1附件嗨大家好
您是否知道如何更改此代碼以使此MTF MACD更加流暢?
讓我們說,在M1上使用indior繪製M5 MACD(使用默認設置12,26,9),然後indior將參考計算中使用的每個收盤價5次,直到移動到下一個收盤價(這將是再次使用5次)。因此,您獲得的樓梯踏步的MTF MACD更高或更低。
如何更改,以便在任何給定時間室內參考主時間框架的下一個收盤價?
案件:
我們在M1上將MTF MACD設置為5(下一個更高的TF)。現在為了獲得更平滑的MACD值,我將在任何時候使用當前價格shift0和shift5,shift10,15,20,25等的收盤價。
如果在M5和MTF MACD設置為M15,則indior應該參考當前價格shift0和shift3,shift6,9等的收盤價。
我認為,每次較低的時間範圍繪製新條形時,更新的時間範圍MACD值都會更新。當然,它不會繪製精確的較高TF的MACD值,就像在較高的TF上繪製MACD一樣。但它會提供更早的零線交叉,以及可能更早的交易信號。
我在這裡拿到了MTF MACD:[url = http://codebase.mql4.com/5660]。
代碼粘貼在下面。你能幫助我嗎?必須更改start函數中的某些代碼才能獲得我的目標。
乾杯
托馬斯
_______
// ----------------------------------------------- -------------------
//| MTF MACD.mq4 |
// ----------------------------------------------- -------------------
#property copyright mqlservice.co.uk
#property鏈接http://mqlservice.co.uk/
#property indior_separate_window
#property indior_buffers 2
#property indior_color1灰色
#property indior_color2紅色
//----輸入參數
extern int TimeFrame = 0;
extern int FastEMA = 12;
extern int SlowEMA = 26;
extern int Signal = 9;
extern int AppliedPrice = 0;
extern int Shift = 0;
extern string note0 =應用價格0-CLOSE | 1-OPEN | 2-HIGH | 3-LOW |;
extern string note1 = | 4-MEDIAN | 5-TYPICAL | 6加權|;
extern string note2 =時間幀0 =當前時間範圍;
外部字符串note3 = 1 = M1,5 = M5,15 = M15,30 = M30;
extern string note4 = 60 = H1,240 = H4,1440 = D1;
extern string note5 = 10080 = W1,43200 = MN1;
//----緩衝區
double MainBuffer [];
double SignalBuffer [];
// ----------------------------------------------- -------------------
//|自定義室內初始化功能|
// ----------------------------------------------- -------------------
int init()
{
int draw_begin = MathMax(FastEMA,SlowEMA);
string short_name = MTF MACD價格;
//- - 在室內
SetIndexStyle(0,DRAW_HISTOGRAM,0,2);
SetIndexBuffer(0,MainBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,SignalBuffer);
打印(MTF MACD.mq4,Ver。#2);
打印(版權所有©2009/05/26 MQL Service UK http://mqlservice.co.uk/);
開關(AppliedPrice){
案例1:short_name = short_name |開放;打破;
情況2:short_name = short_name |高;打破;
案例3:short_name = short_name |低;打破;
案例4:short_name = short_name | MEDIAN;打破;
案例5:short_name = short_name |典型的;打破;
案例6:short_name = short_name |加權;打破;
默認值:
AppliedPrice = PRICE_CLOSE; SHORT_NAME = SHORT_NAME |關 ;打破;
}
if(TimeFramelt; Period())TimeFrame = Period();
string TFName =;
開關(時限)
{
案例1:TFName = M1;打破;
情況5:TFName = M5;打破;
案例15:TFName = M15;打破;
情況30:TFName = M30;打破;
case 60:TFName = H1;打破;
情況240:TFName = H4;打破;
case 1440:TFName = D1;打破;
case 10080:TFName = W1;打破;
case 43200:TFName = MN1;打破;
默認值:TFName = Chart;時限=週期();打破;
}
short_name = StringConenate(short_name,(TF TFName , FastEMA , SlowEMA , Signal ));
IndiorShortName(SHORT_NAME);
SetIndexDrawBegin(0,draw_begin);
SetIndexDrawBegin(1,draw_begin);
SetIndexLabel(0,主);
SetIndexLabel(1,信號);
IndiorDigits(6);
返回(0);
}
// ----------------------------------------------- -------------------
//|定制室內取消初始化功能|
// ----------------------------------------------- -------------------
int deinit()
{
//----
//----
返回(0);
}
// ----------------------------------------------- -------------------
//|自定義室內迭代功能|
// ----------------------------------------------- -------------------
int start()
{
int limit,iChart,iTF,delta = 0;
datetime TimeArray [];
if(TimeFramegt; Period())delta = MathCeil(TimeFramePeriod());
int counts_bars = IndiorCounted();
//----檢查可能的錯誤
if(counts_barslt; 0)return(-1);
//----將重新計算最後計算的欄
if(counting_barsgt; 0)counting_bars--;
極限=棒材 - counted_bars 增量;
ArrayCopySeries(TimeArray,MODE_TIME,符號(),時間範圍);
ITF = 0;
for(Chart = 0; iChart; limit; iChart)
{
while(Time [iChart] lt; TimeArray [iTF])iTF ;
MainBuffer [iChart] = EMPTY_VALUE;
SignalBuffer [iChart] = EMPTY_VALUE;
MainBuffer [iChart] = iMACD(符號(),時間範圍,FastEMA,SlowEMA,信號,AppliedPrice,MODE_MAIN,ITF Shift鍵);
SignalBuffer [iChart] = iMACD(符號(),時間範圍,FastEMA,SlowEMA,信號,AppliedPrice,MODE_SIGNAL,ITF Shift鍵);
}
返回(0);
}
// ----------------------------------------------- -------------------
https://www.forex-pedia.com/attachme...1556900020.mq4