for(int cnt = 0; cnt < OrdersTotal(); cnt++)
The better practice is to count down, rather than up, when looping through orders. See Loops and Closing or Deleting Orders.
Why are you doing it this way:
if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))continue;
What about doing it this way instead:
if (OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) if (OrderSymbol() == Symbol()&& OrderMagicNumber() == MagicNumber) { LastLot = OrderLots(); Commission = OrderCommission(); MLots = NormalizeDouble( LastLot * Multiplier,2); }
is it value accessible in any part of code including void functions
The scope of a variable would be determined on where you defined that variable. See Types of Variables.
could one use this place to get OrderCommission()?
Yes. See OrderCommission().
Hi all,
I want to get the OrderCommission() of an open order,
Which open order ? if you have more than one your code will return the commision just for one of them.
Hi RaptorUK,
I bet you start to thing that I am a completely idiot but I'm doing my best to get the grips on mql.
so, why do I ask for OrderCommission ?
Well the issue is that I just want that the trailing stop start when AccountProfit() is above 0 for that I use this code,
if(OrderStopLoss() < Bid - (TrailingStop * pips2dbl) && Bid - OrderOpenPrice() > (MinimumProfit*pips2dbl) && AccountProfit() > 0)
Now, when one looks for the terminal could be seen that AccountProfit() is the result of the difference of order profit minus commission, but when the order close the commission is take from the order profit and in that case the
OrderProfit() value that we see on terminal while the order is running is not liquid ( the value is take at the close instead).
So I thought if I get that value from commission and subtract it from the OrderProfit() then the code will be;
if(OrderStopLoss() < Bid - (TrailingStop * pips2dbl) && Bid - OrderOpenPrice() > (MinimumProfit*pips2dbl) && AccountProfit() - commission > 0)
The better practice is to count down, rather than up, when looping through orders. See Loops and Closing or Deleting Orders.
Why are you doing it this way:
What about doing it this way instead:
Hi Thirteen:,
Thank you for your prompt response to my issue.
People like RaptorUK and WHRoeder are always tell me to get the count down (...) and this the last part of my code where I missed it, but now is DONE !!!
Thank you again for your support.
Luis
Hi RaptorUK,
I bet you start to thing that I am a completely idiot but I'm doing my best to get the grips on mql.
Hi Thirteen:,
Thank you for your prompt response to my issue.
People like RaptorUK and WHRoeder are always tell me to get the count down (...) and this the last part of my code where I missed it, but now is DONE !!!
Thank you again for your support.
Luis
Hi Thirteen:,
The problem when count down is that order lots do not behave accordingly. I mean, if first lot is 0.01, second is 0.02 , third should be 0.03, but it comes with 0.02 again.
When op by count up lots keep going well...
Luis
Hi Thirteen:,
The problem when count down is that order lots do not behave accordingly. I mean, if first lot is 0.01, second is 0.02 , third should be 0.03, but it comes with 0.02 again.
When op by count up lots keep going well...
Luis
if(MLots <= OrderLots())MLots = NormalizeDouble( OrderLots() * Multiplier,2);
Change your MLots line
Hi deVries,
Thank you for your attention to my issue.
It's done...let's test it(....)
Best Regards
Luis
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I want to get the OrderCommission() of an open order, for that have include extra code in the following block,
Is this right and if so is it value accessible in any part of code including void functions if I put double Commission; in Global ?
Thanks in advance for any help provided.
Luis