Page 1 of 1

mql4 help

Posted: Mon Nov 28, 2011 2:29 pm
by forexjake80
I wanna draw a horizontal line in a given time period... can anyone help me with that? Best thing i could come up with so far is a OBJ_TREND with 2x the same price.

Posted: Mon Nov 28, 2011 3:53 pm
by Relativity
Take this :

void DrawHLine(string objname,string objLabel, double LinePrice, color LineColor, int styleno, datetime myStartTime,datetime myEndTime, int thicknessCtrl, int RayCtrl)
{
string linename = objname+"HLine";
string lblname = objname+"HLineLbl";

ObjectDelete(linename);
ObjectCreate(linename, OBJ_TREND, 0, myStartTime, LinePrice, myEndTime, LinePrice);
ObjectSet(linename, OBJPROP_COLOR, LineColor );
ObjectSet(linename, OBJPROP_RAY, RayCtrl );
ObjectSet(linename, OBJPROP_WIDTH, thicknessCtrl );
ObjectSet(linename,OBJPROP_STYLE,styleno);

ObjectDelete(lblname);
ObjectCreate(lblname, OBJ_TEXT, 0, myEndTime + (myStartTime-myEndTime)/2, LinePrice);
ObjectSetText(lblname, objLabel, myFontSize, myFont, LineColor);
}


Usage Example :
DrawHLine("PsychLine"," Psych Line ", PsychLinePrice, PsychLineColor, 0 , Time[1000],Time[0],1,0);

Posted: Mon Nov 28, 2011 6:40 pm
by forexjake80
ahhhhhhhh.... OBJPROP_RAY gotta be false.... thanks Rel!!

Posted: Mon Nov 28, 2011 10:34 pm
by Relativity
no probs!