Thank you for your reply!
The problem is that I want to call the function each time I make a new trendline, and then run it for everyone of these trendlines each time a new bar is created. So basically I will have the function running multiple instances simultaneously. With your idea I will have to create a vector with all of my trendlines, and add/delete trendlines from it, that seems more difficult.
Thank you for your reply!
The problem is that I want to call the function each time I make a new trendline, and then run it for everyone of these trendlines each time a new bar is created. So basically I will have the function running multiple instances simultaneously. With your idea I will have to create a vector with all of my trendlines, and add/delete trendlines from it, that seems more difficult.
Check for a new trendline in OnChartEvent()
Hi everyone, I'm quite new to mql4 but I hope my thinking still makes sense.
In the start function I create a trendline that I then want to check the price for for every coming bar. So far i've created a function outside of the start function that checks the price of it, but I am not sure how to make it run once per bar? Just creating a while(true) loop feels horribly ineffective. Hence my question: is there any way to make mt4 wait until a certain condition is true, such as a new bar being created? Once again: I am not inside of the start-function and so my function won't update once per tick.
Take care
datetime newBar = 0; void OnTick(void) { if( newBar != Time[0] ) { newBar = Time[0]; // work } }MQL4/5
datetime newBar = 0; void OnTick(void) { datetime time_bar[]; if( CopyTime(_Symbol, 0, 0, 1, time_bar) == 1 ) if( newBar != time_bar[0] ) { newBar = time_bar[0]; // work } }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone, I'm quite new to mql4 but I hope my thinking still makes sense.
In the start function I create a trendline that I then want to check the price for for every coming bar. So far i've created a function outside of the start function that checks the price of it, but I am not sure how to make it run once per bar? Just creating a while(true) loop feels horribly ineffective. Hence my question: is there any way to make mt4 wait until a certain condition is true, such as a new bar being created? Once again: I am not inside of the start-function and so my function won't update once per tick.
Take care