초보자의 질문 MQL5 MT5 MetaTrader 5 - 페이지 1390

 
-IMXO- # :
제발, 어떻게? "SB"란 무엇입니까?

SB는 표준 라이브러리입니다.

예를 들어 다음과 같이

   int k = 0 ;
   do
   {
    calc_Margin = OrderCalcMargin (orderType, _Symbol , lots, price, margin);
     Sleep ( 50 );
    k++;
   }
   while (margin <= 0 && k < 7 && ! IsStopped ());

변수가 다른 곳에 설정되어 있는 점 이해해 주시길 바랍니다...

 
Vladimir Karputov # :

귀하의 질문은 혼란스럽습니다. 터미널과 함께 제공되는 예제에서 버튼이 어떻게 작동하는지 확인하십시오: MQL5\Experts\Examples\Controls\Controls.mq5


블라디미르님, 감사합니다.

그러나 이 예에서 버튼은 표준 라이브러리에서 가져온 것입니다. OBJ_BUTTON 이 아닙니다 .

 
Alexey Viktorov # :

SB는 표준 라이브러리입니다.

예를 들어 다음과 같이

변수가 다른 곳에 설정되어 있는 점 이해해 주시길 바랍니다...

감사합니다. 이해하려고 노력하겠습니다.
 

문제는 다음과 같습니다. 예를 들어, 한 차트에서 다른 매개변수(예: 기간 및 색상)를 사용하여 동일한 표시기( 이동 평균 )의 복사본 3개를 던졌습니다. 차트에서 Ctrl+I를 누르면 설치된 표시기 목록이 호출되고 목록의 모든 "움직임"이 동일하게 보입니다. 3에서 올바른 것을 선택할 확률은 낮습니다. 그리고 이 이름(즉, 표시기 창의 목록용)에 지정된 "식별기"를 추가하도록 프로그래밍(표시기 자체 작성)할 수 있습니까? 저것들. "움직이는" 예의 경우 설치된 표시기 목록에서 다음과 같은 항목을 보고 싶습니다.
이동 평균 - 10 이동 평균 - 20 이동 평균 - 50

여기서 이름의 숫자는 기간을 결정합니다.

MQL5 언어에 그러한 가능성이 있습니까?

 
Alexandr Gershkevich # :

문제는 다음과 같습니다. 예를 들어, 한 차트에서 다른 매개변수(예: 기간 및 색상)를 사용하여 동일한 표시기( 이동 평균 )의 복사본 3개를 던졌습니다. 차트에서 Ctrl+I를 누르면 설치된 표시기 목록이 호출되고 목록의 모든 "움직임"이 동일하게 보입니다. 3에서 올바른 것을 선택할 확률은 낮습니다. 그리고 이 이름(즉, 표시기 창의 목록용)에 지정된 "식별기"를 추가하도록 프로그래밍(표시기 자체 작성)할 수 있습니까? 저것들. "움직이는" 예의 경우 설치된 표시기 목록에서 다음과 같은 항목을 보고 싶습니다.
이동 평균 - 10 이동 평균 - 20 이동 평균 - 50

여기서 이름의 숫자는 기간을 결정합니다.

MQL5 언어에 그러한 가능성이 있습니까?

물론 당신은 할 수. 예는 iMA 설명서를 참조하십시오.

코드를 붙여넣습니다 ( PlotIndexSetString 및 PLOT_LABEL 사용

식별자

설명

속성 유형

PLOT_LABEL

DataWindow에 표시할 표시기 그래픽 시리즈의 이름. 여러 표시기 버퍼를 표시해야 하는 복잡한 그래픽 스타일의 경우 ";"를 사용하여 각 버퍼의 이름을 지정할 수 있습니다. 구분자로. 코드 예제는 다음과 같습니다.   DRAW_CANDLES

)

 //--- show the symbol/timeframe the Moving Average indicator is calculated for
   short_name= StringFormat ( "iMA(%s/%s, %d, %d, %s, %s)" ,name, EnumToString (period),
                           ma_period, ma_shift, EnumToString (ma_method), EnumToString (applied_price));
   IndicatorSetString ( INDICATOR_SHORTNAME ,short_name);
   string plot_label= StringFormat ( "iMA(%d, %d, %s, %s)" ,
                                  ma_period, ma_shift, StringSubstr ( EnumToString (ma_method), 5 ,- 1 ), StringSubstr ( EnumToString (applied_price), 6 ,- 1 ));
   PlotIndexSetString ( 0 , PLOT_LABEL ,plot_label);
//--- normal initialization of the indicator
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |                              |

결과는 다음과 같습니다.

파일:
iMA.mq5  19 kb
 

데이터 창에서 표시기의 차이가 이미 표시됩니다.

질문은 지표 목록에 관한 것이었습니다.


 

여보세요

코드 도와주세요

만든 지표

테스터에서 잘 작동합니다

그래프에 넣어 잘못된 표시

나는 이유를 알 수 없다

 //+------------------------------------------------------------------+
//|                                                        Oscil.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link        " https://www.mql5.com "
#property version    "1.00"
#property indicator_separate_window
#property   indicator_buffers 5
#property indicator_plots    5

#property   indicator_color1    clrNONE
#property   indicator_color2    clrRoyalBlue
#property   indicator_color3    clrPink
#property   indicator_color4    clrAqua
#property   indicator_color5    clrYellow

#property   indicator_width1 1
#property   indicator_width2 5
#property   indicator_width3 5
#property   indicator_width4 5
#property   indicator_width5 5

double MainLine[];
double UpLine[];
double DnLine[];
double muls[];
double x,y,z;
double price;
double mulSum= 0 ;
double Pi   = 3.1415926535 ;
bool LastUp = false ;
bool GoUp   = false ;
input bool otl    = false ;
/***********Range***************/
int     Length             = 3 ;
int     MajorRangeStrength = 4 ;


double MajorRangeBuy[];
double MajorRangeSell[];


double RangePrice  = 0.0 ,
       SweepB      = 0.0 ;
int     Switch2     = 0 ,
         SwitchB     = 0 ;
double Price2BuyA  = 0.0 ;
int     Price2BuyB  = 1.0 ;
double Price2SellA = 0.0 ;
int     Price2SellB = 0.0 ;
bool    BuySwitchB  = false ,
       SellSwitchB = false ;
       
int hendlMA_1;
double MA_1[];

int hendlMA_2;
double MA_2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
//--- indicator buffers mapping
   SetIndexBuffer ( 0 ,MainLine, INDICATOR_DATA );
   PlotIndexSetDouble ( 0 , PLOT_EMPTY_VALUE , 0 );
   PlotIndexSetInteger ( 0 , PLOT_DRAW_TYPE , DRAW_HISTOGRAM ); 
   ArraySetAsSeries (MainLine, true );
   
   SetIndexBuffer ( 1 ,UpLine, INDICATOR_DATA );
   PlotIndexSetDouble ( 1 , PLOT_EMPTY_VALUE , 0 );
   PlotIndexSetInteger ( 1 , PLOT_DRAW_TYPE , DRAW_HISTOGRAM ); 
   ArraySetAsSeries (UpLine, true );
   
   SetIndexBuffer ( 2 ,DnLine, INDICATOR_DATA );
   PlotIndexSetDouble ( 2 , PLOT_EMPTY_VALUE , 0 );
   PlotIndexSetInteger ( 2 , PLOT_DRAW_TYPE , DRAW_HISTOGRAM ); 
   ArraySetAsSeries (DnLine, true );
   
   SetIndexBuffer ( 3 ,MajorRangeBuy, INDICATOR_DATA );
   PlotIndexSetDouble ( 3 , PLOT_EMPTY_VALUE , 0 );
   PlotIndexSetInteger ( 3 , PLOT_DRAW_TYPE , DRAW_HISTOGRAM ); 
   ArraySetAsSeries (MajorRangeBuy, true );
   
   SetIndexBuffer ( 4 ,MajorRangeSell, INDICATOR_DATA );
   PlotIndexSetDouble ( 4 , PLOT_EMPTY_VALUE , 0 );
   PlotIndexSetInteger ( 4 , PLOT_DRAW_TYPE , DRAW_HISTOGRAM ); 
   ArraySetAsSeries (MajorRangeSell, true );
   
   hendlMA_1= iMA ( Symbol (), 0 , 1 , 0 , MODE_LWMA , PRICE_CLOSE );
   ArraySetAsSeries (MA_1, true );
   
   hendlMA_2= iMA ( Symbol (), 0 , 1 , 0 , MODE_SMMA , PRICE_CLOSE );
   ArraySetAsSeries (MA_2, true );
   
   ArrayResize (muls, 99 );
   
   mulSum = 0 ;
   
   for ( int i0 = 0 ; i0 < 98 ; i0++) { //повторяем в цикле 98 раз
       if (i0 <= 18 ) y = 1.0 * i0 / 18 ; //если это первые 18 повторений
       else y = (i0 - 18 ) * 7.0 / 79.0 + 1.0 ; //иначе
      
      x = MathCos (Pi * y);
      z = 1.0 / ( 3.0 * Pi * y + 1.0 );
       if (y <= 0.5 ) z = 1 ;
      
      muls[i0] = z * x;
      mulSum += muls[i0];
   }
   if (otl) Print ( " Распределение создано muls[20]=" ,muls[ 20 ]);
//---
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
  {
//---
   if ( PeriodSeconds () < 60 * 60 || PeriodSeconds () > 10080 * 60 ) return ( 0 );
   int depth= 0 ;

   int l_ind_counted_8 = prev_calculated; //Возвращает количество баров, не измененных после последнего вызова индикатора.
   
   int bars= Bars ( Symbol (), PERIOD_CURRENT );
   if (l_ind_counted_8 < 0 ) return ( 0 );
   if (l_ind_counted_8 == 0 )
      {
         depth = bars - 98 ;
         for ( int a= 0 ;a<bars;a++)
            {
               MainLine[a] = 0 ;
               UpLine[a] = 0 ;
               DnLine[a] = 0 ;
               MajorRangeBuy[a]= 0 ;
               MajorRangeSell[a]= 0 ;
            }
      }
   if (l_ind_counted_8 > 0 )  depth = bars - l_ind_counted_8;
   if (otl) Print ( " количество баров, не измененных после последнего вызова индикатора= " ,l_ind_counted_8, "  Количество баров на текущем графике Bars=" ,bars, "  depth= " ,depth);
   if (l_ind_counted_8 < 1 ) {
       for ( int i2 = 1 ; i2 < 100 ; i2++) {
         MainLine[bars - i2] = 0 ;
         UpLine[bars - i2] = 0 ;
         DnLine[bars - i2] = 0 ;
      }
   }
   
   for ( int i1 = depth; i1 >= 0 ; i1--) 
   {
      price = 0 ;
          
           CopyBuffer (hendlMA_1, 0 , 0 ,bars,MA_1);
          
       for ( int i2 = 0 ; i2 <= 98 ; i2++) 
         {
             if (i2 + i1>=bars) break ;
            price += muls[i2] * MA_1[i2 + i1];
         }
          
       if (mulSum > 0.0 ) MainLine[i1] = price / mulSum;

     GoUp=MainLine[i1 + 1 ] > MainLine[i1] ;
     
       if (GoUp) 
      {
         if (!LastUp) DnLine[i1+ 1 ] = MainLine[i1+ 1 ];
         DnLine[i1] = MainLine[i1];
         UpLine[i1] = 0 ;
      }
         else
      {
         if (LastUp) UpLine[i1+ 1 ] = MainLine[i1+ 1 ];
         UpLine[i1] = MainLine[i1];
         DnLine[i1] = 0 ;
      }
      LastUp=GoUp; 

   } //  for (int i1

 //  return (0);

/***************** Range **********************/

   int counted_bars=prev_calculated;
   if (otl) Print ( " Range counted_bars = " , counted_bars);
   if (counted_bars< 0 ) return (- 1 );
   int position=bars-counted_bars;
   if (position< 0 ) position= 0 ;
   if (position== 0 ) position= 1 ;
   int rnglength = 250 ;
   double range = 0.0 , srange = 0.0 ;
   if (otl) Print ( " position=" ,position);
   
   for ( int pos = position; pos >= 0 ; pos--)
   { /***************** MAIN Range **********************/
      srange = 0.0 ;
       int j = 0 ;
       for ( int i= 0 ;i<rnglength;i++)
      {
         j++;
         int posr = pos + i;
         if (posr >= bars) break ; 
         srange = srange + (High(posr) - Low(posr));
      }
      range = srange / j * Length;
       int BarNumber = bars-pos; //??????????
       if (BarNumber < 0 )  BarNumber = 0 ;
          
           CopyBuffer (hendlMA_2, 0 , 0 ,bars,MA_2);
           //Print(bars," - ",pos);
       if (pos<bars)RangePrice = MA_2[pos];   //Moving Average MODE_SMMA
       else RangePrice = MA_2[pos- 1 ];

       if (BarNumber == 1 )
      {
         SweepB  = range *  MajorRangeStrength;
         Price2BuyA = RangePrice;
         Price2SellA = RangePrice;
      }     

       if (BarNumber > 1 )
      {

         if (Switch2  >  - 1 ) //проверка цикла на покупку
         {
             if (RangePrice < Price2BuyA) //если средняя цена ниже
            {
if (BuySwitchB ) MajorRangeBuy [pos +BarNumber - Price2BuyB] = 0 ;                                                                 //OUT
                           Price2BuyA = RangePrice;
               Price2BuyB = BarNumber;
               BuySwitchB = true ;
            } 
             else if (RangePrice > Price2BuyA)
            {
                            SwitchB = BarNumber - Price2BuyB;
MajorRangeBuy [pos +SwitchB] = MainLine[pos + SwitchB]* 1.0005 ;                                                                                                                           //OUT
                BuySwitchB = true ;

                               if (RangePrice - MA_2[pos + SwitchB] >= SweepB && SwitchB >= 1 )
                              {
                     Switch2 =  - 1 ;
                     Price2SellA = RangePrice;
                     Price2SellB = BarNumber;
                     SellSwitchB = false ;
                     BuySwitchB = false ;
               }
            }
         }
         if (Switch2  < 1 ) //проверка цикла на продажу
         {
             if (RangePrice  > Price2SellA )
            {
if (pos +BarNumber - Price2SellB<bars&&SellSwitchB ) MajorRangeSell [pos +BarNumber - Price2SellB] = 0 ;                                                         //OUT
                           Price2SellA = RangePrice;
               Price2SellB = BarNumber;
               SellSwitchB = true ;
                    }
                       else if (RangePrice < Price2SellA)
                    {
               SwitchB = BarNumber - Price2SellB ;

         if (pos+ SwitchB<bars)MajorRangeSell[pos + SwitchB] =MainLine[pos + SwitchB]* 1.0005 ;                                                                                                                             //OUT
                SellSwitchB = true ;             
        
                               if (pos + SwitchB<bars&&MA_2[pos + SwitchB] - RangePrice >= SweepB && SwitchB >= 1 )
                              {
                                     Switch2 = 1 ;
                     Price2BuyA = RangePrice;
                     Price2BuyB = BarNumber;
                     SellSwitchB = false ;
                     BuySwitchB = false ;
                                  }
            }
         }
      }

   //   MajorRangeSell[pos] = 0;
     //  MajorRangeBuy[pos]  = 0;  
    }
//--- return value of prev_calculated for next call
   return (rates_total);
  }
//+------------------------------------------------------------------+
//========================================================================================
double High( int index)
{   
   if (index < 0 ) return (- 1 );
   double Arr[];
   ENUM_TIMEFRAMES timeframe= PERIOD_CURRENT ;
   if ( CopyHigh ( Symbol (),timeframe, index, 1 , Arr)> 0 ) 
         return (Arr[ 0 ]);
   else return (- 1 );
}
//========================================================================================
double Low( int index)
{   
   if (index < 0 ) return (- 1 );
   double Arr[];
   ENUM_TIMEFRAMES timeframe= PERIOD_CURRENT ;
   if ( CopyLow ( Symbol (),timeframe, index, 1 , Arr)> 0 ) 
         return (Arr[ 0 ]);
   else return (- 1 );
}
 
여기에서 실제 MT5 계정에서 자금을 인출할 수 있는지 또는 MT5 계정을 이 계정과 어떻게든 동기화할 수 있는지 알려주십시오. 여기에서 잔액이 0으로 표시되기 때문입니다.
 
Леонид Курганский # :
여기에서 실제 MT5 계정에서 자금을 인출할 수 있는지 또는 MT5 계정을 이 계정과 어떻게든 동기화할 수 있는지 알려주십시오. 여기에서 잔액이 0으로 표시되기 때문입니다.

귀하는 MQL5.community에 있으며 자체 결제 시스템이 있습니다. 섹션의 프로필( Leonid Kurgansky )에서 MQL5.community의 자금을 볼 수 있습니다. .

"Trade" 탭의 MetaTrader 5 터미널에서 볼 수 있는 돈은 브로커로 개설한 거래 계좌로 이체한 자금입니다.

 
Леонид Курганский # :
그리고 또 다른 질문, 누군가 ***와 함께 일한 사람이 있습니까?

중개인 및 거래 기관에 대한 논의는 금지되어 있습니다.

사유: