In this screenshot there is a Buy signal at 11.13+ three more Buy signals before there is a Sell signal at 12.05. I need a way of not allowing the second, third and fourth Buy signal and only allow a Sell signal at 12.05
I'm not a newbie by any stretch. This one looked easy enough but I'm coming up empty.
Code: Select all
//+------------------------------------------------------------------+
//| AdvancedFractals.mq4 |
//| Copyright © 2012, Gehtsoft USA LLC |
//| http://fxcodebase.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, Gehtsoft USA LLC"
#property link "http://fxcodebase.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 LimeGreen
extern int Frames=2;
double ExtUpFractalsBuffer[];
double ExtDownFractalsBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator buffers mapping
SetIndexBuffer(0,ExtUpFractalsBuffer);
SetIndexBuffer(1,ExtDownFractalsBuffer);
//---- drawing settings
SetIndexStyle(0,DRAW_ARROW,0,2);
SetIndexArrow(0,234);
SetIndexStyle(1,DRAW_ARROW,0,2);
SetIndexArrow(1,233);
//----
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
//---- name for DataWindow
SetIndexLabel(0,"Fractal Up");
SetIndexLabel(1,"Fractal Down");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i,nCountedBars;
bool bFound;
double dCurrent;
nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted
if(nCountedBars<=2)
i=Bars-nCountedBars-3;
if(nCountedBars>2)
{
nCountedBars--;
i=Bars-nCountedBars-1;
}
while(i>=Frames+1)
{
bool FrUp=true;
bool FrDn=true;
int ii;
for (ii=1;ii<=Frames;ii++)
{
if (High[i+ii]>=High[i] || High[i-ii]>=High[i]) FrUp=false;
if (Low[i+ii]<=Low[i] || Low[i-ii]<=Low[i]) FrDn=false;
}
//----Fractals up
if (FrUp)
{
ExtUpFractalsBuffer[i]=High[i];
}
//----Fractals down
if (FrDn)
{
ExtDownFractalsBuffer[i]=Low[i];
}
i--;
}
return(0);
}