kyle1681:
Any comment and any suggestion will help,
Thanks.
Your indenting is horrible . . . IMO, maybe you love it . .
} } } } } }
Check return values from your OrderModify, if it fails Print a message telling you the ticket number, the error number and any other helpful info . . .
I don't see an OrderSelect . . . I assume you check that it works ? if not you should.
Because of......
//================Averaging*/ if(OrderType() == OP_SELL) { // <<=== HERE FIRST BRACKET OPEN OP_SELL open_sell++; // TotalSellProfit=TotalSellProfit+OrderProfit()+OrderSwap()+OrderCommission(); if(FirstSellTime==0 || FirstSellTime>OrderOpenTime()) { // << OKE 1 FirstSellTime=OrderOpenTime(); FirstSellPrice=OrderOpenPrice(); FirstSellLot=OrderLots(); FirstSellStopLoss=OrderStopLoss(); FirstSellTakeProfit=OrderTakeProfit(); } // CLOSE 1 if(LastSellTime<OrderOpenTime()) { // << OKE 2 LastSellTime=OrderOpenTime(); LastSellPrice=OrderOpenPrice(); LastSellLot=OrderLots(); LastSellStopLoss=OrderStopLoss(); LastSellTakeProfit=OrderTakeProfit(); } // CLOSE 2 if(OrderStopLoss()==0 || OrderTakeProfit()==0) { // << 3 if(StoplossUse) tmpStoploss=OrderOpenPrice()+Stoploss*PointDigit; else tmpStoploss=0; if(TakeprofitUse) tmpTakeprofit=OrderOpenPrice()-Takeprofit*PointDigit; else tmpTakeprofit=0; if(tmpStoploss>0 || tmpTakeprofit>0) OrderModify(OrderTicket(),OrderOpenPrice(),tmpStoploss,tmpTakeprofit,0,DarkOrange); } // CLose 3 If one of those is 0 it will modify every time again // if it is changed one Time /* // WHY NOT....... if(OrderStopLoss()==0 && OrderTakeProfit()==0) { // && instead of || if(StoplossUse) tmpStoploss=OrderOpenPrice()+Stoploss*PointDigit; else tmpStoploss=0; if(TakeprofitUse) tmpTakeprofit=OrderOpenPrice()-Takeprofit*PointDigit; else tmpTakeprofit=0; if(tmpStoploss>0 || tmpTakeprofit>0) OrderModify(OrderTicket(),OrderOpenPrice(),tmpStoploss,tmpTakeprofit,0,DarkOrange); } */ if(TrailingstopUse == true ){ // OKE 4. if ( OrdersTotal() == 1 ) { // 4.1 if(OrderOpenPrice() - Ask > TrailingSinglestop*PointDigit) { // 4.2 if(OrderStopLoss() > Ask + (TrailingSinglestop+TrailingSinglestep-1)*PointDigit) { // 4.3 WHY TrailingSinglestep-1 // if TrailingSinglestep = 1 it goes wrong modify same SL OrderModify(OrderTicket(), OrderOpenPrice(), Ask + (TrailingSinglestop) * PointDigit, OrderTakeProfit(), 0, DarkOrange); } // end 4.1 } // end 4.2 } // end 4.3 if( OrdersTotal() > 1 ) { // 4.4 OrdersTotal() can be also > 1 if other Symbol is trading if(AvgPrice - Ask > Trailingstop*PointDigit) { // 4.5 What is AvgPrice ?? // With only sells or buys and sells if(OrderStopLoss() > Ask + (Trailingstop+Trailingstep-1)*PointDigit) { //4.6 again TrailingSinglestep-1 OrderModify(OrderTicket(), OrderOpenPrice(), Ask + (Trailingstep) * PointDigit, OrderTakeProfit(), 0, DarkOrange); // << YOUR ERROR TRAILINGSTEP } //end 4.4 } // end 4.5 } //end 4.6 } // end 4. } // end OP_SELL
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
OMG,, this is driving me crazy..
Long positioin works fine but why short position doesn't !!!
I checked Symbol, MagicNo, Everything...
Now,, just gently requesting the help from your fresh eyes,,,
My eyes are no good any more..
Any comment and any suggestion will help,
Thanks.