double TOTAL_LOSSES() { double pr_2=0; for( i=OrdersHistoryTotal()-1; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) { if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber) { if((OrderProfit()+OrderCommission()+OrderSwap())<0) { pr_2+=(OrderProfit()+OrderCommission()+OrderSwap()); } } }return(pr_2); }return(pr_2++); }
You are returning after the first run of the loop
You are returning after the first run of the loop
thank you buddy yea i tried it like this now :
double LOSSES() { double pr_2=0; for( i=OrdersHistoryTotal()-1; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) { if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber) { if((OrderProfit()+OrderCommission()+OrderSwap())<0) { pr_2+=(OrderProfit()+OrderCommission()+OrderSwap()); } } } }return(pr_2++); }
now its summing the losses for all orders from 0 to last one , excluding the profit one,but i want it to return(0) after hitting a takeprofit, any idea how to do that?
thank you buddy yea i tried it like this now :
now its summing the losses for all orders from 0 to last one , excluding the profit one,but i want it to return(0) after hitting a takeprofit, any idea how to do that?
Check if the trade earned profit, if it did, return(0) but what would be the point of that?
Check if the trade earned profit, if it did, return(0) but what would be the point of that?
yes buddy i know but how to write that in the code?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everybody,
im trying to sum the total loss of the closed orders that closes on LOSS ,
i tried as much as i can, here is what i got :
but it seems that its calculating the last Order LOSSES only,
any help appreciated ,
thanks in advance