MQL4、MQL5に関する初心者からの質問、アルゴリズムやコードに関するヘルプ、ディスカッションなど。 - ページ 586 1...579580581582583584585586587588589590591592593...1953 新しいコメント Sergii Krutyi 2018.07.24 19:14 #5851 Alexey Viktorov: なぜダメなのか?テスト中にMT4が手数料が存在する口座に接続されている場合、それは間違いなくそれを考慮します。そして、テスト中にOrderCommission()関数を試し、何が出るか見てみましょう :) Vitaly Muzichenko 2018.07.24 19:27 #5852 Sergii Krutyi:そして、テスト中にOrderCommission()関数を試し、何が出るか見て みましょう: )委員会 bij 2018.07.24 19:53 #5853 Andrey Barinov:https://www.mql5.com/ru/docs/constants/structures/mqldatetimeこのエラーを修正する方法を教えてください。 'TargetTimeFrame' - cannot convert enum max_min.mq5 397 17 if(Period()>=TargetTimeFrame)// строка 397 return( rates_total );設定にて。 enum AvailablePeriods { PreviousDay=PERIOD_D1,// Previous day PreviousWeek=PERIOD_W1,// Previous week PreviousMonth=PERIOD_MN1 // Previous month }; input AvailablePeriods TargetTimeFrame=PreviousDay; // Period Sergii Krutyi 2018.07.24 20:02 #5854 Vitaly Muzichenko:委員会0になり、アカウントの実際の手数料ではなく、その人は値がどうなるかをテスターで尋ねます。 Evgentlt 2018.07.24 21:23 #5855 中括弧{ }がなぜ必要なのか、いつ、どのように使うのか、理解できません。私はまだ胎動期で、簡単な関数を学んでいる段階ですが、必要だからといってこれらの記号をつけるのではなく、いつ、どのように使うのか理解する必要があります。 Alexey Viktorov 2018.07.24 21:28 #5856 Evgentlt: 中括弧{ }をいつ、どのように使うのかが理解できません。私はまだ胎動期で、簡単な関数を学んでいる段階ですが、必要だからといってこれらの記号をつけるのではなく、いつ、どのように使うのか理解する必要があります。これだけ で、理解できるかもしれません。 こちらも どうぞ。 Составной оператор - Операторы - Основы языка - Справочник MQL4 docs.mql4.com Составной оператор - Операторы - Основы языка - Справочник MQL4 bij 2018.07.24 21:30 #5857 Evgentlt: 中括弧{ }がなぜ必要なのか、いつ、どのように使うのか、理解できません。私はまだ未熟で、簡単な関数を学んでいる段階ですが、必要だからといってこれらの記号をつけるのではなく、いつ、どのように使うのか理解する必要があります。 中括弧 { } で囲まれた、任意の型の1つ以上の演算子。 Andrey Barinov 2018.07.25 02:51 #5858 bij:このエラーを修正する方法を教えてください。 設定にて。 もっとコードが必要だ。 bij 2018.07.25 03:31 #5859 Andrey Barinov :より多くのコードが必要#property strict #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 C'83,173,52' #property indicator_color2 C'83,173,52' #property indicator_color3 C'83,173,52' #property indicator_style1 STYLE_DASH ; #property indicator_style2 STYLE_SOLID ; #property indicator_style3 STYLE_DASH ; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ enum AvailablePeriods { PreviousDay= PERIOD_D1 , // Previous day PreviousWeek= PERIOD_W1 , // Previous week PreviousMonth= PERIOD_MN1 // Previous month }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ struct TimeRange { bool Failed; datetime StartTime; datetime EndTime; TimeRange() { Failed= false ; StartTime= 0 ; EndTime= 0 ; } }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ struct PeriodData { TimeRange PeriodRange; double PeriodHigh; double PeriodClose; double PeriodLow; PeriodData() { PeriodHigh= 0 ; PeriodClose= 0 ; PeriodLow= 0 ; } }; input string _sepTimeShift= "" ; // /////// Calculation input ENUM_TIMEFRAMES Precision= PERIOD_H1 ; // Precision input AvailablePeriods TargetTimeFrame=PreviousDay; // Period input int PeriodsToCalculate= 1 ; // Periods to calculate input int HoursShift=- 2 ; // Hours shift input int MinutesShift= 0 ; // Minutes shift input bool IgnoreSunday= true ; // Ignore Sunday input bool IgnoreSaturday= true ; // Ignore Saturday input string _sepBufferVisibility= "" ; // /////// Buffer visibility input bool ShowHighBuffer= true ; // High input bool ShowCloseBuffer= true ; // Close input bool ShowLowBuffer= true ; // Low input string _sepProbeVisibility= "" ; // /////// Probe visibility input bool ShowHighProbe= true ; // High input bool ShowCloseProbe= true ; // Close input bool ShowLowProbe= true ; // Low input string _sepProbeColor= "" ; // /////// Probe color input color HighColor= C'83,173,52' ; // High input color CloseColor= C'83,173,52' ; // Close input color LowColor= C'83,173,52' ; // Low input string _sepProbeSize= "" ; // /////// Probe size input int HighSize= 2 ; // High input int CloseSize= 2 ; // Close input int LowSize= 2 ; // Low input string _sepCustomLabel= "" ; // /////// Data window label input string HighLabel= "P.Day High" ; // High input string CloseLabel= "P.Day Close" ; // Close input string LowLabel= "P.Day Low" ; // Low string HighProbeName= "HighPrevious" + IntegerToString (TargetTimeFrame)+ IntegerToString (HoursShift)+ IntegerToString (MinutesShift); string CloseProbeName= "ClosePrevious" + IntegerToString (TargetTimeFrame)+ IntegerToString (HoursShift)+ IntegerToString (MinutesShift); string LowProbeName= "LowPrevious" + IntegerToString (TargetTimeFrame)+ IntegerToString (HoursShift)+ IntegerToString (MinutesShift); double PeriodHighBuffer[]; double PeriodCloseBuffer[]; double PeriodLowBuffer[]; PeriodData TempData; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ PeriodData CalculateCommonSRData( datetime targetTime,TimeRange &periodRange) { if (TempData.PeriodRange.StartTime==periodRange.StartTime && TempData.PeriodRange.EndTime==periodRange.EndTime) return ( TempData ); PeriodData result; int firstBar= iBarShift ( Symbol (),Precision,periodRange.StartTime); int lastBar = iBarShift ( Symbol (),Precision,periodRange.EndTime); datetime firstBarTime= iTime ( Symbol (),Precision,firstBar); datetime lastBarTime = iTime ( Symbol (),Precision,lastBar); int startBar=lastBar; int bars=firstBar-lastBar+ 1 ; int highestBar= iHighest ( Symbol (),Precision, MODE_HIGH ,bars,startBar); int lowestBar = iLowest ( Symbol (),Precision, MODE_LOW ,bars,startBar); result.PeriodRange= periodRange; result.PeriodHigh = iHigh ( Symbol (),Precision,highestBar); result.PeriodClose= iClose ( Symbol (),Precision,lastBar); result.PeriodLow= iLow ( Symbol (),Precision,lowestBar); TempData=result; return ( result ); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ datetime MoveDateToEndOfDay( datetime target) { MqlDateTime targetTime; TimeToStruct (target,targetTime); targetTime.hour= 23 ; targetTime.min = 59 ; targetTime.sec = 59 ; return ( StructToTime ( targetTime ) ); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ datetime MoveDateToEndOfMonth( datetime target) { MqlDateTime targetTime; TimeToStruct (target,targetTime); targetTime.mon++; targetTime.day= 1 ; targetTime.hour= 0 ; targetTime.min = 0 ; targetTime.sec = 0 ; return ( StructToTime ( targetTime ) - 1 ); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ datetime MoveDateToEndOfWeek( datetime target) { MqlDateTime targetTime; TimeToStruct (target,targetTime); targetTime.day += 5 - targetTime.day_of_week; targetTime.hour = 23 ; targetTime.min = 59 ; targetTime.sec = 59 ; return ( StructToTime ( targetTime ) ); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ TimeRange CalculateTargetTimeRange( datetime targetTime,AvailablePeriods targetPeriod, int periodShift, ENUM_TIMEFRAMES precision, int hoursShift, int minutesShift, bool ignoreSunday, bool ignoreSaturday) { TimeRange currentRange=CalculateTimeRange(targetTime,( ENUM_TIMEFRAMES )( int )targetPeriod,precision, 0 ,hoursShift,minutesShift,ignoreSunday,ignoreSaturday); if (targetTime<currentRange.StartTime) periodShift++; if (targetTime>currentRange.EndTime) periodShift--; if (periodShift== 0 ) return ( currentRange ); TimeRange target=CalculateTimeRange(targetTime,( ENUM_TIMEFRAMES )( int )targetPeriod,precision,periodShift,hoursShift,minutesShift,ignoreSunday,ignoreSaturday); return ( target ); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ TimeRange CalculateTimeRange( datetime targetTime, ENUM_TIMEFRAMES targetPeriod, ENUM_TIMEFRAMES precision, int periodShift, int hoursShift, int minutesShift, bool ignoreSunday, bool ignoreSaturday) { if (targetPeriod<precision) precision=targetPeriod; TimeRange result; int totalShift=hoursShift* 3600 +minutesShift* 60 ; // Start time. int periodStartBar= iBarShift ( Symbol (),targetPeriod,targetTime)+periodShift; datetime periodStartTime= iTime ( Symbol (),targetPeriod,periodStartBar); int precisePeriodStartBar= iBarShift ( Symbol (),precision,periodStartTime); datetime precisePeriodStartTime= iTime ( Symbol (),precision,precisePeriodStartBar); if (precisePeriodStartTime== 0 ) result.Failed= true ; if (precisePeriodStartTime>periodStartTime) { precisePeriodStartTime= iTime ( Symbol (),precision,precisePeriodStartBar+ 1 ); if (precisePeriodStartTime== 0 ) result.Failed= true ; } if (result.Failed) return ( result ); if (precisePeriodStartTime<periodStartTime) precisePeriodStartTime=MoveDateToEndOfDay(precisePeriodStartTime)+ 1 ; result.StartTime=precisePeriodStartTime; // End time. int nextPeriodStartBar = periodStartBar - 1 ; if (nextPeriodStartBar >= 0 ) { // Exact calculation. datetime nextPeriodStartTime= iTime ( Symbol (),targetPeriod,nextPeriodStartBar); int preciseNextPeriodStartBar= iBarShift ( Symbol (),precision,nextPeriodStartTime); datetime preciseNextPeriodStartTime= iTime ( Symbol (),precision,preciseNextPeriodStartBar); if (preciseNextPeriodStartTime== 0 ) result.Failed= true ; if (preciseNextPeriodStartTime>=nextPeriodStartTime) { preciseNextPeriodStartTime= iTime ( Symbol (),precision,preciseNextPeriodStartBar+ 1 ); if (preciseNextPeriodStartTime== 0 ) result.Failed= true ; } if (result.Failed) return ( result ); if (preciseNextPeriodStartTime<nextPeriodStartTime) preciseNextPeriodStartTime=MoveDateToEndOfDay(preciseNextPeriodStartTime); //if(TimeHour(preciseNextPeriodStartTime)==0) MqlDateTime timestruct={ 0 }; :: TimeToStruct (preciseNextPeriodStartTime,timestruct); if (timestruct.hour== 0 ) preciseNextPeriodStartTime--; result.EndTime=preciseNextPeriodStartTime; } else { // Approximation. switch (targetPeriod) { case PERIOD_D1 : result.EndTime=MoveDateToEndOfDay( iTime ( Symbol (),precision, 0 )); break ; case PERIOD_W1 : result.EndTime=MoveDateToEndOfWeek( iTime ( Symbol (),precision, 0 )); break ; case PERIOD_MN1 : result.EndTime=MoveDateToEndOfMonth( iTime ( Symbol (),precision, 0 )); break ; } } // Resulting shifted time. result.StartTime+=totalShift; result.EndTime+=totalShift; // Sunday and saturday fix. if (targetPeriod== PERIOD_D1 ) { // if(TimeDayOfWeek(result.StartTime)==SUNDAY && ignoreSunday) // result.StartTime-=86400; // // if(TimeDayOfWeek(result.EndTime)==SATURDAY && ignoreSaturday) // result.EndTime+=86400; // } // MqlDateTime timestruct={ 0 }; :: TimeToStruct (result.StartTime,timestruct); if (timestruct.day_of_week== SATURDAY && ignoreSaturday) result.StartTime-= 86400 ; // MqlDateTime timestruct={0}; // ::TimeToStruct(preciseNextPeriodStartTime,timestruct); // // if(timestruct.preciseNextPeriodStartTime==0) :: TimeToStruct (result.EndTime,timestruct); if (timestruct.day_of_week== SATURDAY && ignoreSaturday) result.EndTime+= 86400 ; } return ( result ); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void DrawRightPriceProbe( int window, bool selectable, string name, int lineWidth, color lineColor, datetime date, double price, bool visible= true , int zorder= 0 , string tooltip= "\n" ) { bool create= false ; int foundAtWindow= ObjectFind ( ChartID (),name); if (foundAtWindow< 0 ) create= true ; if (foundAtWindow>= 0 && window!=foundAtWindow) { ObjectDelete ( ChartID (),name); create= true ; } if (!create) { ObjectSetInteger ( ChartID (),name, OBJPROP_TIME ,date); ObjectSetDouble ( ChartID (),name, OBJPROP_PRICE ,price); } else ObjectCreate ( ChartID (),name, OBJ_ARROW_RIGHT_PRICE ,window,date,price); ObjectSetInteger ( ChartID (),name, OBJPROP_COLOR ,lineColor); ObjectSetInteger ( ChartID (),name, OBJPROP_WIDTH ,lineWidth); ObjectSetInteger ( ChartID (),name, OBJPROP_HIDDEN ,!selectable); ObjectSetInteger ( ChartID (),name, OBJPROP_SELECTABLE ,selectable); if (!visible) ObjectSetInteger ( ChartID (),name, OBJPROP_TIMEFRAMES , OBJ_NO_PERIODS ); ObjectSetInteger ( ChartID (),name, OBJPROP_ZORDER ,zorder); ObjectSetString ( ChartID (),name, OBJPROP_TOOLTIP ,tooltip); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnDeinit ( const int reason) { ObjectDelete ( ChartID (),HighProbeName); ObjectDelete ( ChartID (),CloseProbeName); ObjectDelete ( ChartID (),LowProbeName); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit () { PlotIndexGetInteger ( 0 , PLOT_DRAW_TYPE , DRAW_LINE ); PlotIndexGetInteger ( 1 , PLOT_DRAW_TYPE , DRAW_LINE ); PlotIndexGetInteger ( 2 , PLOT_DRAW_TYPE , DRAW_LINE ); SetIndexBuffer ( 0 ,PeriodHighBuffer, INDICATOR_DATA ); SetIndexBuffer ( 1 ,PeriodCloseBuffer, INDICATOR_DATA ); SetIndexBuffer ( 2 ,PeriodLowBuffer, INDICATOR_DATA ); PlotIndexSetString ( 0 , PLOT_LABEL ,HighLabel); PlotIndexSetString ( 1 , PLOT_LABEL ,CloseLabel); PlotIndexSetString ( 2 , PLOT_LABEL ,LowLabel); return ( INIT_SUCCEEDED ); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ 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 ( Period ()>=TargetTimeFrame) return ( rates_total ); int total=rates_total-prev_calculated; if (total> 0 ) { int i = - 1 ; int n = ( total + 7 ) / 8 ; int remainingPeriods=PeriodsToCalculate; PeriodData currentData; TimeRange currentTimeRange; TimeRange previousTimeRange; switch (total% 8 ) { case 0 : OnCalculateStep( currentData, currentTimeRange, previousTimeRange, remainingPeriods, time, ++i ); case 7 : OnCalculateStep( currentData, currentTimeRange, previousTimeRange, remainingPeriods, time, ++i ); case 6 : OnCalculateStep( currentData, currentTimeRange, previousTimeRange, remainingPeriods, time, ++i ); case 5 : OnCalculateStep( currentData, currentTimeRange, previousTimeRange, remainingPeriods, time, ++i ); case 4 : OnCalculateStep( currentData, currentTimeRange, previousTimeRange, remainingPeriods, time, ++i ); case 3 : OnCalculateStep( currentData, currentTimeRange, previousTimeRange, remainingPeriods, time, ++i ); case 2 : OnCalculateStep( currentData, currentTimeRange, previousTimeRange, remainingPeriods, time, ++i ); case 1 : OnCalculateStep( currentData, currentTimeRange, previousTimeRange, remainingPeriods, time, ++i ); } while (--n> 0 ) { OnCalculateStep(currentData,currentTimeRange,previousTimeRange,remainingPeriods,time,++i); OnCalculateStep(currentData,currentTimeRange,previousTimeRange,remainingPeriods,time,++i); OnCalculateStep(currentData,currentTimeRange,previousTimeRange,remainingPeriods,time,++i); OnCalculateStep(currentData,currentTimeRange,previousTimeRange,remainingPeriods,time,++i); OnCalculateStep(currentData,currentTimeRange,previousTimeRange,remainingPeriods,time,++i); OnCalculateStep(currentData,currentTimeRange,previousTimeRange,remainingPeriods,time,++i); OnCalculateStep(currentData,currentTimeRange,previousTimeRange,remainingPeriods,time,++i); OnCalculateStep(currentData,currentTimeRange,previousTimeRange,remainingPeriods,time,++i); } if (total== 1 ) { TimeRange olderBarRange=CalculateTargetTimeRange(time[ 1 ],TargetTimeFrame, 1 ,Precision,HoursShift,MinutesShift,IgnoreSunday,IgnoreSaturday); if (olderBarRange.StartTime!=currentTimeRange.StartTime) { PeriodHighBuffer[ 1 ]= EMPTY_VALUE ; PeriodCloseBuffer[ 1 ]= EMPTY_VALUE ; PeriodLowBuffer[ 1 ]= EMPTY_VALUE ; } } } if (total> 0 || prev_calculated> 0 ) { if (ShowHighProbe && ShowHighBuffer) DrawRightPriceProbe( ChartWindowFind (), false , HighProbeName, HighSize, HighColor, time[ 0 ], PeriodHighBuffer[ 0 ] ); if (ShowCloseProbe && ShowCloseBuffer) DrawRightPriceProbe( ChartWindowFind (), false , CloseProbeName, CloseSize, CloseColor, time[ 0 ], PeriodCloseBuffer[ 0 ] ); if (ShowLowProbe && ShowLowBuffer) DrawRightPriceProbe( ChartWindowFind (), false , LowProbeName, LowSize, LowColor, time[ 0 ], PeriodLowBuffer[ 0 ] ); } return ( rates_total ); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnCalculateStep(PeriodData ¤tData,TimeRange ¤tTimeRange,TimeRange &previousTimeRange, int &remainingPeriods, const datetime &time[], int i) { if (currentTimeRange.Failed || remainingPeriods< 1 ) { PeriodHighBuffer[i]= EMPTY_VALUE ; PeriodCloseBuffer[i]= EMPTY_VALUE ; PeriodLowBuffer[i]= EMPTY_VALUE ; return ; } currentTimeRange=CalculateTargetTimeRange(time[i],TargetTimeFrame, 1 ,Precision,HoursShift,MinutesShift,IgnoreSunday,IgnoreSaturday); if (i== 0 ) { currentData=CalculateCommonSRData(time[i],currentTimeRange); previousTimeRange=currentTimeRange; } if (previousTimeRange.StartTime==currentTimeRange.StartTime) { if (ShowHighBuffer) PeriodHighBuffer[i]=currentData.PeriodHigh; if (ShowCloseBuffer) PeriodCloseBuffer[i]=currentData.PeriodClose; if (ShowLowBuffer) PeriodLowBuffer[i]=currentData.PeriodLow; } else { PeriodHighBuffer[i]= EMPTY_VALUE ; PeriodCloseBuffer[i]= EMPTY_VALUE ; PeriodLowBuffer[i]= EMPTY_VALUE ; if (--remainingPeriods< 1 ) return ; currentData=CalculateCommonSRData(time[i],currentTimeRange); } previousTimeRange=currentTimeRange; } //+------------------------------------------------------------------+ 全体) Andrey Barinov 2018.07.25 06:39 #5860 bij: 全体)このようにコンパイルします。 if(Period()>=(ENUM_TIMEFRAMES) TargetTimeFrame) return( rates_total ); 1...579580581582583584585586587588589590591592593...1953 新しいコメント 取引の機会を逃しています。 無料取引アプリ 8千を超えるシグナルをコピー 金融ニュースで金融マーケットを探索 新規登録 ログイン スペースを含まないラテン文字 このメールにパスワードが送信されます エラーが発生しました Googleでログイン WebサイトポリシーおよびMQL5.COM利用規約に同意します。 新規登録 MQL5.com WebサイトへのログインにCookieの使用を許可します。 ログインするには、ブラウザで必要な設定を有効にしてください。 ログイン/パスワードをお忘れですか? Googleでログイン
なぜダメなのか?テスト中にMT4が手数料が存在する口座に接続されている場合、それは間違いなくそれを考慮します。
そして、テスト中にOrderCommission()関数を試し、何が出るか見てみましょう :)
そして、テスト中にOrderCommission()関数を試し、何が出るか見て みましょう: )
委員会
https://www.mql5.com/ru/docs/constants/structures/mqldatetime
このエラーを修正する方法を教えてください。
設定にて。
委員会
0になり、アカウントの実際の手数料ではなく、その人は値がどうなるかをテスターで尋ねます。
中括弧{ }をいつ、どのように使うのかが理解できません。私はまだ胎動期で、簡単な関数を学んでいる段階ですが、必要だからといってこれらの記号をつけるのではなく、いつ、どのように使うのか理解する必要があります。
これだけ で、理解できるかもしれません。
こちらも どうぞ。
中括弧{ }がなぜ必要なのか、いつ、どのように使うのか、理解できません。私はまだ未熟で、簡単な関数を学んでいる段階ですが、必要だからといってこれらの記号をつけるのではなく、いつ、どのように使うのか理解する必要があります。
このエラーを修正する方法を教えてください。
設定にて。
もっとコードが必要だ。
より多くのコードが必要
全体)
このようにコンパイルします。