for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==Magic && OrderStopLoss() == 0 && OrderProfit() > 0) YourCounterVariable ++
}
Dear heyarn,
Thank you.
I will try it
Regards
Paulo
heyarn:
for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==Magic && OrderStopLoss() == 0 && OrderProfit() > 0) YourCounterVariable ++
}
Heyarn,
It worked. Thank you very much
Regards
Paulo
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
Dear all,
I need your help on developing a code for controling the number of existing positions openned. NOT ALL just the negative ones.
I have a sample code that limits the number of open trades/positions but this one considers all positions and not just the negative positions.
The code is:
"bool ExistPositions()
{
for (int l_pos_0 = maxtrades; l_pos_0 < OrdersTotal(); l_pos_0++)
{
if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES))
if (OrderSymbol() == Symbol()) return (TRUE);
}
return (FALSE);
}
...where "maxtrades" is the number of maximum existing positions.
What I need is a code like this one, that controls the positions that are not already TRAILLED STOP.
That is:
- If the position is already positive and trailled, DO NOT CONSIDER;
- If the position is negative, or NOT trailled, ONSIDER;
Thank you very much
Regards
Paulo