Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Candle Signal
//+------------------------------------------------------------------+
//| Candle Signal.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright "Bryant"
#property link "youngwarm@live.cn"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_width1 3
#property indicator_width2 3
//---- input parameters
extern double FastMA=12;
extern double SlowMA=26;
extern double SMA =9;
extern int MacdPrevious=5;
extern bool alerton= false;
//---- buffers
double Up[];
double Down[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
//---- indicator buffers
SetIndexBuffer(0,Up);
SetIndexBuffer(1,Down);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,67);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,68);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
SetIndexLabel(0,"Up");
SetIndexLabel(1,"Down");
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("Candle Signal");
return(0);
}
int start()
{
int limit = Bars- IndicatorCounted(),i;
double body,length,macd;
for ( i=limit ; i>=0; i--)
{
body=MathAbs(Close[i]-Open[i]);
length=(High[i]-Low[i])/2;
macd=iMACD(NULL,0,FastMA,SlowMA,SMA,0,0,i+MacdPrevious);
Up[i]=EMPTY_VALUE;
Down[i]=EMPTY_VALUE;
if( body<=length&&macd>0&&High[i]>High[i+1]&&Low[i]>Low[i+1])Up[i]=Low[i];
if( body<=length&&macd<0&&High[i]<High[i+1]&&Low[i]<Low[i+1])Down[i]=High[i];
}
for(i=limit; i>=1; i--)
{
if(Up[i]==Low[i]&&alerton==true)
{
Alert("Buy Signal Showed Up Last Bar!!!");
break;
}
if(Down[i]==High[i]&&alerton==true)
{
Alert("Sell Signal Showed Up Last Bar!!!");
break;
}
}
}
return(0);
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---