Drawing Lines Question

 

I want to be able to draw a series of lines, 30 pips apart, from the high of the day to the low. The code below accomplishes this, but no matter where I put the code in my EA, some lines don't draw. I think it's because of other objects being drawn. If I keep compiling the code, I get different results, but same problem. Some lines get skipped. If I run the code in as a script or indicator, only the first line is drawn. Can anyone tell me what I'm doing wrong? Also, would like the lines to be dashed.

Thanks!

int NXCnt;

double NX;

double vDH=iHigh(NULL,1440,0); // Daily High

double vDL=iLow(NULL,1440,0); // Daily Low

NXCnt = NXCnt + 1;

double TX = ( 0.00030 * NXCnt );

NX = (vDH - TX);

// Alert("NX = ",DoubleToStr(NormalizeDouble(NX,5),5)," vDH = ",DoubleToStr(NormalizeDouble(vDH,5),5)," vDL = ",DoubleToStr(NormalizeDouble(vDL,5),5)," NXCnt = ",NXCnt);

if( NX > vDL )

{

// ChartRedraw();

ObjectCreate(StringConcatenate("T30",TimeCurrent()),OBJ_HLINE,0,TimeCurrent(),NX);

ObjectSet(StringConcatenate("T30",TimeCurrent()), OBJPROP_COLOR, LightBlue);

}

 
Yellowbeard:
I want to be able to draw a series of lines, 30 pips apart, from the high of the day to the low. The code below accomplishes this, but no matter where I put the code in my EA, some lines don't draw. I think it's because of other objects being drawn. If I keep compiling the code, I get different results, but same problem. Some lines get skipped. If I run the code in as a script or indicator, only the first line is drawn. Can anyone tell me what I'm doing wrong? Also, would like the lines to be dashed.

Thanks!

int NXCnt;

double NX;

double vDH=iHigh(NULL,1440,0); // Daily High

double vDL=iLow(NULL,1440,0); // Daily Low

NXCnt = NXCnt + 1;

double TX = ( 0.00030 * NXCnt );

NX = (vDH - TX);

// Alert("NX = ",DoubleToStr(NormalizeDouble(NX,5),5)," vDH = ",DoubleToStr(NormalizeDouble(vDH,5),5)," vDL = ",DoubleToStr(NormalizeDouble(vDL,5),5)," NXCnt = ",NXCnt);

if( NX > vDL )

{

// ChartRedraw();

ObjectCreate(StringConcatenate("T30",TimeCurrent()),OBJ_HLINE,0,TimeCurrent(),NX);

ObjectSet(StringConcatenate("T30",TimeCurrent()), OBJPROP_COLOR, LightBlue);

}

Yellowbeard

StringConcatenate("T30",TimeCurrent() ) does not guarantee that the name of the object will be unique. Make some procedure that will assign unique name for each and every line

 
mladen:
Yellowbeard StringConcatenate("T30",TimeCurrent() ) does not guarantee that the name of the object will be unique. Make some procedure that will assign unique name for each and every line

Thanks mladen!

I just had to change TimeCurrent() to Time[NXCnt].

ObjectCreate(StringConcatenate("T30",Time[NXCnt]),OBJ_HLINE,0,Time[NXCnt],NX);

ObjectSet(StringConcatenate("T30",Time[NXCnt]), OBJPROP_COLOR, LightBlue);

Any advice on how to make the lines dashed?

Thanks!

 

O.k. Figured it out.

ObjectCreate(StringConcatenate("T30",Time[NXCnt]),OBJ_HLINE,0,Time[NXCnt],NX);

ObjectSet(StringConcatenate("T30",Time[NXCnt]), OBJPROP_STYLE,STYLE_DOT);

ObjectSet(StringConcatenate("T30",Time[NXCnt]), OBJPROP_COLOR, LightBlue);