for(Count = 0; Count <= OrdersHistoryTotal()-1; Count++) { }
Think about what this is doing.
if(OrderProfit() > 0) SellOrder = 0;
I want to set the SellOrder to "zero" 0 when there was a profit by a Sell transaction. So if OrderProfit() > 0 it must set the variable SellOrder equal to = 0.
Am I doing it wrong?
I want to set the SellOrder to "zero" 0 when there was a profit by a Sell transaction. So if OrderProfit() > 0 it must set the variable SellOrder equal to = 0.
Am I doing it wrong?
It depends on what you want the code to do.
As it is, if the last sell trade checked in the loop closed with profit, SellOrder is set to 0.
That is exactly what I want to do.
But my main problem is that if there are losing trades and no subsequent profit trade it does not register or count those losing trades. The number of losing trades never go higher than "0" even if there are 3 or more losing trades in a row. And I cannot figure out why!
That is exactly what I want to do.
But my main problem is that if there are losing trades and no subsequent profit trade it does not register or count those losing trades. The number of losing trades never go higher than "0" even if there are 3 or more losing trades in a row. And I cannot figure out why!
How do you know that it never goes higher than 0?
Add a print and you should see it increase
if(OrderProfit() < 0) SellOrder++; if(OrderProfit() > 0) SellOrder = 0; Print("Losing Sell count = ",SellOrder);
Try:
int SellOrder; int prev_calc; void test() { //.......... //Your code //.......... for(Count = prev_calc ; Count <= OrdersHistoryTotal()-1; Count++) { if(OrderSelect(Count, SELECT_BY_POS, MODE_HISTORY) && OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol() && OrderType() == OP_SELL) { if(OrderProfit() < 0) SellOrder++; if(OrderProfit() > 0) SellOrder = 0; } } prev_calc = OrdersHistoryTotal(); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to count all the loss trades in total or after the last profit trade but i keep on getting "0"(zero) no matter how many loss Sell trades there were with no profit trades in between.
Here is the code: