nikoscher:
Hey there, using this code snippet:
I was able to get the bid,ask and volume every tick.
Now i just need the last bid,ask and volume every start e.g.
When i activate the 1h chart,
i just want those three value´s every hour once, i tried:
But this doesnt work, anybody could help? Greetings!!You can't use a tick-based function (MqlTick) inside OnStart... That's why you have OnStart and OnTick...
In this case you have to use a kind of "new H1 bar" function inside OnTick. Something like:
//--- globals int oldHour = -1; MqlDateTime time; //--- inside OnTick TimeTradeServer(time); if(time.hour!=oldHour) { Print("This will be printed once every hour!"); oldHour = time.hour; }
ok thanks i just thought i can use onStart like in mql4..
but how can i get last value´s from last hour updated?
this doesnt work:
//--- globals int oldHour = -1; MqlDateTime time; void OnTick() { TimeTradeServer(time); if(time.hour!=oldHour) { Print("This will be printed once every hour!",last_tick.time,": Bid = ",last_tick.bid," Ask = ",last_tick.ask); oldHour = time.hour; } }So the last_tick should stay?
nikoscher:
but how can i get last value´s from last hour updated?
this doesnt work:
So the last_tick should stay?Of course! You cannot forget to use
MqlTick last_tick; SymbolInfoTick(Symbol(),last_tick);
Try this:
//--- globals int oldHour = -1; MqlDateTime time; MqlTick last_tick; void OnTick() { SymbolInfoTick(Symbol(),last_tick); TimeTradeServer(time); //--- if(time.hour!=oldHour) { Print("This will be printed once every hour!",last_tick.time,": Bid = ",last_tick.bid," Ask = ",last_tick.ask); oldHour = time.hour; } }
mhm strange i still get value´s every "tick"..
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hey there, using this code snippet:
I was able to get the bid,ask and volume every tick.
Now i just need the last bid,ask and volume every start e.g.
When i activate the 1h chart,
i just want those three value´s every hour once, i tried:
But this doesnt work, anybody could help? Greetings!!