When a time is hit, I want to store the current price in a attribute. That attribute does not change.
I know to use datetime, and Bid. But Bid will refresh on every tick, I assume.
It is for data release buy/sell stop strategy. The second data is released, store currentprice. Then set sell/buy orders. When one order is hit, set its SL to the currentprice.
I hope one will understand, thank you
- Ask and bid price in BUY and SELL order
- MT4 flaky giving different backtest results with no changes
- how to store a Bid Ask price when condition hits?
#property strict #define DAY 86400 #define HOUR 3600 #define MIDNIGHT (TimeCurrent()-TimeCurrent()%DAY) int when = 6*HOUR; // 06:00 double stored_price = 0; int OnInit() { EventSetTimer(1); return(INIT_SUCCEEDED); } void OnTimer() { static datetime next_check = TimeCurrent()%DAY > when ? MIDNIGHT+when+DAY: MIDNIGHT+when; if(TimeCurrent() >= next_check) { stored_price = Bid; next_check = MIDNIGHT+when+DAY; printf("Price updated: %f Next check %s",stored_price,TimeToString(next_check)); } } void OnTick() { // do whatever you need with stored_price }
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