MQL4 및 MQL5에 대한 초보자 질문, 알고리즘 및 코드에 대한 도움말 및 토론 - 페이지 464

 

@Konstantin Nikitin 더 쉽습니다! 당신은 특별하다! 공부해요! 스위치는 아직 전혀 사용되지 않았습니다!

 if (! OrderSelect (i, SELECT_BY_POS )) continue ;
     if ( OrderSymbol ()!= Symbol ()) continue ;
А это как прочитать? Если (Ордер не выбран) продолжить;
                     Если (Текущий Символ не равен Символу) продолжить; Так? Или как?
 

Rewerpool :

그리고 그것을 읽는 방법? (주문이 선택되지 않은 경우) 계속하십시오.

(현재 기호가 기호와 같지 않은 경우) 계속하십시오. 그래서? 또는 어떻게?

계속 문

 

@Konstantin Nikitin 이해, 이것이 의미하는 바가 있다면 수정해 주세요!

 if (! OrderSelect (i, SELECT_BY_POS )) continue ;
Если (Ордер не выбран ордер) начать цикл снова; //(Вернутся в начало функции)
if ( OrderSymbol ()!= Symbol ()) continue ;
Если (ОрдерСимвола не равен текущему Графику)начать цикл снова; //(Вернутся в начало функции)


여기에 또 다른 질문이 있습니다. !OrderSelect - 이것은 다음을 의미합니까? 주문이 없거나 선택되지 않았습니까?

 
Rewerpool :

이해, 다음을 의미합니다: 맞다, 그렇다면!

순서가 선택되지 않은 경우 주기의 다음 요소가 선택됩니다.

여기에 또 다른 질문이 있습니다. !OrderSelect - 이것은 다음을 의미합니까? 주문이 없거나 선택되지 않았습니까?

연산과 표현식 , 거기에서 우리는 논리 연산 을 봅니다.

 
@Konstantin Nikitin 다음과 같이 컴파일됩니다 .
 void STOP_TAKE()
   int tip,Ticket;
   double OOP,OSL,OTP;
   int SPREAD    = ( int ) MarketInfo ( Symbol (), MODE_SPREAD );
   if (stoploss<STOPLEVEL) stoploss= 0 ; 
   if (takeprofit<STOPLEVEL) takeprofit= 0 ; 

for ( int i= 0 ; i< OrdersTotal (); i++)
{
     if (! OrderSelect (i, SELECT_BY_POS , MODE_TRADES )) continue ;
     if ( OrderSymbol ()!= Symbol ()) continue ;
     
     int tip = OrderType ();
     if (tip!= OP_BUY && tip!= OP_BUYSTOP && tip!= OP_BUYLIMIT ) continue ;
     
     // переменные которые будут использоваться в любых ордерах
     int Ticket = OrderTicket ();
     double OOP = OrderOpenPrice ();
     
     //---
     switch ( OrderMagicNumber () )
     {
           case Magic:     //----------Если Ордера Советника
               {
                 if (tip< 2 )
           {
            OSL = OrderStopLoss ();
            OTP = OrderTakeProfit ();
             if ((OSL== 0 &&stoploss!= 0 )||(OTP== 0 &&takeprofit!= 0 ))
            {  
               if (tip== OP_BUY || tip== OP_BUYSTOP || tip== OP_BUYLIMIT )             
               {
                   if (takeprofit!= 0 ) TP = NormalizeDouble (OOP + takeprofit* Point , Digits ); else TP=OTP;
                   if (stoploss!= 0 )   SL = NormalizeDouble (OOP - (stoploss+SPREAD)* Point , Digits ); else SL=OSL;       
                   if ( OrderModify (Ticket,OOP,SL,TP, 0 ,White)) Print ( "STOP_TAKE" ,Ticket, " SL " ,OSL, " -> " ,SL, "   TP " ,OTP, " -> " ,TP);
                   else Print ( Symbol (), " Error STOP_TAKE" , GetLastError (), "  Ticket " ,Ticket);
               }                                         
               if (tip== OP_SELL || tip== OP_SELLSTOP || tip== OP_SELLLIMIT )        
               {
                   if (takeprofit!= 0 ) TP = NormalizeDouble (OOP - takeprofit* Point , Digits ); else TP=OTP;
                   if (stoploss!= 0 )   SL = NormalizeDouble (OOP + (stoploss+SPREAD)* Point , Digits ); else SL=OSL;             
                   if ( OrderModify (Ticket,OOP,SL,TP, 0 ,White)) Print ( "STOP_TAKE" ,Ticket, " SL " ,OSL, " -> " ,SL, "   TP " ,OTP, " -> " ,TP);
                   else Print ( Symbol (), " Error STOP_TAKE" , GetLastError (), "  Ticket " ,Ticket);
               } 
            }
         }
               }
               break ;

           default :       //----------Если Ордера Оператора 
               {
                 {
                 if (tip< 2 )
           {
            OSL = OrderStopLoss ();
            OTP = OrderTakeProfit ();
             if ((OSL== 0 &&stoploss!= 0 )||(OTP== 0 &&takeprofit!= 0 ))
            {  
               if (tip== OP_BUY || tip== OP_BUYSTOP || tip== OP_BUYLIMIT )             
               {
                   if (takeprofit!= 0 ) TP = NormalizeDouble (OOP + takeprofit* Point , Digits ); else TP=OTP;
                   if (stoploss!= 0 )   SL = NormalizeDouble (OOP - (stoploss+SPREAD)* Point , Digits ); else SL=OSL;       
                   if ( OrderModify (Ticket,OOP,SL,TP, 0 ,White)) Print ( "STOP_TAKE" ,Ticket, " SL " ,OSL, " -> " ,SL, "   TP " ,OTP, " -> " ,TP);
                   else Print ( Symbol (), " Error STOP_TAKE" , GetLastError (), "  Ticket " ,Ticket);
               }                                         
               if (tip== OP_SELL || tip== OP_SELLSTOP || tip== OP_SELLLIMIT )        
               {
                   if (takeprofit!= 0 ) TP = NormalizeDouble (OOP - takeprofit* Point , Digits ); else TP=OTP;
                   if (stoploss!= 0 )   SL = NormalizeDouble (OOP + (stoploss+SPREAD)* Point , Digits ); else SL=OSL;             
                   if ( OrderModify (Ticket,OOP,SL,TP, 0 ,White)) Print ( "STOP_TAKE" ,Ticket, " SL " ,OSL, " -> " ,SL, "   TP " ,OTP, " -> " ,TP);
                   else Print ( Symbol (), " Error STOP_TAKE" , GetLastError (), "  Ticket " ,Ticket);
               } 
            }
         }
               }
               }
     }
}
바르게?
 

다음과 같이 더 추가했습니다.


6

 

왜 그런 식으로 글을 쓰는 걸까요?

 if (! OrderSelect (i, SELECT_BY_POS , MODE_TRADES )) continue ;
     if ( OrderSymbol ()!= Symbol ()) continue ;

고문을 하나의 기호에만 적용하면 모든 기호에 적용됩니까? 그리고 마술사는 자신의 것을 보게 될 것입니다!

완전히 혼란스러워!

 

구현 방법을 알고 있는 친구: 조언자는 지표 의 절대값 을 얻을 수 있습니다(예: iStohastic()). 그리고 지표가 과매수 또는 과매도 영역을 벗어 났는지 확인하는 방법은 무엇입니까?

시각적으로, 예를 들어 레벨 80 및 20의 확률적 지표로.

 

Rewerpool : 글쎄, 그것은 오류가없는 것처럼 보입니다.

 void STOP_TAKE( void )
{
   int SPREAD    = ( int ) MarketInfo ( Symbol (), MODE_SPREAD );
   if (stoploss<STOPLEVEL) stoploss= 0 ; 
   if (takeprofit<STOPLEVEL) takeprofit= 0 ;

     for ( int i= 0 ; i< OrdersTotal (); i++)
     {
           if (! OrderSelect (i, SELECT_BY_POS , MODE_TRADES )) continue ;
           if ( OrderSymbol ()!= Symbol ()) continue ;
     
           int tip = OrderType ();
           if (  tip!= OP_BUY && tip!= OP_BUYSTOP && tip!= OP_BUYLIMIT &&
               tip!= OP_SELL && tip!= OP_SELLSTOP && tip!= OP_SELLLIMIT ) continue ;
     
           // переменные которые будут использоваться в любых ордерах
           int Ticket = OrderTicket ();
           double     OOP = OrderOpenPrice (),
                    OSL = OrderStopLoss (),
                    OTP = OrderTakeProfit ();
     
           //---
           if ( OrderMagicNumber () == Magic )
          { //----------Если Ордера Советника
               switch (tip)
               {
                     case OP_BUY :
                     case OP_BUYSTOP :
                     case OP_BUYLIMIT :
                         {
                               if (takeprofit!= 0 ) TP = NormalizeDouble (OOP + takeprofit* Point , Digits ); else TP=OTP;
                               if (stoploss!= 0 )   SL = NormalizeDouble (OOP - (stoploss+SPREAD)* Point , Digits ); else SL=OSL;
                               if ( OrderModify (Ticket,OOP,SL,TP, 0 ,White)) Print ( "STOP_TAKE" ,Ticket, " SL " ,OSL, " -> " ,SL, "   TP " ,OTP, " -> " ,TP);
                               else Print ( Symbol (), " Error STOP_TAKE" , GetLastError (), "  Ticket " ,Ticket);
                         }
                         break ;
                         // end case
                         
                    default :
                         {
                               if (takeprofit!= 0 ) TP = NormalizeDouble (OOP - takeprofit* Point , Digits ); else TP=OTP;
                               if (stoploss!= 0 )   SL = NormalizeDouble (OOP + (stoploss+SPREAD)* Point , Digits ); else SL=OSL;             
                               if ( OrderModify (Ticket,OOP,SL,TP, 0 ,White)) Print ( "STOP_TAKE" ,Ticket, " SL " ,OSL, " -> " ,SL, "   TP " ,OTP, " -> " ,TP);
                               else Print ( Symbol (), " Error STOP_TAKE" , GetLastError (), "  Ticket " ,Ticket);
                         } // end case
               } // end switch

          }
           else
          { //----------Если Ордера Оператора
               switch (tip)
               {
                     case OP_BUY :
                     case OP_BUYSTOP :
                     case OP_BUYLIMIT :
                         {
                               if (takeprofit!= 0 ) TP = NormalizeDouble (OOP + takeprofit* Point , Digits ); else TP=OTP;
                               if (stoploss!= 0 )   SL = NormalizeDouble (OOP - (stoploss+SPREAD)* Point , Digits ); else SL=OSL;       
                               if ( OrderModify (Ticket,OOP,SL,TP, 0 ,White)) Print ( "STOP_TAKE" ,Ticket, " SL " ,OSL, " -> " ,SL, "   TP " ,OTP, " -> " ,TP);
                               else Print ( Symbol (), " Error STOP_TAKE" , GetLastError (), "  Ticket " ,Ticket);
                         }
                         break ;
                         // end case
                         
                    default :
                         {
                               if (takeprofit!= 0 ) TP = NormalizeDouble (OOP - takeprofit* Point , Digits ); else TP=OTP;
                               if (stoploss!= 0 )   SL = NormalizeDouble (OOP + (stoploss+SPREAD)* Point , Digits ); else SL=OSL;             
                               if ( OrderModify (Ticket,OOP,SL,TP, 0 ,White)) Print ( "STOP_TAKE" ,Ticket, " SL " ,OSL, " -> " ,SL, "   TP " ,OTP, " -> " ,TP);
                               else Print ( Symbol (), " Error STOP_TAKE" , GetLastError (), "  Ticket " ,Ticket);
                         } // end case
               } // end switch
          } // end if
     } // end for
} // end STOP_TAKE
고문과 다른 사람들의 주문을 수정할 때 정확히 같은 논리를 가지고 있지만. 그것들을 구별해야 하는 이유는 완전히 명확하지 않습니다. 하지만 원칙 자체가 도움이 될 것이라고 생각합니다.
 
@Konstantin Nikitin 우리는 그것을 사랑합니다!! 공유해주셔서 감사합니다!!!