Indicators Used
0
Views
0
Downloads
0
Favorites
iCFMA
ÿþ//+------------------------------------------------------------------+
//| iCFMA.mq4 |
//| Alex_Shmatko |
//+------------------------------------------------------------------+
#property copyright "Alex_Shmatko"
#property link ""
#property version "2.10"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 clrRed
#property indicator_color2 clrMediumSlateBlue
#property indicator_color3 clrRed
#property indicator_color4 clrMediumSlateBlue
//+------------------------------------------------------------------+
//| input parameters |
//+------------------------------------------------------------------+
input int Cluster_MA_period = 80; // Cluster Moving Average Period
input color Bars_SELL = clrRed; // Color bar SELL
input color Bars_BUY = clrMediumSlateBlue; // Color bar BUY
//---
//+------------------------------------------------------------------+
//| variables |
//+------------------------------------------------------------------+
double ibuf_thin_SELL[]; // The SELL thin line buffer
double ibuf_thin_BUY[]; // Buffer of a thin line BUY
double ibuf_bar_SELL[]; // Buffer of thick line SELL
double ibuf_bar_BUY[]; // Buffer of a thick line BUY
double iMA_CLOSE;
double iMA_LOW;
double iMA_OPEN;
double iMA_HIGH;
double up_bound_bar_SELL;
double up_bound_ind;
double lo_bound_ind;
double up_bound_bar_BUY;
int i;
//---
//+------------------------------------------------------------------+
//| Initialization indicator |
//+------------------------------------------------------------------+
int OnInit()
{
//+------------------------------------------------------------------+
//| Initialization the indicator buffers |
//+------------------------------------------------------------------+
SetIndexStyle (0, DRAW_HISTOGRAM, STYLE_SOLID, 1, Bars_SELL); // thin SELL
SetIndexBuffer(0, ibuf_thin_SELL); // thin SELL
SetIndexStyle (1, DRAW_HISTOGRAM, STYLE_SOLID, 1, Bars_BUY); // thin BUY
SetIndexBuffer(1, ibuf_thin_BUY); // thin BUY
SetIndexStyle (2, DRAW_HISTOGRAM, STYLE_SOLID, 2, Bars_SELL); // bar SELL
SetIndexBuffer(2, ibuf_bar_SELL); // bar SELL
SetIndexStyle (3, DRAW_HISTOGRAM, STYLE_SOLID, 2, Bars_BUY); // bar BUY
SetIndexBuffer(3, ibuf_bar_BUY); // bar BUY
//---
return(INIT_SUCCEEDED);
}
//---
//+------------------------------------------------------------------+
//| The body of the indicator |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
i = rates_total - prev_calculated - 2;
if(i < 0) i = 0;
while(i >= 0)
{
/*double iMA(
string symbol, //
int timeframe, //
string name_of_the_indicator, //
int CLUSTER_ma_period, //
int price_type, // 1 - PRICE_OPEN, 2 - PRICE_HIGH, 3 - PRICE_LOW, 4 - PRICE_CLOSE
int ma_type, // 0 - SMA, 1 - EMA, 2 - CLUSTERFilter
int shift //
);*/
iMA_OPEN = iCustom(NULL, 0, "ClusterFilter_ch_price", Cluster_MA_period, 1, 2, i);
iMA_HIGH = iCustom(NULL, 0, "ClusterFilter_ch_price", Cluster_MA_period, 2, 2, i);
iMA_LOW = iCustom(NULL, 0, "ClusterFilter_ch_price", Cluster_MA_period, 3, 2, i);
iMA_CLOSE = iCustom(NULL, 0, "ClusterFilter_ch_price", Cluster_MA_period, 4, 2, i);
up_bound_bar_SELL = (ibuf_bar_SELL[i + 1] + ibuf_bar_BUY[i + 1]) / 2; // The upper limit of the thick SELL lines
up_bound_bar_BUY = (iMA_CLOSE + iMA_LOW + iMA_OPEN + iMA_HIGH) / 4; // The upper limit of thick lines BUY
up_bound_ind = MathMax(iMA_HIGH, MathMax(up_bound_bar_SELL, up_bound_bar_BUY)); // The upper limit of the indicator
lo_bound_ind = MathMin(iMA_OPEN, MathMin(up_bound_bar_SELL, up_bound_bar_BUY)); // The lower limit of the indicator
if(up_bound_bar_SELL < up_bound_bar_BUY)
{
ibuf_thin_SELL[i] = lo_bound_ind; // thin SELL
ibuf_thin_BUY[i] = up_bound_ind; // thin BUY
}else
{
ibuf_thin_SELL[i] = up_bound_ind; // thin SELL
ibuf_thin_BUY[i] = lo_bound_ind; // thin BUY
}
ibuf_bar_SELL[i] = up_bound_bar_SELL; // bar SELL
ibuf_bar_BUY[i] = up_bound_bar_BUY; // bar BUY
i--;
}
//---
return(rates_total);
}
//---
//---
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
---