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

 
kopeyka2 :

일단은 하자

다른 (비 기본) 기간


일반적으로 도움을 무시합니다. 나는 대화를 떠난다. 더 나아가 나 없이 - 나는 코드의 올바른 작동을 위해 모든 데이터를 제공했지만 당신은 듣고 싶지 않고 당신 자신의 방식으로 무언가를하고 싶습니다. 시간이 아쉽습니다.
 
Artyom Trishkin :
일반적으로 도움을 무시합니다. 나는 대화를 떠난다. 더 나아가 나 없이 - 나는 코드의 올바른 작동을 위해 모든 데이터를 제공했지만 당신은 듣고 싶지 않고 당신 자신의 방식으로 무언가를하고 싶습니다. 시간이 아쉽습니다.

관심을 가져주시고 시간을 내주셔서 감사합니다....아마 아직 뭔가 와닿지 않은 것 같습니다... 바퀴와 모터에 대해서는 동의합니다.

아마도 핸들을 포기하고 평균 기간 동안 iClose 의 평균 값을 계산할 것입니다.

 
kopeyka2 :

관심을 가져주시고 시간을 내주셔서 감사합니다....아마 아직 뭔가 와닿지 않은 것 같습니다... 바퀴와 모터에 대해서는 동의합니다.

아마도 핸들을 포기하고 평균 기간 동안 iClose의 평균 값을 계산할 것입니다.

 //+------------------------------------------------------------------+
//|                                                       TestMA.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                                 https://mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link        "https://mql5.com"
#property version    "1.00"
#property description "Выводит данные скользящей средней с заданного таймфрейма на любом текущем"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots    1
//--- plot LWMA
#property indicator_label1    "MA"
#property indicator_type1    DRAW_LINE
#property indicator_color1    clrBlue
#property indicator_style1    STYLE_SOLID
#property indicator_width1    1
//--- input parameters
input uint                  InpPeriod         =   14 ;             // MA period
input int                   InpShift          =   0 ;             // MA shift
input ENUM_MA_METHOD        InpMethod         =   MODE_SMA ;       // MA method
input ENUM_APPLIED_PRICE    InpApplierPrice   =   PRICE_CLOSE ;   // MA applied price
input ENUM_TIMEFRAMES       InpTimeframe      =   PERIOD_H1 ;     // LRMA timeframe
//--- indicator buffers
double          BufferMA[];
//--- global variables
//ENUM_TIMEFRAMES   timeframe1;
int             period_ma;
int             shift_ma;
int             handle_ma;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
//--- timer
   EventSetTimer ( 90 );
//--- set global variables
   period_ma= int (InpPeriod< 1 ? 1 : InpPeriod);
   shift_ma=InpShift;
   //timeframe1=(InpTimeframe>Period() ? InpTimeframe : Period());
//--- indicator buffers mapping
   SetIndexBuffer ( 0 ,BufferMA, INDICATOR_DATA );
//--- setting indicator parameters
   IndicatorSetString ( INDICATOR_SHORTNAME , "Any TF MA on current" );
   IndicatorSetInteger ( INDICATOR_DIGITS , Digits ());
//--- setting plot buffer parameters
   string label=TimeframeToString(InpTimeframe)+ " " +MethodToString(InpMethod)+ "(" +( string )period_ma+ ")" ;
   PlotIndexSetString ( 0 , PLOT_LABEL ,label);
//--- setting buffer arrays as timeseries
   ArraySetAsSeries (BufferMA, true );
//--- create handles
   ResetLastError ();
   handle_ma= iMA ( NULL ,InpTimeframe,period_ma,shift_ma,InpMethod,InpApplierPrice);
   if (handle_ma== INVALID_HANDLE )
     {
       Print ( "The " ,TimeframeToString(InpTimeframe), " iMA(" ,( string )period_ma, ") object was not created: Error " , GetLastError ());
       return INIT_FAILED ;
     }
//--- get timeframe
   Time ( NULL ,InpTimeframe, 1 );
//---
   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 (rates_total< fmax (period_ma, 4 )) return 0 ;
//--- Проверка и расчёт количества просчитываемых баров
   int limit=rates_total-prev_calculated;
   if (limit> 1 )
     {
      limit=rates_total- 1 ;
       ArrayInitialize (BufferMA, EMPTY_VALUE );
     }
//--- Подготовка данных
   if ( Time ( NULL ,InpTimeframe, 1 )== 0 )
       return 0 ;
   int bars=(InpTimeframe== PERIOD_CURRENT ? rates_total : Bars ( NULL ,InpTimeframe));
   int count=(limit> 1 ? fmin (bars,rates_total) : 1 ),copied= 0 ;
   copied= CopyBuffer (handle_ma, 0 , 0 ,count,BufferMA);
   Comment (TimeframeToString(InpTimeframe), " " ,MethodToString(InpMethod), ": copied=" ,copied, ", count=" ,count, ", bars=" ,bars, ", rates_total=" ,rates_total);
   if (copied!=count) return 0 ;
      
//--- Расчёт индикатора
   //for(int i=limit; i>=0 && !IsStopped(); i--)
   //  {
   //   
   //  }

//--- return value of prev_calculated for next call
   return (rates_total);
  }
//+------------------------------------------------------------------+
//| Custom indicator timer function                                  |
//+------------------------------------------------------------------+
void OnTimer ()
  {
   Time ( NULL ,InpTimeframe, 1 );
  }
//+------------------------------------------------------------------+
//| Возвращает Time                                                  |
//+------------------------------------------------------------------+
datetime Time ( const string symbol_name, const ENUM_TIMEFRAMES timeframe, const int shift)
  {
   datetime array[];
   ArraySetAsSeries (array, true );
   return ( CopyTime (symbol_name,timeframe,shift, 1 ,array)== 1 ? array[ 0 ] : 0 );
  }
//+------------------------------------------------------------------+
//| Возвращает наименование таймфрейма                               |
//+------------------------------------------------------------------+
string TimeframeToString( const ENUM_TIMEFRAMES timeframe)
  {
   return StringSubstr ( EnumToString (timeframe), 7 );
  }
//+------------------------------------------------------------------+
//| Возвращает наименование метода МА                                |
//+------------------------------------------------------------------+
string MethodToString( ENUM_MA_METHOD method)
  {
   return StringSubstr ( EnumToString (method), 5 );
  }
//+------------------------------------------------------------------+

불필요한 모든 것을 제거했습니다.

주말에는 틱이 없으며 라인은 일치하는 시간 프레임(작업 시간 프레임과 설정에 있는 시간)에만 즉시 표시된다는 것을 잊지 마십시오.

설정에 지정된 시간과 다른 시간 프레임에 실행하고 주말에 틱 없이 차트를 강제로 마우스 오른쪽 버튼으로 새로 고쳐야 합니다. 새로 고침, 그러면 선이 그려집니다.

 
Artyom Trishkin :

불필요한 모든 것을 제거했습니다.

주말에는 틱이 없으며 라인은 일치하는 시간 프레임(작업 시간 프레임과 설정에 있는 시간)에만 즉시 표시된다는 것을 잊지 마십시오.

설정에 지정된 시간과 다른 시간 프레임에 실행하고 주말에 틱 없이 차트를 강제로 마우스 오른쪽 버튼으로 새로 고쳐야 합니다. 새로 고침, 그러면 선이 그려집니다.

감사합니다 !!1 하루종일 쉬고있었는데.... 눈을 감다. 다시 SPS
 

좋은 오후에요 여러분.

 
이해했다. 고맙습니다.
 
좋은 오후에요 여러분.
시간 불일치 문제에 직면하여 해결에 도움을 요청합니다.
주문이 늦게 나가는 이유를 알아내려고 Expert Advisor에 디버깅 정보를 기록합니다. 절대적으로 신뢰할 수 있습니다. 스크린샷에서 볼 수 있습니다. 메시지 시간이 막대의 시작 시간(TF=M30)보다 4.5시간 더 길다는 것을 알았습니다. 이 지연으로 인해 주문이 종료됩니다. 저것들. 디버깅 정보에 따르면 입력 조건이 충족되었음을 알 수 있습니다. 예를 들어 시간은 바에서 10:00이고 주문은 시간 14:30과 함께 바에서 출발합니다. 나는 이것을 처음 접했다. 무엇을 할까요?
파일:
MT5dataerror.jpg  724 kb
 

YouTube에서 후행 중지 코드를 찾았습니다. 어떻게 사용합니까?

 #include <Trade\Trade.mqh> 
CTrade trade;

void OnTick ()
  {
     double Ask = NormalizeDouble ( SymbolInfoDouble ( _Symbol , SYMBOL_ASK ), _Digits );
    
         if ( PositionsTotal ()< 2 )
    
    trade.Buy( 0.10 , NULL , Ask ,( Ask - 1000 * _Point ),( Ask + 500 * _Point ), NULL );
    
    CheckTrailingStop( Ask );
   
  }
void    CheckTrailingStop( double Ask )
  {
     double SL = NormalizeDouble ( Ask - 150 * _Point , _Digits );
     
     for ( int i= PositionsTotal ()- 1 ; i>= 0 ; i--)
     {
     string symbol= PositionGetSymbol (i);
     if ( _Symbol ==symbol)
     {
     ulong PositionTicket= PositionGetInteger ( POSITION_TICKET );
     
     double CurrentStopLoss= PositionGetDouble ( POSITION_SL );
     if (CurrentStopLoss<SL)
     {
       trade.PositionModify(PositionTicket,(CurrentStopLoss + 10 * _Point ), 0 );
     }
   }
  }   
}
 
Vladimir Baskakov :

YouTube에서 후행 중지 코드를 찾았습니다. 어떻게 사용합니까?

이 트롤은 구매 전용이며 구현되어 있으므로 사용할 수 없습니다.

 
Nikolay Khrushchev :

이 트롤은 구매 전용이며 구현되어 있으므로 사용할 수 없습니다.

알았어 고마워
사유: