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

 
   if ( OrderSelect ( OrdersTotal (),SELECT_BY_TICKET,MODE_TRADES)== true && OpenOrdersThisPair( Symbol ())== 1 && OrderType()==OP_BUY){ // Even though I am calling "OP_BUY" here, it doesn't seem to work?
         
         }
         double minLot  = MarketInfo( Symbol (), MODE_MINLOT);
                {
                 Print ( "The minimum lots are: " , DoubleToStr( minLot, Digits ));
                }
                        
         double lotStep = MarketInfo( Symbol (), MODE_LOTSTEP);
                {
                 Print ( "The Lotstep is: " , DoubleToStr( lotStep, Digits ));
                }
                
         double half    = MathCeil (OrderLots()/ 2 /lotStep)*lotStep;
                {
                 Print ( "The Lots to close is: " , DoubleToStr( half, Digits ));
                }
      
       for ( int c= OrdersTotal ()- 1 ; c >= 0 ; c-- )
      {
         if ( OrderSelect (c,SELECT_BY_POS,MODE_TRADES)== true )
            {
             Print ( "Order Ticker Number = " ,OrderTicket());
             Print ( "Order Lots Open = " , OrderLots());
            } 
         else {
           Print ( "Order Select returned the error of " , GetLastError ()); // Order Select does not seem to want to work?
             continue ;
            }
            
           double FirstTarget_Buy = OrderOpenPrice() + ( ( OrderTakeProfit()-OrderOpenPrice() ) / 2 );
           {
           Print ( "FirstTarget_Buy: " , DoubleToStr( FirstTarget_Buy, Digits ));
           }
             if (OrderMagicNumber()==MagicNumber)
               if (OrderSymbol()== Symbol ())
                
               Print ( "Current Bid: " , DoubleToStr(Bid, Digits ), " FirstTarget_Buy: " , DoubleToStr(FirstTarget_Buy, Digits )  );
                 if (OrderType()==OP_BUY && Bid >= FirstTarget_Buy +( Point / 2 ))
                  {
                   Print ( "Bid >= FirstTarget_Buy - Current Bid: " , DoubleToStr(Bid, Digits ), " FirstTarget_Buy: " , DoubleToStr(FirstTarget_Buy, Digits )  );
                   bool Close_Half_Order_Buy = OrderClose(OrderTicket(),half,Bid, 3 , CLR_NONE );
                   if (Close_Half_Order_Buy!=TRUE) Print ( "Close_Half_Order_Buy Last Error = " , GetLastError ());
                  }

         } 
   }
     
약간 지저분하다는 것을 알고 있습니다! 나는 그것을 많이 가지고 놀고 있습니다. 그래서 빨리 우리가 이야기했던 곳으로 되돌려 놓습니까? 나는 당신이이 전체 부분을 의미했다고 가정합니다. 맞습니까?
 
   if (direction== 0 ){ //--Buy--//
      
       double bsl=buy_stop_price;
       double btp=buy_takeprofit_price;
      LotSize = (RiskedAmount/(pips_to_bsl/pips))/ 10 ;
      
       if (OpenOrdersThisPair( Symbol ())== 0 ){
         int BuyTicketOrder = OrderSend ( Symbol (),OP_BUYSTOP,LotSize,buyPrice, 3 ,bsl,btp, NULL ,MagicNumber, 0 ,Green); // This puts out the initial order.
      }
      
         if (OrderStopLoss()< iMA ( NULL , 0 ,MA_Period, 0 , 1 , 0 , 0 )-MA_PadAmount*pips){ // This triggers the For loop if the pending order needs adjusting relative to where the MA is.
         
               for ( int b= OrdersTotal ()- 1 ; b >= 0 ; b--) 
                  {
    
                     if ( OrderSelect (b,SELECT_BY_POS,MODE_TRADES)== true ){
                     Print ( " Stop loss value for the order is " , OrderStopLoss());
                     }
    
                     else if ( OrderSelect (b,SELECT_BY_POS,MODE_TRADES)== false ){
                     Print ( " OrderSelect failed error code is " , GetLastError ());
                     }
                     if (OrderMagicNumber()==MagicNumber)
                         if (OrderSymbol()== Symbol ())
                           if (OrderType()==OP_BUYSTOP)
                               if (OrderStopLoss()< iMA ( NULL , 0 ,MA_Period, 0 , 1 , 0 , 0 )-MA_PadAmount*pips)
                                 if (OpenOrdersThisPair( Symbol ())== 1 ) 
                                 DeleteOrder = OrderDelete(OrderTicket());
                                     if (DeleteOrder!=TRUE) Print ( "DeleteOrder Last Error = " , GetLastError ());
                                  
                                 if (OpenOrdersThisPair( Symbol ())== 0 ) 
                                  NewBuyOrder = OrderSend ( Symbol (),OP_BUYSTOP,LotSize,buyPrice, 3 ,bsl,btp, NULL ,MagicNumber, 0 ,Green); // New Pending order with calibrated stops, lots and targets.
                                   if (NewBuyOrder!=TRUE) Print ( "New Buy Order Last Error = " , GetLastError ());   // This is giving me an "Error 0", despite the trade ACTUALLY being placed correctly...?   

                  }
                 } 
             
               if (NewBuyOrder == true ){
               Print ( "New Buy Order Placed #" , NewBuyOrder);
               }
               else {
               Print ( "New Buy Order Send Failed, error # " , GetLastError ());   
               }
               }
이것은 구매 섹션입니다. "OP_BUYSTOP"이라고 외칩니다.
 
DomGilberto :
약간 지저분하다는 것을 알고 있습니다! 나는 그것을 많이 가지고 놀고 있습니다. 그래서 빨리 우리가 이야기했던 곳으로 되돌려 놓습니까? 나는 당신이이 전체 부분을 의미했다고 가정합니다. 맞습니까?

음. . . 한 걸음 물러서서 심호흡을 하고 코드를 주의 깊게 읽어야 합니다. 기능별 로, 한 줄씩. . . "내가 여기서 무엇을 하려는 거지?" 그런 다음 코드가 그렇게 할 것인지 확인하십시오. . . 예를 들어:

   if ( OrderSelect ( OrdersTotal (), SELECT_BY_TICKET,   MODE_TRADES)== true && OpenOrdersThisPair( Symbol ())== 1 && OrderType()==OP_BUY)

         { // Even though I am calling "OP_BUY" here, it doesn't seem to work?
         
         }

이 if test가 true이면 주석을 실행합니까? ? ? ? ? 잠시 무시합니다. . . OrdersTotal() 티켓 번호는 무엇입니까? SELECT_BY_TICKET SELECT_BY_POS를 사용한 경우 유효한 위치도 아닙니다.


나는 이 코드가 당신에게 문제를 일으키고 있다고 생각하지 않습니다. . . 몇 가지 문제가 있음에도 불구하고.

 

예 - 좋은 자리입니다. 솔직히 말해서 물질적 차이는 없습니다.

흠....

 
DomGilberto :

예 - 좋은 자리입니다. 솔직히 말해서 물질적 차이는 없습니다.

흠....

아니요. . .

랩터영국 :


나는 이 코드가 당신에게 문제를 일으키고 있다고 생각하지 않습니다. . . 몇 가지 문제가 있음에도 불구하고.

나는 당신이 문제를 일으키는 코드를 보여주고 있다고 생각하지 않습니다. . .

 
DomGilberto :
이것은 구매 섹션입니다. "OP_BUYSTOP"이라고 외칩니다.

이것 . . .

 if (OpenOrdersThisPair( Symbol ())== 0 ) 
   NewBuyOrder = OrderSend ( Symbol (),OP_BUYSTOP,LotSize,buyPrice, 3 ,bsl,btp, NULL ,MagicNumber, 0 ,Green); // New Pending order with calibrated stops, lots and targets.

if (NewBuyOrder!=TRUE) Print ( "New Buy Order Last Error = " , GetLastError ());   // This is giving me an "Error 0", despite the trade ACTUALLY being placed correctly...? 

. . . {} 중괄호 문제입니다. . .

 if (OpenOrdersThisPair( Symbol ())== 0 ) 
   {
   NewBuyOrder = OrderSend ( Symbol (),OP_BUYSTOP,LotSize,buyPrice, 3 ,bsl,btp, NULL ,MagicNumber, 0 ,Green); // New Pending order with calibrated stops, lots and targets.

   if (NewBuyOrder != TRUE) Print ( "New Buy Order Last Error = " , GetLastError ());   // This is giving me an "Error 0", despite the trade ACTUALLY being placed correctly...? 
   }

들여쓰기를 정렬하면 이러한 문제를 빠르게 "볼" 것입니다.

 
예, 다시 한 번 좋은 소리입니다. 몇 가지 들여쓰기 문제를 해결하고 해결했습니다. 그래도 같은 문제가 계속 발생합니까? 다른 어떤 코드가 있을 수 있다고 암시합니까? 내 코딩의 다른 부분에서 온 것이라고 상상할 수 없었습니다 ...?
 
if ( OrderSelect ( OrdersTotal (),SELECT_BY_POS,MODE_TRADES)== true && OpenOrdersThisPair(Symbol())==1) // If I put "OrderType() == OP_BUY" it won't work at all. This means that it could just grab a pending order - which is wrong.
  { 
         
         
         double minLot  = MarketInfo( Symbol (), MODE_MINLOT);
                {
                 Print ( "The minimum lots are: " , DoubleToStr( minLot, Digits ));
                }
                        
         double lotStep = MarketInfo( Symbol (), MODE_LOTSTEP);
                {
                 Print ( "The Lotstep is: " , DoubleToStr( lotStep, Digits ));
                }
                
         double half    = MathCeil (OrderLots()/ 2 /lotStep)*lotStep;
                {
                 Print ( "The Lots to close is: " , DoubleToStr( half, Digits ));
                }
      
     for ( int c= OrdersTotal ()- 1 ; c >= 0 ; c-- )
      {
         if ( OrderSelect (c,SELECT_BY_POS,MODE_TRADES)== true )
            {
             Print ( "Order Ticker Number = " ,OrderTicket());
             Print ( "Order Lots Open = " , OrderLots());
            } 
         else {
           Print ( "Order Select returned the error of " , GetLastError ()); 
           continue ;
           }

           double FirstTarget_Buy = OrderOpenPrice() + ( ( OrderTakeProfit()-OrderOpenPrice() ) / 2 );
           {
           Print ( "FirstTarget_Buy: " , DoubleToStr( FirstTarget_Buy, Digits ));
           }
            
             if (OrderMagicNumber()==MagicNumber)
               if (OrderSymbol()== Symbol ())
                
               Print ( "Current Bid: " , DoubleToStr(Bid, Digits ), " FirstTarget_Buy: " , DoubleToStr(FirstTarget_Buy, Digits )  );
                
                 if (OrderType()==OP_BUY && Bid >= FirstTarget_Buy +( Point / 2 )) // Does not go further than this. I do not get an error from OrderClose?
                  {
                   Print ( "Bid >= FirstTarget_Buy - Current Bid: " , DoubleToStr(Bid, Digits ), " FirstTarget_Buy: " , DoubleToStr(FirstTarget_Buy, Digits )  );
                   bool Close_Half_Order_Buy = OrderClose(OrderTicket(),half,Bid, 3 , CLR_NONE );
                   if (Close_Half_Order_Buy!=TRUE) Print ( "Close_Half_Order_Buy Last Error = " , GetLastError ());
                  }
                   
       } 
   }
꼼짝 못하고 있습니다. 많은 변화와 변화를 시도했지만 지금은 존재하는지도 모르는 무언가를 놓친 경우일 것입니다. 그래야만 합니까? OrderType()==OP_BUY가 작동하지 않는 것 같습니까? 위 코드의 참고 사항을 참조하십시오 - 들여쓰기를 확인 했습니다... 정말 대단합니다! ㅋ...
 
DomGilberto :
예, 다시 한 번 좋은 소리입니다. 몇 가지 들여쓰기 문제를 해결하고 해결했습니다. 그래도 같은 문제가 계속 발생합니까? 다른 어떤 코드가 있을 수 있다고 암시합니까? 내 코딩의 다른 부분에서 온 것이라고 상상할 수 없었습니다 ...?
LOL, 나도 몰라, 내가 다 본 적이 없어. . . 하지만 OP_BUY가 있을 때 인쇄를 실행하는 코드를 중지하는 것이 있습니다.
 
2013.08.02 10:52:47	2013.02.01 15:00  trendfishing_play_ground EURUSD,H1: NEW BUY ORDER:-  Lots to open: 0.18215 Entry Price: 1.36790 Buy Stop Loss: 1.35649 Buy Take Profit: 1.39072 Magic Number is: 1234.00000

이것은 나의 for 루프 동안 저널에 인쇄되고 있습니다. 보류 중인 구매 중지 주문의 경우 60 EMA가 OrderStopLoss보다 크면 보류 중인 주문을 닫고 새 SL로 새 주문을 엽니다. 60EMA 뒤에 있음), 1:2 보상을 즐기기 위해 이익 실현을 조정하고 포인트 및 내 위험 프로필(예: 2%)의 스탑을 기준으로 로트를 변경합니다.

따라서 이 모든 작업이 완료되면 OrderSend 내의 "LotSize" 사용자 정의 변수인 "Current Lot"가 작동하는데 서버가 수신할 수 없는 잘못된 크기의 로트를 보내는 것입니까? "0.18215"? 어쨌든 주문이 실제로 전송되었음에도 불구하고 이것이 문제가 될 수 있습니다. 이 질문은 "이것이 "OrderType==OP_BUY"를 호출할 수 없는 이유와 더 관련이 있습니까?

이것은 longgggg 프로세스입니다 lol ...