Fishtank:
Can you store the price in just a variable? So maybe at the end of the EA add a line of code like:
int Previous_Price;
Previous_Price= Ask;
Can you store that for the next tick as the EA re-initializes? or does it get wiped out no matter what?
Do I need to use an Array even if I ONLY need the previous tick's price data?
Or is there a different way I can't think of that's better?
If only the last data point is to be saved then check out the Static variable Declarations capability of MT. In the dictionary > variables > static variable section. Can you store the price in just a variable? So maybe at the end of the EA add a line of code like:
int Previous_Price;
Previous_Price= Ask;
Can you store that for the next tick as the EA re-initializes? or does it get wiped out no matter what?
Do I need to use an Array even if I ONLY need the previous tick's price data?
Or is there a different way I can't think of that's better?
The CockeyedCowboy
Fishtank,
if you need the Var alive OVER the span of the EA, just use the GlobalVariableXXX set of functions. They retain even if you exit MT4 until you specifically delete them.
m
if you need the Var alive OVER the span of the EA, just use the GlobalVariableXXX set of functions. They retain even if you exit MT4 until you specifically delete them.
m
CockeyedCowboy:
The CockeyedCowboy
Fishtank:
Can you store the price in just a variable? So maybe at the end of the EA add a line of code like:
int Previous_Price;
Previous_Price= Ask;
Can you store that for the next tick as the EA re-initializes? or does it get wiped out no matter what?
Do I need to use an Array even if I ONLY need the previous tick's price data?
Or is there a different way I can't think of that's better?
If only the last data point is to be saved then check out the Static variable Declarations capability of MT. In the dictionary > variables > static variable section. Can you store the price in just a variable? So maybe at the end of the EA add a line of code like:
int Previous_Price;
Previous_Price= Ask;
Can you store that for the next tick as the EA re-initializes? or does it get wiped out no matter what?
Do I need to use an Array even if I ONLY need the previous tick's price data?
Or is there a different way I can't think of that's better?
The CockeyedCowboy
if you do this...
int rc;
double nzdusd[][6];
rc=ArrayCopyRates(nzdusd,"NZDUSD",0);
nzdusd[0][4]; //current close price
nzdusd[1][4]; //previous close price
nzdusd[2[4]; //etc...
note, arraycopyrates returns the number of bars read.
i found that if i would physically open an nzdusd chart and
manually scroll back in time(once for all time frames) this
would fill mq's cache and then arraycopyrates will read more
bars.
int rc;
double nzdusd[][6];
rc=ArrayCopyRates(nzdusd,"NZDUSD",0);
nzdusd[0][4]; //current close price
nzdusd[1][4]; //previous close price
nzdusd[2[4]; //etc...
note, arraycopyrates returns the number of bars read.
i found that if i would physically open an nzdusd chart and
manually scroll back in time(once for all time frames) this
would fill mq's cache and then arraycopyrates will read more
bars.
Thanks for the responses guys, the GlobalVariableSet/Get functions suited my purpose great. It's always great to learn more ways than
one though!
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
int Previous_Price;
Previous_Price= Ask;
Can you store that for the next tick as the EA re-initializes? or does it get wiped out no matter what?
Do I need to use an Array even if I ONLY need the previous tick's price data?
Or is there a different way I can't think of that's better?