static int LastDirection = 0;
if( you want to draw an UP ){
if(LastDirection == -1 || LastDirection == 0){
draw up arrow;
LastDirection = 1;
}
}
if( you want to draw a DOWN ){
if(LastDirection == 1 || LastDirection == 0){
draw down arrow;
LastDirection = -1;
}
}
static int LastDirection = 0;
if( you want to draw an UP ){
if(LastDirection == -1 || LastDirection == 0){
draw up arrow;
LastDirection = 1;
}
}
if( you want to draw a DOWN ){
if(LastDirection == 1 || LastDirection == 0){
draw down arrow;
LastDirection = -1;
}
}
Hi, thanks for your reply.
I've included the code for the indicator below. Would you be able to make amendments accordingly?
//+------------------------------------------------------------------+
//| Indicator.mq4 |
//| GGekko |
//| |
//+------------------------------------------------------------------+
#property copyright "GGekko"
#property link ""
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Orange
#property indicator_width1 1
#property indicator_width2 1
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
int bullishcount=0;
int bearishcount=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,233);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,EMPTY_VALUE);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,234);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(1,EMPTY_VALUE);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(int i=0; i<limit; i++)
{
if(Close[i]>High[i+1]) ExtMapBuffer1[i]=Low[i];
else ExtMapBuffer1[i]=EMPTY_VALUE;
}
for(i=0; i<limit; i++)
{
if(Close[i]<Low[i+1]) ExtMapBuffer2[i]=High[i];
else ExtMapBuffer2[i]=EMPTY_VALUE;
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
Thanks,
Fred
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I was hoping that someone could assist me with tweaking the following code. I've manipulated code originally posted by GGekko - for which I'm very grateful.
I've included a chart for your information. The BLUE ARROWS are marking candles that are CLOSING HIGHER THAN THE PREVIOUS HIGH. The ORANGE ARROWS are marking those candles that are CLOSING LOWER THAN THE PREVIOUS LOW. The custom indicator should only mark the first HIGHER CLOSING HIGH or LOWER CLOSING LOW in a sequence. I've highlighted the arrows accordingly.
Any assistance would be greatly appreciated.
Fred