MACD indicator - page 55

 
mrtools:
Hi Oskay, Made this one, it alerts like the code you posted but no repainting of the arrows and alerts once while the cross is happening(alertsOnCurrent=true) or after the cross has happened(alertsOnCurrent=false).

Thanks MrTools am checking it out already, am very grateful bro.

Thanksssssssss

 
tampa:
Nice version of MACD

that is very nice work but it's so zigzag pls make it perfect

 

MrTool pls kindly . . . OR anyone else.

oskay2012:
Thanks MrTools am checking it out already, am very grateful bro. Thanksssssssss

Thanks for the indicator but i compared the arrow alerts of urs with mine and i noticed that even with the same MACD settings they seem to give some false and unwanted arrow signals and i guessed that its the Bar_Count=20000 that makes the difference (just guessing) so i seem to like my arrow signals better cos am using it not for FOREX but for BINARY OPTIONS, pls kindly add the function or state the function that would correct the alert signal in mine to alert just once.

Thanks in anticipation

CODE TO BE CORRECTED

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

//| MACD Crossover Arrows & Alert |

//| Copyright © 2006 Written by PussyGalore |

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

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 DodgerBlue

#property indicator_width1 3

#property indicator_color2 Magenta

#property indicator_width2 3

extern int MACD_Fast = 20;

extern int MACD_Slow = 62;

extern int MACD_Slowing = 57;

extern int Bars_Count= 20000;

extern string note1 = "Arrow Type";

extern string note2 = "0=Thick, 1=Thin, 2=Hollow, 3=Round";

extern string note3 = "4=Fractal, 5=Diagonal Thin";

extern string note4 = "6=Diagonal Thick, 7=Diagonal Hollow";

extern string note5 = "8=Thumb, 9=Finger";

extern int ArrowType=2;

extern string note6 = "--------------------------------------------";

extern string note7 = "turn on Alert = true; turn off = false";

extern bool AlertOn = true;

extern string note8 = "--------------------------------------------";

extern string note9 = "send Email Alert = true; turn off = false";

extern bool SendAnEmail=false;

double CrossUp[];

double CrossDown[];

string AlertPrefix, MA1short_name, MA2short_name;

string GetTimeFrameStr() {

switch(Period())

{

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

case 5 : TimeFrameStr="M5"; break;

case 15 : TimeFrameStr="M15"; break;

case 30 : TimeFrameStr="M30"; break;

case 60 : TimeFrameStr="H1"; break;

case 240 : TimeFrameStr="H4"; break;

case 1440 : TimeFrameStr="D1"; break;

case 10080 : TimeFrameStr="W1"; break;

case 43200 : TimeFrameStr="MN1"; break;

default : TimeFrameStr=Period();

}

return (TimeFrameStr);

}

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

if (ArrowType == 0) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 233);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 234);

}

else if (ArrowType == 1) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 225);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 226);

}

else if (ArrowType == 2) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 241);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 242);

}

else if (ArrowType == 3) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 221);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 222);

}

else if (ArrowType == 4) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 217);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 218);

}

else if (ArrowType == 5) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 228);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 230);

}

else if (ArrowType == 6) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 236);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 238);

}

else if (ArrowType == 7) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 246);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 248);

}

else if (ArrowType == 8) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 67);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 68);

}

else if (ArrowType == 9) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 71);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 72);

}

SetIndexBuffer(0, CrossUp);

SetIndexBuffer(1, CrossDown);

AlertPrefix=Symbol()+" ("+GetTimeFrameStr()+"): ";

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

bool NewBar()

{

static datetime lastbar;

datetime curbar = Time[0];

if(lastbar!=curbar)

{

lastbar=curbar;

return (true);

}

else

{

return(false);

}

}

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

//| Custom indicator iteration function |

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

int start() {

int limit, i, counter;

double macdnow, macd_signow, macdprevious, macd_sigprevious, macdafter, macd_sigafter;

double Range, AvgRange;

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;

for(i = 0; i <= limit; i++) {

counter=i;

Range=0;

AvgRange=0;

for (counter=i ;counter<=i+9;counter++)

{

AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);

}

Range=AvgRange/10;

macdnow = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow, MACD_Slowing, PRICE_CLOSE, MODE_MAIN, i);

macdprevious = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow, MACD_Slowing, PRICE_CLOSE, MODE_MAIN, i+1);

macdafter = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow, MACD_Slowing, PRICE_CLOSE, MODE_MAIN, i-1);

macd_signow = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow, MACD_Slowing, PRICE_CLOSE, MODE_SIGNAL, i);

macd_sigprevious = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow, MACD_Slowing, PRICE_CLOSE, MODE_SIGNAL, i+1);

macd_sigafter = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow, MACD_Slowing, PRICE_CLOSE, MODE_SIGNAL, i-1);

if ((macdnow > macd_signow) && (macdprevious macd_sigafter)) {

CrossUp = Low - Range*1.5;

if (AlertOn && NewBar()) {

Alert(AlertPrefix + "UPZONE 4 MACD Bcos ("+MACD_Fast+","+MACD_Slow+","+MACD_Slowing+") crosses UP");

}

if (SendAnEmail && NewBar()) {

SendMail(AlertPrefix, "UPZONE 4 MACD Bcos ("+MACD_Fast+","+MACD_Slow+","+MACD_Slowing+") crosses UP");

}

}

else if ((macdnow macd_sigprevious) && (macdafter < macd_sigafter)) {

CrossDown = High + Range*1.5;

if (AlertOn && NewBar()) {

Alert(AlertPrefix + "DOWNZONE 4 MACD Bcos ("+MACD_Fast+","+MACD_Slow+","+MACD_Slowing+") crosses DOWN");

}

if (SendAnEmail && NewBar()) {

SendMail(AlertPrefix, "DOWNZONE 4 MACD Bcos ("+MACD_Fast+","+MACD_Slow+","+MACD_Slowing+") crosses DOWN");

}

}

}

return(0);

}

 
oskay2012:
Thanks MrTools am checking it out already, am very grateful bro. Thanksssssssss

Thanks MrTool once again, i just want to add that there are some functions in mine that seem to be different with the one you gave to me bcos even with the same MACD SETTING there seems to be some false and unwanted arrow signals so pls i would like you to or anyone to pls just add the Alert once function to the original code, thats all i need cos am not trading FOREX directly am using the signals it on BINARY OPTIONS.

Thanks in anticipation.

 
mladen:
This would be it then
Have a nice weekend

This is great, thank you. Is it possible to restrict number of bars shown/calculated (like limit bars to 200 or something) to save some processing power.

In backtesting I am ok to see as far back as possible but in realtime I only need last few days of bars.

Thank you again, I really admire your generosity in giving up time to do this for everyone and everyone should be really grateful for what you do.

PG

 

...

pgtips,

No need to limit it : in 99.99% of cases it calculates only the 3 last bars (it could be make to calculate less, but I prefer to be sure hence the 3 bars calculation) so it is not adding any significant burden to CPU usage

pgtips:
This is great, thank you. Is it possible to restrict number of bars shown/calculated (like limit bars to 200 or something) to save some processing power.

In backtesting I am ok to see as far back as possible but in realtime I only need last few days of bars.

Thank you again, I really admire your generosity in giving up time to do this for everyone and everyone should be really grateful for what you do.

PG
 
oskay2012:
Thanks MrTool once again, i just want to add that there are some functions in mine that seem to be different with the one you gave to me bcos even with the same MACD SETTING there seems to be some false and unwanted arrow signals so pls i would like you to or anyone to pls just add the Alert once function to the original code, thats all i need cos am not trading FOREX directly am using the signals it on BINARY OPTIONS. Thanks in anticipation.

Oskay2012,

In your code the macdafter = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow, MACD_Slowing, PRICE_CLOSE, MODE_MAIN, i-1);

and the

macd_sigafter = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow, MACD_Slowing, PRICE_CLOSE, MODE_SIGNAL, i-1);

the i-1, best way to describe it is the indicator is looking to the future that is not there, its looking and making decisions on price that isn't there, so sorry to say not able to help you there, this one repaints and sometimes disappears. Posting a picture with both having the same settings, the aqua and magenta arrows is from the code you posted, as you can see on the last arrow, the one you posted is 1 bar faster now as time goes on the arrow will either line up with the green and red, or have even seen them disappear.Hopefully you'll find someone to help!!

Files:
macd_2.gif  40 kb
 

I am not a coder of it, but what does "pls make it perfect" mean? That is a MACD shown in one way, so it is a "perfect MACD"

lion of gail:
that is very nice work but it's so zigzag pls make it perfect
 

Please can some have a look at the alerts on this Osma, as they rarely ever alert, and sometimes just alert the wrong way

ideally if the indi can alert once and every time the up and down histo bars cross the zero line, but in real time not after a bar close

and if the other up / down alert can be fixed aswell i would be very grateful

i've tried to it sort out and have found many similar versions on the net - but none seem to work properly

here's a couple of the ones found - both almost the same

although would prefer if Osma(2) can be fixed (if possible)

as its had the long numbers in window removed already

Thanks very much

osma4colorhist_alert_la.mq4

macd_osmaonly_4colorhistm_alert2.mq4

 
mladen:
pgtips, No need to limit it : in 99.99% of cases it calculates only the 3 last bars (it could be make to calculate less, but I prefer to be sure hence the 3 bars calculation) so it is not adding any significant burden to CPU usage

I see.

Thank you again

Reason: