Dear Ergys1,
Please find the required code below:
var
SIGNAL := 50;
RSI_VAL := RSI(C,8);
SMARSI_VAL := 0;
end_var
SMARSI_VAL:= SMA(RSI_VAL,8);
if( RSI_VAL > SMARSI_VAL and RSI_VAL\1\ < SMARSI_VAL\1\)
then SIGNAL := 100;
else
if (RSI_VAL < SMARSI_VAL and RSI_VAL\1\ > SMARSI_VAL\1\)
then SIGNAL := 0;
return SIGNAL;
Sincerely,
Tradecision Support Team
I need some help to code the following in improvian: I have one RSI and one SMA (period 8 for both) in one indicator window and i need to signal whne RSI crosses the SMA line. I have this code in MQ4 see below however I needed to convert this in improvian.
Any help would be appreciated
Thanks,
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 White
#property indicator_color4 White
#property indicator_color5 White
#property indicator_color6 Green
//---- indicator parameters
extern int RSIPeriod = 8;
extern int RSIMAPeriod = 8;
extern int BandsPeriod=20;
extern int BandsShift=0;
extern double BandsDeviations=2.0;
//---- buffers
double RSI[];
double RSIMA[];
double BBMid[];
double BBUp[];
double BBDn[];
double Signal[];
int i;
int init()
{
IndicatorBuffers(6);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);
SetIndexDrawBegin(0,i-1);
SetIndexBuffer(0, RSI);
SetIndexLabel(0,"RSI");
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID);
SetIndexDrawBegin(1,i-1);
SetIndexBuffer(1, RSIMA);
SetIndexLabel(1,"RSI-MA");
SetIndexStyle(2,DRAW_LINE,STYLE_DOT);
SetIndexDrawBegin(2,i-1);
SetIndexBuffer(2, BBMid);
SetIndexLabel(2,"BB-Mid");
SetIndexStyle(3,DRAW_LINE,STYLE_DOT);
SetIndexDrawBegin(3,i-1);
SetIndexBuffer(3, BBUp);
SetIndexLabel(3,"BB-Up");
SetIndexStyle(4,DRAW_LINE,STYLE_DOT);
SetIndexDrawBegin(4,i-1);
SetIndexBuffer(4, BBDn);
SetIndexLabel(4,"BB-Dn");
SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,1);
SetIndexDrawBegin(5,i-1);
SetIndexBuffer(5, Signal);
SetIndexLabel(5,"Signal");
return(0);
}
int start()
{
i=Bars-BandsPeriod;
while(i>=0) {
RSI = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i);
i--;
}
i=Bars-BandsPeriod;
while(i>=0) {
RSIMA = iMAOnArray(RSI,0,RSIMAPeriod,0,MODE_SMA,i);
i--;
}
i=Bars-BandsPeriod;
while(i>=0) {
BBMid = iMAOnArray(RSIMA,0,BandsPeriod,BandsShift,MODE_SMA,i);
BBUp = iBandsOnArray(RSIMA,0,BandsPeriod,BandsDeviations,BandsShift,MODE_UPPER,i);
BBDn = iBandsOnArray(RSIMA,0,BandsPeriod,BandsDeviations,BandsShift,MODE_LOWER,i);
i--;
}
i=Bars-BandsPeriod;
while(i>=0) {
Signal = 50;
if(RSI>RSIMA && RSI[i+1]<RSIMA[i+1]){
Signal = 100;
} else {
if(RSI<RSIMA && RSI[i+1]>RSIMA[i+1]){
Signal = 0;
}
}
i--;
}
return(0);
}
//+-----------------------------------------------------------------