//+------------------------------------------------------------------+ //| Fervent Forex Signal Bars.mq4 | //| Fervent Forex | //| landonbarnard@gmail.com | //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_minimum 1.0 #property indicator_maximum 4.0 #property indicator_buffers 7 extern int Fast_Mom_MA_Period= 12; extern int Slow_Mom_MA_Period= 96; extern int Fast_Trend_MA_Period= 5; extern int Slow_Trend_MA_Period= 8; extern int StdDev_Period= 12; extern bool StdDev_Limit= 0.0006; //---- extern int Bar_Wingdings = 0; extern int Bar_Width = 0; extern color Bar_Color_Up = MediumSpringGreen; extern color Bar_Color_Down = FireBrick; //---- extern double Gap = 0.6; extern double Vertical_Shift = 0.5; extern int Horizontal_Shift= 20; //---- extern color Text_Color_Up = DeepSkyBlue; extern color Text_Color_Down= Red; //---- extern int Position_1 = 4; extern int Position_2 = 3; extern int Position_3 = 2; extern int Position_4 = 1; //---- double Mom[]; double Momentum_Bull[]; double Momentum_Bear[]; double Trend_Bull[]; double Trend_Bear[]; double High_Volatility[]; double Low_Volatility[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexStyle (0, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Up); SetIndexStyle (1, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Down); SetIndexStyle (2, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Up); SetIndexStyle (3, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Down); SetIndexStyle (4, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Up); SetIndexStyle (4, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Down); SetIndexArrow (0, 167); SetIndexArrow (1, 167); SetIndexArrow (2, 167); SetIndexArrow (3, 167); SetIndexArrow (4, 167); SetIndexArrow (5, 167); SetIndexBuffer(0, Momentum_Bull); SetIndexBuffer(1, Momentum_Bear); SetIndexBuffer(2, Trend_Bull); SetIndexBuffer(3, Trend_Bear); SetIndexBuffer(4, High_Volatility); SetIndexBuffer(5, Low_Volatility); SetIndexEmptyValue(0, 0.0); SetIndexEmptyValue(1, 0.0); SetIndexEmptyValue(2, 0.0); SetIndexEmptyValue(3, 0.0); SetIndexEmptyValue(4, 0.0); SetIndexEmptyValue(5, 0.0); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //---- int Counted_Bars = IndicatorCounted(); int i; if(Counted_Bars<0) return(-1); if(Counted_Bars>0) Counted_Bars--; int Limit = Bars - Counted_Bars; //---- for(i=Limit; i>=0; i--) { double MomFastMA=iMA(NULL,0,Fast_Mom_MA_Period,0,MODE_SMA,PRICE_TYPICAL,i); double MomSlowMA=iMA(NULL,0,Slow_Mom_MA_Period,0,MODE_SMA,PRICE_TYPICAL,i); double TrendFastMA=iMA(NULL,0,Fast_Trend_MA_Period,0,MODE_SMA,PRICE_CLOSE,i); double TrendSlowMA=iMA(NULL,0,Slow_Trend_MA_Period,0,MODE_SMA,PRICE_CLOSE,i); double StdDev=iStdDev(NULL,0,StdDev_Period,0,MODE_SMA,PRICE_CLOSE,i); Mom[i]=(MomFastMA-MomSlowMA); double Mom_Current=Mom[i]; double Mom_Previous=Mom[i+1]; { Momentum_Bull[i]=EMPTY_VALUE; Momentum_Bear[i]=EMPTY_VALUE; if(Mom_Current>Mom_Previous) Momentum_Bull[i] = Gap * Position_1 + 1.0; else Momentum_Bear[i] = Gap * Position_1 + 1.0; if(TrendFastMA>TrendSlowMA) Trend_Bull[i] = Gap * Position_2 + 1.0; else Trend_Bear[i] = Gap * Position_2 + 1.0; if(StdDev>StdDev_Limit) High_Volatility[i] = Gap * Position_3 + 1.0; else Low_Volatility[i] = Gap * Position_3 + 1.0; } } //---- done return(0); } //+------------------------------------------------------------------+
bump
SetIndexEmptyValue(0, 0.0);
Where you don't want the arrows, set the buffers to the empty value. Most indicators (to be used with EA's) don't use SetIndexEmptyValue. They just set the buffer to EMPTY_VALUE.
You're not setting the empty, so if an average moves up and then down you'll get both arrays set.
bump
Where you don't want the arrows, set the buffers to the empty value. Most indicators (to be used with EA's) don't use SetIndexEmptyValue. They just set the buffer to EMPTY_VALUE.
You're not setting the empty, so if an average moves up and then down you'll get both arrays set.
thanks that fixed a lot of problems !
i still have an issue with the momentum_bull and momentum_bear buffers not changing when momentum changes ... any ideas ?
sorry WHRoeder
need to bump
Momentum_Bull[i]=EMPTY_VALUE; Momentum_Bear[i]=EMPTY_VALUE;Either set them all to EMPTY_VALUE and don't use
SetIndexEmptyValueor set them to the SetIndexEmptyValue's value.
Either set them all to EMPTY_VALUE and don't use or set them to the SetIndexEmptyValue's value.
like this?
now it is only showing the calculations for the previous three bars... (sigh)
and the momentum part still isn't changing...
//+------------------------------------------------------------------+ //| Fervent Forex Signal Bars.mq4 | //| Fervent Forex | //| landonbarnard@gmail.com | //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_minimum 1.0 #property indicator_maximum 4.0 #property indicator_buffers 8 extern int Fast_Mom_MA_Period= 12; extern int Slow_Mom_MA_Period= 96; extern int Fast_Trend_MA_Period= 5; extern int Slow_Trend_MA_Period= 8; extern int StdDev_Period= 12; extern double StdDev_Limit= 0.0006; extern int ATR_Period=12; extern int FFRI_MA_Period=24; //---- extern int Bar_Wingdings = 0; extern int Bar_Width = 0; extern color Bar_Color_Up = MediumSpringGreen; extern color Bar_Color_Down = FireBrick; //---- extern double Gap = 0.6; extern double Vertical_Shift = 0.5; extern int Horizontal_Shift= 20; //---- extern color Text_Color_Up = DeepSkyBlue; extern color Text_Color_Down= Red; //---- extern int Position_1 = 4; extern int Position_2 = 3; extern int Position_3 = 2; extern int Position_4 = 1; //---- double Mom[]; double Momentum_Bull[]; double Momentum_Bear[]; double Trend_Bull[]; double Trend_Bear[]; double High_Volatility[]; double Low_Volatility[]; double Extended[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexStyle (0, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Up); SetIndexStyle (1, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Down); SetIndexStyle (2, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Up); SetIndexStyle (3, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Down); SetIndexStyle (4, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Up); SetIndexStyle (5, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Down); SetIndexStyle (6, DRAW_ARROW, STYLE_SOLID, Bar_Width, Bar_Color_Up); SetIndexArrow (0, 167); SetIndexArrow (1, 167); SetIndexArrow (2, 167); SetIndexArrow (3, 167); SetIndexArrow (4, 167); SetIndexArrow (5, 167); SetIndexArrow (6, 167); SetIndexBuffer(0, Momentum_Bull); SetIndexBuffer(1, Momentum_Bear); SetIndexBuffer(2, Trend_Bull); SetIndexBuffer(3, Trend_Bear); SetIndexBuffer(4, High_Volatility); SetIndexBuffer(5, Low_Volatility); SetIndexBuffer(6, Extended); SetIndexEmptyValue (0, 0.0); SetIndexEmptyValue (1, 0.0); SetIndexEmptyValue (2, 0.0); SetIndexEmptyValue (3, 0.0); SetIndexEmptyValue (4, 0.0); SetIndexEmptyValue (5, 0.0); SetIndexEmptyValue (6, 0.0); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //---- int Counted_Bars = IndicatorCounted(); int i; if(Counted_Bars<0) return(-1); if(Counted_Bars>0) Counted_Bars--; int Limit = Bars - Counted_Bars; //---- for(i=Limit; i>=0; i--) { double Close1=(Close[i]); double MomFastMA=iMA(NULL,0,Fast_Mom_MA_Period,0,MODE_SMA,PRICE_TYPICAL,i); double MomSlowMA=iMA(NULL,0,Slow_Mom_MA_Period,0,MODE_SMA,PRICE_TYPICAL,i); double TrendFastMA=iMA(NULL,0,Fast_Trend_MA_Period,0,MODE_SMA,PRICE_CLOSE,i); double TrendSlowMA=iMA(NULL,0,Slow_Trend_MA_Period,0,MODE_SMA,PRICE_CLOSE,i); double StdDev=iStdDev(NULL,0,StdDev_Period,0,MODE_SMA,PRICE_CLOSE,i); double ATR=iATR(NULL,0,ATR_Period,i); double FFRIMA=iMA(NULL,0,FFRI_MA_Period,0,MODE_SMA,PRICE_CLOSE,i); double FFRI=((Close1-FFRIMA)/ATR); Mom[i]=(MomFastMA-MomSlowMA); double Mom_Current=Mom[i]; double Mom_Previous=Mom[i+1]; { if(Mom_Current > Mom_Previous) Momentum_Bull[i] = Gap * Position_1 + 1.0; else Momentum_Bear[i] = Gap * Position_1 + 1.0; if(TrendFastMA > TrendSlowMA) Trend_Bull[i] = Gap * Position_2 + 1.0; else Trend_Bear[i] = Gap * Position_2 + 1.0; if(StdDev > StdDev_Limit) High_Volatility[i] = Gap * Position_3 + 1.0; else Low_Volatility[i] = Gap * Position_3 + 1.0; } } //---- done return(0); } //+------------------------------------------------------------------+
Either set them all to EMPTY_VALUE and don't use or set them to the SetIndexEmptyValue's value.
What part of all didn't you understand. Where so you set
SetIndexBuffer(0, Momentum_Bull); SetIndexBuffer(1, Momentum_Bear); SetIndexBuffer(2, Trend_Bull); SetIndexBuffer(3, Trend_Bear); SetIndexBuffer(4, High_Volatility); SetIndexBuffer(5, Low_Volatility); SetIndexBuffer(6, Extended);
to zero?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Fellas,
I am still trying to learn how to program simple indicators to simplify my charts, i have had a few successes but mostly failure, below is an indicator I was developing to display several different indicators i use. I cant get it to work properly... I would much appreciate some guidance. Thanks in advance for your help.