Jump to content

MTF MACD


Recommended Posts

Re: (Req) MTF MACD

 

try :

 

 

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Silver

#property indicator_color2 Red

 

//---- input parameters

 

extern int TimeFrame=0;

extern int FastEMA=12;

extern int SlowEMA=26;

extern int SignalSMA=9;

extern int applied_price=0;

 

 

double ExtMapBuffer1[];

double ExtMapBuffer2[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

 

//---- indicator line

SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexDrawBegin(1,SignalSMA);

IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);

 

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexBuffer(1,ExtMapBuffer2);

//---- name for DataWindow and indicator subwindow label

switch(TimeFrame)

{

case 1 : string TimeFrameStr="Period_M1"; break;

case 5 : TimeFrameStr="Period_M5"; break;

case 15 : TimeFrameStr="Period_M15"; break;

case 30 : TimeFrameStr="Period_M30"; break;

case 60 : TimeFrameStr="Period_H1"; break;

case 240 : TimeFrameStr="Period_H4"; break;

case 1440 : TimeFrameStr="Period_D1"; break;

case 10080 : TimeFrameStr="Period_W1"; break;

case 43200 : TimeFrameStr="Period_MN1"; break;

default : TimeFrameStr="Current Timeframe";

}

IndicatorShortName("MTF_MACD("+FastEMA+","+SlowEMA+","+SignalSMA+") ("+TimeFrameStr+")");

 

}

//----

return(0);

 

//+------------------------------------------------------------------+

//| MTF MACD |

//+------------------------------------------------------------------+

int start()

{

datetime TimeArray[];

int i,limit,y=0,counted_bars=IndicatorCounted();

 

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);

 

limit=Bars-counted_bars;

for(i=0,y=0;i<limit;i++)

{

if (Time<TimeArray[y]) y++;

 

ExtMapBuffer1=iMACD(NULL,TimeFrame,FastEMA,SlowEMA,SignalSMA,applied_price,0,y);

ExtMapBuffer2=iMACD(NULL,TimeFrame,FastEMA,SlowEMA,SignalSMA,applied_price,1,y);

}

 

//

 

 

 

return(0);

}

//+------------------------------------------------------------------+

Link to comment
Share on other sites

Re: (Req) MTF MACD

 

try :

 

 

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Silver

#property indicator_color2 Red

 

//---- input parameters

 

extern int TimeFrame=0;

extern int FastEMA=12;

extern int SlowEMA=26;

extern int SignalSMA=9;

extern int applied_price=0;

 

 

double ExtMapBuffer1[];

double ExtMapBuffer2[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

 

//---- indicator line

SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexDrawBegin(1,SignalSMA);

IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);

 

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexBuffer(1,ExtMapBuffer2);

//---- name for DataWindow and indicator subwindow label

switch(TimeFrame)

{

case 1 : string TimeFrameStr="Period_M1"; break;

case 5 : TimeFrameStr="Period_M5"; break;

case 15 : TimeFrameStr="Period_M15"; break;

case 30 : TimeFrameStr="Period_M30"; break;

case 60 : TimeFrameStr="Period_H1"; break;

case 240 : TimeFrameStr="Period_H4"; break;

case 1440 : TimeFrameStr="Period_D1"; break;

case 10080 : TimeFrameStr="Period_W1"; break;

case 43200 : TimeFrameStr="Period_MN1"; break;

default : TimeFrameStr="Current Timeframe";

}

IndicatorShortName("MTF_MACD("+FastEMA+","+SlowEMA+","+SignalSMA+") ("+TimeFrameStr+")");

 

}

//----

return(0);

 

//+------------------------------------------------------------------+

//| MTF MACD |

//+------------------------------------------------------------------+

int start()

{

datetime TimeArray[];

int i,limit,y=0,counted_bars=IndicatorCounted();

 

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);

 

limit=Bars-counted_bars;

for(i=0,y=0;i<limit;i++)

{

if (Time<TimeArray[y]) y++;

 

ExtMapBuffer1=iMACD(NULL,TimeFrame,FastEMA,SlowEMA,SignalSMA,applied_price,0,y);

ExtMapBuffer2=iMACD(NULL,TimeFrame,FastEMA,SlowEMA,SignalSMA,applied_price,1,y);

}

 

//

 

 

 

return(0);

}

//+------------------------------------------------------------------+

 

 

 

Thanks Very Much to the good Oleng! I gave you Kudos. It works well! =D>

 

 

(For any who use it, in the finished indicator settings, once the indicator is on the 1minute chart, change BOTH the time period and applied price inputs to 5 for a 5 minute MACD on the 1 minute chart)

 

 

 

Note: I tried to upload the finished mq4 indicator, but got the following error message:

 

"The file is too big, maximum allowed size is 1 KiB". :-?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...