0

I write the code below but it doesn't show anything on the chart and i dont know why?

#property indicator_chart_window

void OnStart()
{
    double weekly_open = iOpen(NULL, PERIOD_W1, 0);
    double daily_open = iOpen(NULL, PERIOD_D1, 0);

    // Draw the weekly open as a line on the chart
    ObjectCreate("weekly_open", OBJ_HLINE, 0, Time[0], weekly_open);
    ObjectSet("weekly_open", OBJPROP_COLOR, Blue);

    // Draw the daily open as a line on the chart
    ObjectCreate("daily_open", OBJ_HLINE, 0, Time[0], daily_open);
    ObjectSet("daily_open", OBJPROP_COLOR, Red);
}

This should show 2 lines on graph for daily open and weekly open

1 Answers1

0

Your code works fine for me. For a "belt and braces" approach, try the following.

#property indicator_chart_window

int start()
{
    ObjectCreate(0,"weekly_open",OBJ_HLINE,0,Time[0], iOpen(NULL, PERIOD_W1, 0));
    ObjectSet("weekly_open", OBJPROP_COLOR, clrBlue);
    ObjectMove(0, "weekly_open", 0, Time[0], iOpen(NULL, PERIOD_W1, 0));

    ObjectCreate("daily_open", OBJ_HLINE, 0, Time[0], iOpen(NULL, PERIOD_D1, 0));
    ObjectSet("daily_open", OBJPROP_COLOR, clrRed);
    ObjectMove(0, "daily_open", 0, Time[0], iOpen(NULL, PERIOD_D1, 0));
return(0);
}
PaulB
  • 1,262
  • 1
  • 6
  • 17