Arrow indicator don't work! - page 2

 
pgforex:

Hello, I tried to modify an indicator with my parameters. I want an up arrow when MACD < 0 and become greater than 0 and vise versa. Sorry for the delay (3 years) but I just saw your post.


I juste modify iMA with my iMACD. Now there's any arrow on the chart.


Thank's

pgforex

Your problem is primarily in the iMACD() routines. See below and use and, if you want, repost. I made a few modifications--nothing substantial. I hope you like them and don't mind.

//+------------------------------------------------------------------+
//|                                                  MACD_Signal.mq4 |
//|                      Copyright © 2009, Pascal Gignac             |
//|                                                                  |
//+------------------------------------------------------------------+
 
#property copyright "Copyright © 2009, Pascal Gignac"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red

extern int Period1 = 5, Period2 = 10, BarsBack = 288, StopLevel = 8;

double CrossUp[], CrossDown[], Stops;

int init()
{
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 233);
   
   SetIndexBuffer(1, CrossDown);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 234);
   
   Stops = StopLevel * 0.0001;
   
   return(0);
}

int start()
{
   int limit = MathMin(Bars, BarsBack);
   
   for(int i = limit; i >= 0; i--)
   {
      double MacdLine = iMACD(NULL,0, Period1, Period2, 4, PRICE_CLOSE, MODE_MAIN, i);
      double SignalLine = iMACD(NULL,0,Period1, Period2, 4, PRICE_CLOSE, MODE_SIGNAL,i);
           
      if ((MacdLine < 0.0000) && (SignalLine > 0.0000)) CrossUp[i] = Low[i] - Stops;
      else if ((MacdLine > 0.0000) && (SignalLine < 0.0000)) CrossDown[i] = High[i] + Stops;
   }
   return(0);
}
 
garyhamon:

Your problem is primarily in the iMACD() routines. See below and use and, if you want, repost. I made a few modifications--nothing substantial. I hope you like them and don't mind.

Before posting please read some of the other threads . . . then you would have seen numerous requests like this one:

Please use this to post code . . . it makes it easier to read.


Why are you replying to a thread that is almost 3 years old ?
Reason: