I'm new to EA programming and I'm working on a project that analyzes the price difference between two points in time, in seconds.
My goal is to identify stretched prices over short periods of time.
I already have a robot that analyzes this "stretch" in seconds, using this:
TimeCurrent() <= (iTime(NULL, PERIOD_M1, 0) + 5)
The problem is that the parameter I use to get the first price is the iOpen and this is obviously the bar's opening price... That is, I can't get the price difference between the second 5 and 10 of the bar, as iOpen is always based on the beginning of the slash.
I would be very grateful if someone could give me an idea of how to get the price in a given second of the bar (second 5, for example)...
Big hug to all!
- How to get the price from 5 seconds ago?
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
- How to only open trade in first x seconds of a new candle ?
Not compiled, not tested, just typed.
datetime now=TimeCurrent(); static int nTick=EMPTY; static datetime tickTime; static double price[2]; static datetime time0=0; datetime time1=time0; time0=iTime(_Symbol,_Period,0); bool isNB=time0!=time1; if(isNB){ nTick=0; tickTime=now; return; // Enable elapsed time code. } if(nTick == EMPTY) return; // Wait for a new bar. if(now - tickTime < 5) return; // Wait for elapsed time. double Bid=iClose(_Symbol, _Period, 0); // Store prices. price[nTick++] = Bid; tickTime=now; if(nTick < 2) return; nTick=EMPTY; // Disable elapsed time code. process(price); // Process elapsed time prices.Not compiled, not tested, just typed.
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