절반 부지를 폐쇄합니다. - 페이지 19

 
많은 사람들이 이 문제를 해결하고 작동하는 방법을 이해하는 데 도움을 주었기 때문에 이 스레드를 업데이트하는 것이 공정할 것이라고 생각했습니다! 이것이 내가 너트처럼 달콤하게 작동하고 적절한 시간에 닫는 방법입니다. 먼저 FirstTarget이 true이고 성공적으로 닫히면 EMA가 닫히고 TwoRatio_Buy 타겟이 닫힙니다.

 //+--------------------------------------------------------------------------------------------------+
//| Close OP_BUY Half lots @ 1:1 Function                                                            |
//+--------------------------------------------------------------------------------------------------+
void CloseHalfOrder()
{   
   
   static datetime partclosedonce;
   static datetime partclosedtwice;
   static datetime partclosedthird;
   
   double minLot=MarketInfo( Symbol (),MODE_MINLOT);
   double lotStep=MarketInfo( Symbol (),MODE_LOTSTEP);
   double half_1st= MathFloor (OrderLots()/First_Target/lotStep)*lotStep;
   double half_2nd= MathFloor (OrderLots()/EMA_Target/lotStep)*lotStep;
   double Target_2 = MathFloor (OrderLots()/Second_Target/lotStep)*lotStep;
   
   double EMA_Bar = iClose( NULL , PERIOD_H1 , 1 );
   double EMA_MA = iMA ( Symbol (), 60 , 21 , 0 , 1 , 0 , 0 );
   
   double FirstTarget_Buy = OrderOpenPrice()+(( OrderTakeProfit()-OrderOpenPrice())/ 6 );
   double TwoRatio_Buy = OrderOpenPrice()+(( OrderTakeProfit()-OrderOpenPrice())/ 3 );  

   
for ( int c= OrdersTotal ()- 1 ; c>= 0 ; c--)
    {
       if ( OrderSelect (c,SELECT_BY_POS,MODE_TRADES))
       if (OrderMagicNumber()==MagicNumber)
         if (OrderSymbol() == Symbol ())
        { 
         
           if (OrderOpenTime() != partclosedonce)  
           if (OrderType()==OP_BUY && Bid >= FirstTarget_Buy+( Point / 2 ) && OrderLots()>minLot) 
              {
               bool Close_Half_Order_Buy=OrderClose(OrderTicket(),half_1st,Bid, 5 ,Blue);
              }
               
           if (Close_Half_Order_Buy==True && OrderOpenPrice() > OrderStopLoss())
              {
              MoveToBreakEven(); 
              }
               if (Close_Half_Order_Buy==True)
                 {
                 partclosedonce = OrderOpenTime();
                 } 
      
           if (partclosedonce == OrderOpenTime() && partclosedonce != partclosedtwice && OrderOpenTime() != partclosedtwice)
           if (Bid - OrderOpenPrice() > Point / 2 . 
            && OrderType()==OP_BUY && EMA_Bar < EMA_MA && OrderLots()>minLot)
              {
               bool EMA_Buy_Close=OrderClose(OrderTicket(),half_2nd,Bid, 5 , CLR_NONE );
               if (EMA_Buy_Close==True)partclosedtwice = OrderOpenTime();
              }     
                 
           if (OrderOpenTime() != partclosedthird)
           if (OrderType()==OP_BUY && Bid >= TwoRatio_Buy+( Point / 2 ) && OrderLots()>minLot)
              {
               bool Two_Ratio_Buy=OrderClose(OrderTicket(),Target_2,Bid, 5 , CLR_NONE );
               if (Two_Ratio_Buy==True)partclosedthird = OrderOpenTime();
              }     
        }
     }
}
사유: