I want to write an EA that joins the highest points of each candle using a trend line (after the first hour of a day). I saw the documentation for the trend line.
This is what I've done:
ObjectCreate(chart_ID,name,OBJ_TREND,sub_window,time1,price1,time2,price2)
ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
ObjectSetInteger(chart_ID,name,OBJPROP_RAY,false);
I know I am suppose to iterate through the highest value for each candle and get it's time, but I'm not sure how to go about this. How can this be done?
This image shows what I am trying to do
UPDATE
I tried this but it's not displaying the line. Also how can I specifically limit the trend line to join candles that appear after the first hour of the day?
void CalculateTrendLine() {
for(int i=0;i<30;i++){
if (iTime(_Symbol,60,i) > 1) {
ObjectCreate(0,"TLine"+i,OBJ_TREND,0, iTime(_Symbol,0,i), iHigh(_Symbol,0,i), iTime(_Symbol,0,i+1), iHigh(_Symbol,0,i+1));
printf("trend start", iHigh( _Symbol,0,i));
printf("trend end", iHigh( _Symbol,0,i+1));
ObjectSetInteger(0,"TLine"+i,OBJPROP_COLOR,clrMagenta);
ObjectSetInteger(0,"TLine"+i,OBJPROP_STYLE,STYLE_SOLID);
ObjectSetInteger(0,"TLine"+i,OBJPROP_RAY,false);
}
} }

iTime(_Symbol,0,i)gives you time of thei-th candle (0-current) andiHigh(_Symbol,0,i)gives high of the candle. - Daniel Kniazi>20in loop condition - Daniel Kniaz