Another Newbie here, requesting help

 

I am trying to rewrite the code for the Flattr~2 to work with the RSI and I am getting a "Wrong parameters count" on line 91/82.

The original code is below, followed by my re-write code. Can anyone help, please?


Thanks in advance,


Gordon


Here's the original:

//+------------------------------------------------------------------+
//| FlatTrend.mq4 |
//| Kirk Sloan |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Kirk Sloan"
#property link "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 RoyalBlue
#property indicator_color3 Gold
//---- input parameters
extern int Minutes=0;
extern int MACD_Fast = 12;
extern int MACD_Slow = 26;
extern int MACD_MA = 9;
extern int BarsToCount = 10000;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double Ma;
double hhigh, llow;
double Psar;
double PADX,NADX;
string TimeFrameStr;
double MA1,MA2,MA3;
double MACD_Signal,MACD_Main;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,4,Red);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,4, RoyalBlue);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,4, Gold);
SetIndexBuffer(2,ExtMapBuffer3);

switch(Minutes)
{
case 1 : TimeFrameStr="Period_M1"; break;
case 5 : TimeFrameStr="Period_M5"; break;
case 15 : TimeFrameStr="Period_M15"; break;
case 30 : TimeFrameStr="Period_M30"; break;
case 60 : TimeFrameStr="Period_H1"; break;
case 240 : TimeFrameStr="Period_H4"; break;
case 1440 : TimeFrameStr="Period_D1"; break;
case 10080 : TimeFrameStr="Period_W1"; break;
case 43200 : TimeFrameStr="Period_MN1"; break;
default : TimeFrameStr="Current Timeframe"; Minutes=0;
}
IndicatorShortName("Flat Trend w MACD ("+TimeFrameStr+")");


//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----

for (int i = 0; i < BarsToCount; i++){
ExtMapBuffer1[i]=0;
ExtMapBuffer2[i]=0;
ExtMapBuffer3[i]=0;


MACD_Signal=iMACD(NULL,Minutes,MACD_Fast,MACD_Slow,MACD_MA,PRICE_CLOSE,MODE_SIGNAL,i);
MACD_Main =iMACD(NULL,Minutes,MACD_Fast,MACD_Slow,MACD_MA,PRICE_CLOSE,MODE_MAIN,i);

if(MACD_Signal < MACD_Main && MACD_Main > 0)ExtMapBuffer2[i]=1;
if(MACD_Signal > MACD_Main && MACD_Main < 0)ExtMapBuffer1[i]=1;
if(ExtMapBuffer1[i] == 0 && ExtMapBuffer2[i] == 0)
{ExtMapBuffer3[i] = 1;}

}




//----
return(0);
}
//+------------------------------------------------------------------+


and here's my attempt at the re-write:


//+------------------------------------------------------------------+
//| FlatTrendRSI.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright "Kirk Sloan"
#property link "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 RoyalBlue
#property indicator_color3 Gold
//---- input parameters
extern int Minutes=0;
extern int RSIPeriod = 14;
extern int BarsToCount = 400;
extern int OSLevel = 30;
extern int OBLevel = 70;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double RSIBuffer[];
double PosBuffer[];
double NegBuffer[];
string TimeFrameStr;
double rel;
double negative;
double positive;
double RSI_Main;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,4,Red);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,4, RoyalBlue);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,4, Gold);
SetIndexBuffer(2,ExtMapBuffer3);

switch(Minutes)
{
case 1 : TimeFrameStr="Period_M1"; break;
case 5 : TimeFrameStr="Period_M5"; break;
case 15 : TimeFrameStr="Period_M15"; break;
case 30 : TimeFrameStr="Period_M30"; break;
case 60 : TimeFrameStr="Period_H1"; break;
case 240 : TimeFrameStr="Period_H4"; break;
case 1440 : TimeFrameStr="Period_D1"; break;
case 10080 : TimeFrameStr="Period_W1"; break;
case 43200 : TimeFrameStr="Period_MN1"; break;
default : TimeFrameStr="Current Timeframe"; Minutes=0;
}
IndicatorShortName("Flat Trend w RSI ("+TimeFrameStr+")");


//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----

for (int i = 0; i < BarsToCount; i++){
ExtMapBuffer1[i]=0;
ExtMapBuffer2[i]=0;
ExtMapBuffer3[i]=0;



RSI_Main=iRSI(NULL,Minutes,RSIPeriod,OSLevel,OBLevel,PRICE_CLOSE,MODE_MAIN,i);

if(RSI_Main >= 50 && RSI_Main < OBLevel)ExtMapBuffer2[i]=1;
if(RSI_Main < 50 && RSI_Main >OSLevel)ExtMapBuffer1[i]=1;
if(ExtMapBuffer1[i] == 0 && ExtMapBuffer2[i] == 0)
{ExtMapBuffer3[i] = 1;}

}




//----
return(0);
}
//+------------------------------------------------------------------+

 
sandfire:

I am trying to rewrite the code for the Flattr~2 to work with the RSI and I am getting a "Wrong parameters count" on line 91/82.

The original code is below, followed by my re-write code. Can anyone help, please?


RSI_Main=iRSI(NULL,Minutes,RSIPeriod,OSLevel,OBLevel,PRICE_CLOSE,MODE_MAIN,i);

The line in bold has too many input parameters. The function prototype for iRSA() has only 5 input parameters:

double iRSI( string symbol, int timeframe, int period, int applied_price, int shift)
Please use the SRC button to paste code next time...
Reason: