i wanted to code a Price channel but with buy and sell signals accoridng to RSI MA.
But somehow im not able to get the code running. Can some expert pro coder have a look at it?
//+------------------------------------------------------------------+
//| ATR.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Red
#property indicator_width1 3
#property indicator_width2 3
#property indicator_style1 STYLE_SOLID
#property indicator_style2 STYLE_SOLID
extern string RSI_Source = "Close";
extern int RSI_Period = 14;
extern int RSI_MA_Period = 10;
extern double UpperBandMultiplier = 2.0;
extern double LowerBandMultiplier = 2.0;
extern int NumCandles = 100; // Anzahl der letzten Kerzen für die Berechnung
double ExtMapBufferUpper[];
double ExtMapBufferLower[];
int OnInit()
{
SetIndexBuffer(0, ExtMapBufferUpper);
SetIndexLabel(0, "Upper Channel");
SetIndexBuffer(1, ExtMapBufferLower);
SetIndexLabel(1, "Lower Channel");
return(INIT_SUCCEEDED);
}
int start()
{
int beginIndex = Bars - NumCandles - 1; // Index des ersten Bars für die Berechnung
ArraySetAsSeries(ExtMapBufferUpper, true);
ArraySetAsSeries(ExtMapBufferLower, true);
for (int i = beginIndex; i >= 0; i--)
{
double rsiValue = iRSI(NULL, 0, RSI_Period, RSI_Source, i);
double rsiMA = iMA(NULL, 0, RSI_MA_Period, 0, MODE_SMA, rsiValue, i);
ExtMapBufferUpper[i] = iHigh(NULL, 0, i) + UpperBandMultiplier * rsiMA;
ExtMapBufferLower[i] = iLow(NULL, 0, i) - LowerBandMultiplier * rsiMA;
}
return(0);
}