Is this on purpose? is there a difference between strategy tester and live chart for drawing a line? thanks a lot in advance.
You have not shown your code, nor a screenshot nor output from the logs. We can't see your computer nor read your mind.
So, if you want a reasonable answer, please provide more details.
Hello, ok, here I am trying to summarise the relevant code:
//Inside "OnTick", I am checking if the condition was met: if(LineSignal()) { // it means that a recommendation was received, I want to draw a line DrawLines(); } // end of line signal //Here is the function to check, if the condition is met: //+------------------------------------------------------------------+ //| Line Signal | //+------------------------------------------------------------------+ bool LineSignal() { bool condition1 = false; long CurrentTime = 0; long CheckTime = 0; CurrentTime = TimeGMT(); CheckTime = CurrentTime + 30; // plus 30 seconds // check if current time = recommendation time if( (CurrentTime <= PreferredRecommendation.ValidFrom) // this information is an array which holds a date &&(CheckTime >= PreferredRecommendation.ValidFrom) ) {condition1 = true;} if(condition1){ return true;} else { return false;} } // end Line Signal //This is the function to draw a line: //+------------------------------------------------------------------+ //| Draw a line or multiple lines | //+------------------------------------------------------------------+ void DrawLines() { //ObjectDelete(0, "VerticalLine"); // 0 = current chart ObjectCreate(0, "VerticalLine", OBJ_VLINE, 0, TimeGMT() ,0 ); ObjectSetInteger(0,"VerticalLine", OBJPROP_COLOR,clrMagenta); ObjectSetInteger(0, "VerticalLine", OBJPROP_WIDTH, 1); // end of drawing a vertical lilne } // end of drawing lines
and a screenshot of a "simulation", where it does draw the line:
KjLNi #: Hello, ok, here I am trying to summarise the relevant code:
... CurrentTime = TimeGMT(); ... ObjectCreate(0, "VerticalLine", OBJ_VLINE, 0, TimeGMT() ,0 ); ...
Chart time is based on trade server time zone, not GMT.
In the strategy tester, both TimeCurrent() and TimeGMT() give the same time, but not on a live chart.
In other words, you can't use GMT time for graphical objects on the chart. You will have to use the trade server's time zone and not GMT.
just to document the solution, it works like this for me:
//+------------------------------------------------------------------+ //| Draw a line or multiple lines | //+------------------------------------------------------------------+ void DrawLines() { datetime ServerTime = (datetime)SymbolInfoInteger(_Symbol,SYMBOL_TIME); //ObjectDelete(0, "VerticalLine"); // 0 = current chart ObjectCreate(0, "VerticalLine", OBJ_VLINE, 0, ServerTime ,0 ); ObjectSetInteger(0,"VerticalLine", OBJPROP_COLOR,clrMagenta); ObjectSetInteger(0, "VerticalLine", OBJPROP_WIDTH, 1); // end of drawing a vertical line } // end of drawing lines

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, I have created an expert advisor which should draw a line if a certain condition is reached (MT5).
When I simulate it in strategy tester, it works.
But when I attach it to a live chart, it does not draw the line.
Is this on purpose? is there a difference between strategy tester and live chart for drawing a line?
thanks a lot in advance.