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

 
Zalevsky1234 :

안녕하세요.

말해봐, 고문의 매개 변수에 의견이나 설명이있는 열을 추가 할 수 있습니까... ???

고맙습니다.

네, 하지만 소스가 필요합니다
 
MakarFX :
네, 하지만 소스가 필요합니다
필수는 아니지만...

   input int i = 5 ;            
   input bool b = false ;    
 
void OnTick ()
  {
   if (i != 0 ) 
         {
             Comment ( "123" );
         }
  }
 
Mihail Matkovskij :

고맙습니다! MQL에 이에 대한 기능이 있다는 것을 몰랐습니다. 나는 이미 나만의 것을 만들고 싶었다. 그러나 그 전에 포럼에 질문 하기로 결정했습니다.

이것은 언어 학습에 대한 잘못된 접근의 결과입니다. 문서 작업을 하고 있었고 g.codes from……… 리소스 도움말을 읽고 있다면 분명히 읽을 것입니다. 그리고 물어볼 필요도 없었다.
 
Zalevsky1234 :

안녕하세요.

말해봐, 고문의 매개 변수에 의견이나 설명이있는 열을 추가 할 수 있습니까... ???

고맙습니다.

언제 문서 를 읽는 법을 배우게 됩니까?

 //--- input parameters
input int             InpMAPeriod= 13 ;         // Smoothing period
input int             InpMAShift= 0 ;           // Line horizontal shift
input ENUM_MA_METHOD InpMAMethod= MODE_SMMA ;   // Smoothing method 

Input переменные - Переменные - Основы языка - Справочник MQL4
Input переменные - Переменные - Основы языка - Справочник MQL4
  • docs.mql4.com
Input переменные - Переменные - Основы языка - Справочник MQL4
 
나는 이 일을 했을 때 계약을 따랐을 때   이익을 취하다   는 500이고 손절매는 150입니다.
최대 5개의 추가 계약을 구매하세요.
2개의 포지션이 이미 열렸을 때 새로운 포지션의 개설을 금지할 수 있습니까? 오픈 포지션의 양을 제한하십시오.



 //--------------------------------------------------------------------

void OPENORDER( string ord)

  {
  
   double priceL=m_symbol.Ask();
   if (ord== "Sell" )      
         //--- check for free money
             if (m_account.FreeMarginCheck( Symbol (), ORDER_TYPE_BUY ,my_lot,priceL)< 0.0 )
               printf ( "We have no money. Free Margin = %f" ,m_account.FreeMargin());
             else
       if (!m_trade.Sell(my_lot, Symbol (),m_symbol.Bid(),my_SL,my_TP, "" ))
         Print ( "BUY_STOP -> false. Result Retcode: " ,m_trade.ResultRetcode(),
               ", description of Retcode: " ,m_trade.ResultRetcodeDescription(),
               ", ticket of order: " ,m_trade.ResultOrder());                     // Если sell, то не открываемся
     double priceS=m_symbol.Bid();
   if (ord== "Buy" )
         //--- check for free money
             if (m_account.FreeMarginCheck( Symbol (), ORDER_TYPE_SELL ,my_lot,priceS)< 0.0 )
               printf ( "We have no money. Free Margin = %f" ,m_account.FreeMargin());
             else
       if (!m_trade.Buy(my_lot, Symbol (),m_symbol.Ask(),my_SL,my_TP, "" ))
 
         Print ( "Buy -> false. Result Retcode: " ,m_trade.ResultRetcode(),
               ", description of result: " ,m_trade.ResultRetcodeDescription(),
               ", ticket of deal: " ,m_trade.ResultDeal());
   return ;
 }
   double iMAGet( const int handle, const int index)
  {
   double MA[];
   ArraySetAsSeries (MA, true );
//--- reset error code
   ResetLastError ();
//--- fill a part of the iMABuffer array with values from the indicator buffer that has 0 index
   if ( CopyBuffer (handle, 0 , 0 ,index+ 1 ,MA)< 0 )
     {
       //--- if the copying fails, tell the error code
       PrintFormat ( "Failed to copy data from the iMA indicator, error code %d" , GetLastError ());
       //--- quit with zero result - it means that the indicator is considered as not calculated
       return ( 0.0 );
     }
   return (MA[index]);
  }
//+------------------------------------------------------------------+
//| Refreshes the symbol quotes data                                 |
//+------------------------------------------------------------------+
bool RefreshRates()
  {
//--- refresh rates
   if (!m_symbol.RefreshRates())
       return ( false );
//--- protection against the return value of "zero"
   if (m_symbol.Ask()== 0 || m_symbol.Bid()== 0 )
       return ( false );
//---
   return ( true );
  }
//+------------------------------------------------------------------+
//| Get Time for specified bar index                                 |
//+------------------------------------------------------------------+
datetime iTime ( const int index, string symbol= NULL , ENUM_TIMEFRAMES timeframe= PERIOD_CURRENT )
  {
   if (symbol== NULL )
      symbol= Symbol ();
   if (timeframe== 0 )
      timeframe= Period ();
   datetime Time[];
   datetime time= 0 ;
   ArraySetAsSeries (Time, true );
   int copied= CopyTime (symbol,timeframe,index, 1 ,Time);
   if (copied> 0 )
      time=Time[ 0 ];
   return (time);
  }
//+------------------------------------------------------------------+
//| Get value of buffers                                             |
//+------------------------------------------------------------------+
bool iGetArray( const int handle, const int buffer, const int start_pos,
               const int count, double &arr_buffer[])
  {
   bool result= true ;
   if (! ArrayIsDynamic (arr_buffer))
     {
       PrintFormat ( "ERROR! EA: %s, FUNCTION: %s, this a no dynamic array!" , __FILE__ , __FUNCTION__ );
       return ( false );
     }
   ArrayFree (arr_buffer);
//--- reset error code
   ResetLastError ();
//--- fill a part of the iBands array with values from the indicator buffer
   int copied= CopyBuffer (handle,buffer,start_pos,count,arr_buffer);
   if (copied!=count)
     {
       //--- if the copying fails, tell the error code
       PrintFormat ( "ERROR! EA: %s, FUNCTION: %s, amount to copy: %d, copied: %d, error code %d" ,
                   __FILE__ , __FUNCTION__ ,count,copied, GetLastError ());
       //--- quit with zero result - it means that the indicator is considered as not calculated
       return ( false );
     }
   return (result);
 
 
}
void TrailingOrder()
  {

   if (InpTrailingOrderLimit== 0 )
       return ;
   for ( int i= PositionsTotal ()- 1 ;i>= 0 ;i--) // returns the number of open positions
       if (m_position.SelectByIndex(i))
         if (m_position. Symbol ()==m_symbol.Name() && m_position.Magic()==m_magic)
           {
             if (m_position.PositionType()== POSITION_TYPE_BUY )
              {
               if (m_position.PriceCurrent()-m_position.PriceOpen()>ExtTrailingOrderLimit+ExtTrailingOrderStep)
                   if (m_position.StopLoss()<m_position.PriceCurrent()-(ExtTrailingOrderLimit+ExtTrailingOrderStep))
                    {
                     if (!m_trade.PositionModify(m_position.Ticket(),
                     
                        m_symbol.NormalizePrice(m_position.PriceCurrent()-ExtTrailingOrderLimit),
                        m_position.TakeProfit()))
                         Print ( "Modify " ,m_position.Ticket());
                        OPENORDER( "Buy" );
                    }
              }
             else
              {
               if (m_position.PriceOpen()-m_position.PriceCurrent()>ExtTrailingOrderLimit+ExtTrailingOrderStep)
                   if ((m_position.StopLoss()>(m_position.PriceCurrent()+(ExtTrailingOrderLimit+ExtTrailingOrderStep))) ||
                     (m_position.StopLoss()== 0 ))
                    {
                     if (!m_trade.PositionModify(m_position.Ticket(),
                        m_symbol.NormalizePrice(m_position.PriceCurrent()+ExtTrailingOrderLimit),
                        m_position.TakeProfit()))
                         Print ( "Modify " ,m_position.Ticket());
                        OPENORDER( "Sell" );
                   }
              }
           }
    }      
 void Trailing()
  {
   if (InpTStop== 0 )
       return ;
         if (m_position. Symbol ()==m_symbol.Name() && m_position.Magic()==m_magic)
           {
             if (m_position.PositionType()== POSITION_TYPE_BUY )
              {
               if (m_position.PriceCurrent()-m_position.PriceOpen()>ExtTStop+ExtTStep)
                   if (m_position.StopLoss()<m_position.PriceCurrent()-(ExtTStop+ExtTStep))
                    {
                     if (!m_trade.PositionModify(m_position.Ticket(),
                        m_symbol.NormalizePrice(m_position.PriceCurrent()-ExtTStepShift),
                        m_position.TakeProfit()))
                         Print ( "Modify " ,m_position.Ticket(),
                               " Position -> false. Result Retcode: " ,m_trade.ResultRetcode(),
                               ", description of result: " ,m_trade.ResultRetcodeDescription());
                    }
              }
             else
              {
               if (m_position.PriceOpen()-m_position.PriceCurrent()>ExtTStop+ExtTStep)
                   if ((m_position.StopLoss()>(m_position.PriceCurrent()+(ExtTStop+ExtTStep))) ||
                     (m_position.StopLoss()== 0 ))
                    {
                     if (!m_trade.PositionModify(m_position.Ticket(),
                        m_symbol.NormalizePrice(m_position.PriceCurrent()+ExtTStepShift),
                        m_position.TakeProfit()))
                         Print ( "Modify " ,m_position.Ticket(),
                               " Position -> false. Result Retcode: " ,m_trade.ResultRetcode(),
                               ", description of result: " ,m_trade.ResultRetcodeDescription());
                   }
              }
         }
   }
 
Alexey Viktorov :
이것은 언어 학습에 대한 잘못된 접근의 결과입니다. 문서 작업을 하고 있었고 g.codes from……… 리소스 도움말을 읽고 있다면 분명히 읽을 것입니다. 그리고 당신은 물을 필요가 없습니다.

나는 내 대답 후에 도덕화가 시작될 것이라는 것을 알고 있었습니다... 제 레퍼토리에서... 저는 일종의 "고마워요"라고 말했지만, 아니요... 그런 것을 쓸 필요가 있습니다... 그들은 에서 기능을 알고 있었습니다 문서화 - 잘했습니다! 그러나 코드를 제대로 모른다면 최소한 MQL 문서의 길이와 폭을 연구해야 합니다. 실제로는 이점이 최소화됩니다!...

 

이 버그를 우연히 발견했습니다.

좌표에 약간의 차이가 있는 두 개의 동일한 버튼 생성

   CreateButton( 0 , "lab_Button1" , 0 , 79 , 20 , 77 , 25 , CORNER_RIGHT_UPPER , " " , "START" , "Arial Black" , 10 , clrWhite , clrGreen ,
   BORDER_SUNKEN , false , false , false , false , false , 0 );
   CreateButton( 0 , "lab_Button2" , 0 , 4 , 50 , - 73 , 25 , CORNER_RIGHT_UPPER , " " , "START" , "Arial Black" , 10 , clrWhite , clrGreen ,
   BORDER_SUNKEN , false , false , false , false , false , 0 );

이렇게 생겼어


결과적으로 첫 번째 버튼만 OnChartEvent 에 반응하고 두 번째 버튼은 반응하지 않습니다.

 
Eugen8519 :
나는 이 일을 했을 때 계약을 따랐을 때   이익을 취하다   는 500이고 손절매는 150입니다.
최대 5개의 추가 계약을 구매하세요.
2개의 포지션이 이미 열렸을 때 새로운 포지션의 개설을 금지할 수 있습니까? 오픈 포지션의 양을 제한하십시오.

MQL5는 모르지만 제 생각에는

 void TrailingOrder()
  {

   if (InpTrailingOrderLimit== 0 || PositionsTotal ()>= 2 )
       return ;
   for ( int i= PositionsTotal ()- 1 ;i>= 0 ;i--) // returns the number of open positions
       if (m_position.SelectByIndex(i))
         if (m_position. Symbol ()==m_symbol.Name() && m_position.Magic()==m_magic)
           {
             if (m_position.PositionType()== POSITION_TYPE_BUY )
              {
               if (m_position.PriceCurrent()-m_position.PriceOpen()>ExtTrailingOrderLimit+ExtTrailingOrderStep)
                   if (m_position.StopLoss()<m_position.PriceCurrent()-(ExtTrailingOrderLimit+ExtTrailingOrderStep))
                    {
                     if (!m_trade.PositionModify(m_position.Ticket(),
                     
                        m_symbol.NormalizePrice(m_position.PriceCurrent()-ExtTrailingOrderLimit),
                        m_position.TakeProfit()))
                         Print ( "Modify " ,m_position.Ticket());
                        OPENORDER( "Buy" );
                    }
              }
             else
              {
               if (m_position.PriceOpen()-m_position.PriceCurrent()>ExtTrailingOrderLimit+ExtTrailingOrderStep)
                   if ((m_position.StopLoss()>(m_position.PriceCurrent()+(ExtTrailingOrderLimit+ExtTrailingOrderStep))) ||
                     (m_position.StopLoss()== 0 ))
                    {
                     if (!m_trade.PositionModify(m_position.Ticket(),
                        m_symbol.NormalizePrice(m_position.PriceCurrent()+ExtTrailingOrderLimit),
                        m_position.TakeProfit()))
                         Print ( "Modify " ,m_position.Ticket());
                        OPENORDER( "Sell" );
                   }
              }
           }
    }      
 
MakarFX :

이 버그를 우연히 발견했습니다.

좌표에 약간의 차이가 있는 두 개의 동일한 버튼 생성

이렇게 생겼어


결과적으로 첫 번째 버튼만 OnChartEvent 에 반응하고 두 번째 버튼은 반응하지 않습니다.

핸들러에서 코드를 볼 수 있습니까?

그리고 매개변수에 -73이 있는 이유는 명확하지 않습니까?...

 
Mihail Matkovskij :

핸들러에서 코드를 볼 수 있습니까?

그리고 매개변수에 -73이 있는 이유는 명확하지 않습니까?...

오류가 발생하지 않습니다.

이러한 좌표를 사용하면 버튼이 거꾸로 나옵니다. 버튼 길이는 점 X에서 +/-로 계산됩니다.