Jump to content

MACD_arrows alerts needed


panamamike

Recommended Posts

I have an indicator that I use as part of a 4 hour trading strategy. I would like to add alerts to it including email alerts. If someone could add that for me I would be very grateful.

 

 

 

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

//| MACD_arrows_v0.mq4 |

//| SyDef Research |

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

#property copyright "SyDef Research"

 

 

#property indicator_chart_window

#property indicator_buffers 4

 

 

#property indicator_color1 Indigo

#property indicator_color2 Red

#property indicator_color3 SlateGray

#property indicator_color4 SlateGray

/*

#property indicator_color5 MediumBlue

#property indicator_color6 Maroon

#property indicator_color7 Lime

#property indicator_color8 Red

*/

 

 

//-------------------------------

// Input parameters:

//-------------------------------

 

 

extern int FastMACD = 12;

extern int SlowMACD = 26;

extern int SignalMACD = 5;

 

 

extern int space = 4;

 

 

 

 

 

 

//-------------------------------

// Buffers

//-------------------------------

 

 

double ExtMapBuffer1[];

double ExtMapBuffer2[];

double ExtMapBuffer3[];

double ExtMapBuffer4[];

/*

double ExtMapBuffer5[];

double ExtMapBuffer6[];

double ExtMapBuffer7[];

double ExtMapBuffer8[];

*/

 

 

//-------------------------------

// Internal variables

//-------------------------------

 

 

double my_Point;

 

 

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

//| Custom indicator initialization function |

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

int init()

{

// Buffers and style

SetIndexStyle(0, DRAW_ARROW, 0, 2);

SetIndexArrow(0, 217);

SetIndexBuffer(0, ExtMapBuffer1);

SetIndexStyle(1, DRAW_ARROW, 0, 2);

SetIndexArrow(1, 218);

SetIndexBuffer(1, ExtMapBuffer2);

 

SetIndexStyle(2, DRAW_ARROW, 0, 0);

SetIndexArrow(2, 222);

SetIndexBuffer(2, ExtMapBuffer3);

SetIndexStyle(3, DRAW_ARROW, 0, 0);

SetIndexArrow(3, 221);

SetIndexBuffer(3, ExtMapBuffer4);

/*

SetIndexStyle(4, DRAW_ARROW, 0, 2);

SetIndexArrow(4, 228);

SetIndexBuffer(4, ExtMapBuffer5);

SetIndexStyle(5, DRAW_ARROW, 0, 2);

SetIndexArrow(5, 230);

SetIndexBuffer(5, ExtMapBuffer6);

 

SetIndexStyle(6, DRAW_ARROW, 0, 0);

SetIndexArrow(6, 221);

SetIndexBuffer(6, ExtMapBuffer7);

SetIndexStyle(7, DRAW_ARROW, 0, 0);

SetIndexArrow(7, 222);

SetIndexBuffer(7, ExtMapBuffer8);

*/

 

switch ( Digits ) {

 

case 3: my_Point = Point * 10;

case 4: my_Point = Point;

case 5: my_Point = Point * 10;

}

 

// Data window

IndicatorShortName("MACD_arrows");

SetIndexLabel(0, "Main UP signal");

SetIndexLabel(1, "Main DOWN signal");

SetIndexLabel(2, "Aux down signal");

SetIndexLabel(3, "Aux up signal");

 

 

 

return(0);

}

 

 

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

//| Custor indicator deinitialization function |

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

int deinit() {

 

 

Comment("");

return(0);

}

 

 

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

//| Custom indicator iteration function |

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

int start() {

 

 

int limit;

int counted_bars = IndicatorCounted();

 

 

// check for possible errors

if(counted_bars < 0)

return(-1);

 

 

//last counted bar will be recounted

if ( counted_bars > 0 )

counted_bars--;

limit = Bars - counted_bars;

 

 

// Check the signal for each bar

for( int i = limit; i >= 0; i-- ) {

 

// Classic MACD values

 

double macd_signal_0 = iMACD( NULL, 0, FastMACD, SlowMACD, SignalMACD, PRICE_CLOSE, MODE_SIGNAL, i );

double macd_signal_1 = iMACD( NULL, 0, FastMACD, SlowMACD, SignalMACD, PRICE_CLOSE, MODE_SIGNAL, i + 1 );

 

double macd_main_0 = iMACD( NULL, 0, FastMACD, SlowMACD, SignalMACD, PRICE_CLOSE, MODE_MAIN, i );

double macd_main_1 = iMACD( NULL, 0, FastMACD, SlowMACD, SignalMACD, PRICE_CLOSE, MODE_MAIN, i + 1 );

 

 

// Green arrow - MACD < 0 and crossed signal from below to above

 

if ( ( macd_main_0 < 0 ) && ( ( macd_main_1 < macd_signal_1 ) && ( macd_main_0 > macd_signal_0 ) ) )

ExtMapBuffer1 = Low - space * my_Point;

else

ExtMapBuffer1 = 0;

 

 

// Red arrow - MACD > 0 and crossed signal from above to below

 

if ( ( macd_main_0 > 0 ) && ( ( macd_main_1 > macd_signal_1 ) && ( macd_main_0 < macd_signal_0 ) ) )

ExtMapBuffer2 = High + space * my_Point;

else

ExtMapBuffer2 = 0;

 

 

// Yellow arrow - MACD < 0 and crossed signal from above to below

 

if ( ( macd_main_0 < 0 ) && ( ( macd_main_1 > macd_signal_1 ) && ( macd_main_0 < macd_signal_0 ) ) )

ExtMapBuffer3 = High + space * my_Point;

else

ExtMapBuffer3 = 0;

 

 

// Yellow arrow - MACD > 0 and crossed signal from below to above

 

if ( ( macd_main_0 > 0 ) && ( ( macd_main_1 < macd_signal_1 ) && ( macd_main_0 > macd_signal_0 ) ) )

ExtMapBuffer4 = Low - space * my_Point;

else

ExtMapBuffer4 = 0;

 

 

 

 

}

return(0);

}

 

 

 

 

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

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...