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
Thank you for answer mladen.
Hmm, but it doesn't seem to do what I want the program to do.
Like I said last time, I need the PreviousValue to equal CurrentValue only if there are no trades placed. If there is an active trade, I want PreviousValue not to equal currentvalue but equal the last currentvalue before the trade was placed (thats why we made previousvalue static, remember?).
bool IsTrade=False;
static double PreviousValue=-1;
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol())
{
IsTrade = True;
PreviousValue = CurrentValue;
} [/php]
This code seems to set previousvalue equal to current value only when there is a trade active. It is an opposite of what i am trying to achieve.
Thank you.If you need to store value only if there is no trade active, why don't you count the number of currently opened orders for a magic number and symbol and assign a value to previous value only if that number of currently opened orders is 0?
Something like this :
[PHP] int count=0;
for (int i=OrdersTotal()-1; i>=0; i--)
{
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber() != SomeMagicNumber) continue;
if (OrderType()==OP_BUY || OrderType()==OP_SELL)
count++;
}
if (count==0) PreviousValue = CurrentValue;
That way it will not depend on any variable and can easily be run from multiple terminals and multiple EA instances without a possibility of error
Thanks a lot :-) works like a charm now :-) well, at least it does what its supposed to...