Hi , hope someone can help here. I tried a simple solution of using globalvaribles to try and get 0,-1,1 values from this simple indicator which would be fine but i does not work? In the indicator data window it shows fine when you hover over candle but it only shows 0 in global variable even if it should say 1 or -1. If someone can work out why great that will be dandy.
I then tried to call the value using the icustom (not used it before) i thought it would be simple as there are no inputs and just 3 buffers but i could not get it to work either so if you can help it would be great. Below is the indicator code the indicator is called swingindicator
thank you
#property indicator_separate_window
#property indicator_minimum -1
#property indicator_maximum 1
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Lime
#property indicator_color3 SlateGray
extern color SPlow = Lime;
extern color SPhigh = Red;
extern color ZeroLine = SlateGray;
extern int MarkerWidth = 3;
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,MarkerWidth,SPlow);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,MarkerWidth,SPhigh);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE,EMPTY,1,ZeroLine);
SetIndexBuffer(2,ExtMapBuffer3);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i;
bool c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18;
//----
for(i=0;i<counted_bars;i++){
// detection of a standard SP High
c1 = High[i+2]>High[i];
c2 = High[i+2]>High[i+1];
c3 = High[i+2]>High[i+3];
c4 = High[i+2]>High[i+4];
// detection of a SP High with 2 equal middle highs
c5 = High[i+2]==High[i+3];
c6 = High[i+2]>High[i+0];
c7 = High[i+2]>High[i+1];
c8 = High[i+2]>High[i+4];
c9 = High[i+2]>High[i+5];
//detection of a standard SP Low
c10 = Low[i+2]<Low[i+0];
c11 = Low[i+2]<Low[i+1];
c12 = Low[i+2]<Low[i+3];
c13 = Low[i+2]<Low[i+4];
// detection of a SP Low with 2 equal middle lows
c14 = Low[i+2]==Low[i+3];
c15 = Low[i+2]<Low[i+0];
c16 = Low[i+2]<Low[i+1];
c17 = Low[i+2]<Low[i+4];
c18 = Low[i+2]<Low[i+5];
int a=0;
if(c1 && c2 && c3 && c4) a=+1;
if(a==0 && c5 && c6 && c7 && c8 && c9) a=+1;
if(a==0 && c10 && c11 && c12 && c13) a=-1;
if(a==0 && c14 && c15 && c16 && c17 && c18) a=-1;
if(a== -1)GlobalVariableSet(Symbol()+"SP",-1);
if(a== 1)GlobalVariableSet(Symbol()+"SP",1);
if(a== 0)GlobalVariableSet(Symbol()+"SP",0);
if(a== -1) ExtMapBuffer1[i]=-1;
if(a== -1) ExtMapBuffer1[i]=-1;
if(a== 1) ExtMapBuffer2[i]= 1;
if(a== 0) {
ExtMapBuffer2[i]=EMPTY_VALUE;
ExtMapBuffer1[i]=EMPTY_VALUE;
}
ExtMapBuffer3[i]=0;
}
//----
return(0);
}
//+------------------------------------------------------------------+
I then tried to call the value using the icustom (not used it before) i thought it would be simple as there are no inputs and just 3 buffers but i could not get it to work either so if you can help it would be great. Below is the indicator code the indicator is called swingindicator
thank you
#property indicator_separate_window
#property indicator_minimum -1
#property indicator_maximum 1
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Lime
#property indicator_color3 SlateGray
extern color SPlow = Lime;
extern color SPhigh = Red;
extern color ZeroLine = SlateGray;
extern int MarkerWidth = 3;
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,MarkerWidth,SPlow);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,MarkerWidth,SPhigh);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE,EMPTY,1,ZeroLine);
SetIndexBuffer(2,ExtMapBuffer3);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i;
bool c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18;
//----
for(i=0;i<counted_bars;i++){
// detection of a standard SP High
c1 = High[i+2]>High[i];
c2 = High[i+2]>High[i+1];
c3 = High[i+2]>High[i+3];
c4 = High[i+2]>High[i+4];
// detection of a SP High with 2 equal middle highs
c5 = High[i+2]==High[i+3];
c6 = High[i+2]>High[i+0];
c7 = High[i+2]>High[i+1];
c8 = High[i+2]>High[i+4];
c9 = High[i+2]>High[i+5];
//detection of a standard SP Low
c10 = Low[i+2]<Low[i+0];
c11 = Low[i+2]<Low[i+1];
c12 = Low[i+2]<Low[i+3];
c13 = Low[i+2]<Low[i+4];
// detection of a SP Low with 2 equal middle lows
c14 = Low[i+2]==Low[i+3];
c15 = Low[i+2]<Low[i+0];
c16 = Low[i+2]<Low[i+1];
c17 = Low[i+2]<Low[i+4];
c18 = Low[i+2]<Low[i+5];
int a=0;
if(c1 && c2 && c3 && c4) a=+1;
if(a==0 && c5 && c6 && c7 && c8 && c9) a=+1;
if(a==0 && c10 && c11 && c12 && c13) a=-1;
if(a==0 && c14 && c15 && c16 && c17 && c18) a=-1;
if(a== -1)GlobalVariableSet(Symbol()+"SP",-1);
if(a== 1)GlobalVariableSet(Symbol()+"SP",1);
if(a== 0)GlobalVariableSet(Symbol()+"SP",0);
if(a== -1) ExtMapBuffer1[i]=-1;
if(a== -1) ExtMapBuffer1[i]=-1;
if(a== 1) ExtMapBuffer2[i]= 1;
if(a== 0) {
ExtMapBuffer2[i]=EMPTY_VALUE;
ExtMapBuffer1[i]=EMPTY_VALUE;
}
ExtMapBuffer3[i]=0;
}
//----
return(0);
}
//+------------------------------------------------------------------+