code for MT4 which shows daily open and weekly open values as a straight line on the same chart
code for MT4 which shows daily open and weekly open values as a straight line on the same chart
Loading saved threads...
Can Cankaya · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Can Cankaya
Original post: https://stackoverflow.com/questions/75976862
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: PaulB
Original post: https://stackoverflow.com/a/75979060
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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);
}
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Can Cankaya Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/75976862 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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
Checking account access…