hello @jeanlouie. I have this indicator that plots arrows on the chart. it works perfectly fine. I just want to adjust it so that it gives arrows in a certain sequence. i.e. when it gives an arrow, it skips the next three arrows and plots the fourth arrow.
//compile//
//+------------------------------------------------------------------+
//| CandleSizeAlert.mq4 |
//| Copyright Robert Hill |
//| |
//| Will send alert when a candle meets the size criteria entered |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LawnGreen
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
extern bool AlertON=true;
extern int CandleSize = 100;
double Bull[];
double Bear[];
int flagval1 = 0;
int flagval2 = 0;
double myPoint;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
// IndicatorBuffers(5);
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 233);
SetIndexBuffer(0, Bull);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 234);
SetIndexBuffer(1, Bear);
myPoint = SetPoint(Symbol());
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
double myOpen, myClose, myDif, spread;
int limit, i, counter;
double tmp=0;
double Range, AvgRange;
datetime tc;
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;
myOpen = iOpen(NULL, 0, i);
myClose = iClose(NULL, 0, i);
myDif = NormalizeDouble(MathAbs(myOpen - myClose) / myPoint, 6);
spread = Ask-Bid;
Bull[i] = 0;
Bear[i] = 0;
// if (spread<28)
{
if (myDif > CandleSize)
{
if (myOpen > myClose)
{
if (i == 0 && flagval1==0)
{
flagval1=1;
flagval2=0;
tc = TimeCurrent();
if (AlertON) Alert("Large BEAR candle","\n Time=",TimeToStr(tc,TIME_DATE)," ",TimeHour(tc),":",TimeMinute(tc),"\n Symbol=",Symbol()," Period=",Period());
}
Bear[i] = High[i] + Range*0.75;
}
else if (myOpen < myClose)
{
if (i == 0 && flagval2==0)
{
flagval2=1;
flagval1=0;
tc = TimeCurrent();
if (AlertON) Alert("Large Bull candle","\n Date=",TimeToStr(tc,TIME_DATE)," ",TimeHour(tc),":",TimeMinute(tc),"\n Symbol=",Symbol()," Period=",Period());
}
Bull[i] = Low[i] - Range*0.75;
}
}
}
}
return(0);
}
double SetPoint(string mySymbol)
{
double mPoint, myDigits;
myDigits = MarketInfo (mySymbol, MODE_DIGITS+2);
if (myDigits < 7)
mPoint = 0.00001;
else
mPoint = 0.0001;
return(mPoint);
}
//compile//
//+------------------------------------------------------------------+
//| CandleSizeAlert.mq4 |
//| Copyright Robert Hill |
//| |
//| Will send alert when a candle meets the size criteria entered |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LawnGreen
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
extern bool AlertON=true;
extern int CandleSize = 100;
double Bull[];
double Bear[];
int flagval1 = 0;
int flagval2 = 0;
double myPoint;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
// IndicatorBuffers(5);
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 233);
SetIndexBuffer(0, Bull);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 234);
SetIndexBuffer(1, Bear);
myPoint = SetPoint(Symbol());
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
double myOpen, myClose, myDif, spread;
int limit, i, counter;
double tmp=0;
double Range, AvgRange;
datetime tc;
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;
myOpen = iOpen(NULL, 0, i);
myClose = iClose(NULL, 0, i);
myDif = NormalizeDouble(MathAbs(myOpen - myClose) / myPoint, 6);
spread = Ask-Bid;
Bull[i] = 0;
Bear[i] = 0;
// if (spread<28)
{
if (myDif > CandleSize)
{
if (myOpen > myClose)
{
if (i == 0 && flagval1==0)
{
flagval1=1;
flagval2=0;
tc = TimeCurrent();
if (AlertON) Alert("Large BEAR candle","\n Time=",TimeToStr(tc,TIME_DATE)," ",TimeHour(tc),":",TimeMinute(tc),"\n Symbol=",Symbol()," Period=",Period());
}
Bear[i] = High[i] + Range*0.75;
}
else if (myOpen < myClose)
{
if (i == 0 && flagval2==0)
{
flagval2=1;
flagval1=0;
tc = TimeCurrent();
if (AlertON) Alert("Large Bull candle","\n Date=",TimeToStr(tc,TIME_DATE)," ",TimeHour(tc),":",TimeMinute(tc),"\n Symbol=",Symbol()," Period=",Period());
}
Bull[i] = Low[i] - Range*0.75;
}
}
}
}
return(0);
}
double SetPoint(string mySymbol)
{
double mPoint, myDigits;
myDigits = MarketInfo (mySymbol, MODE_DIGITS+2);
if (myDigits < 7)
mPoint = 0.00001;
else
mPoint = 0.0001;
return(mPoint);
}