初心者の方からの質問 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日中ガチャガチャしてました...目が縫われてるんです。ありがとうございました。
 

皆さん、こんにちは。

 
了解です、ありがとうございます。
 
皆さん、こんにちは。
時間の不一致の問題に直面し、それを解決するために助けてください。
注文が遅れている理由を理解しようとして、私は私のEAでデバッグ情報を記録しています、それは絶対に正しいです、あなたはスクリーンショットにそれを見ることができます。メッセージの時刻がバーの開始時刻(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:

このトロールは購入専用で、実装が貧弱なため、使用できません。

わかりました、ありがとうございます。
理由: