Tradecision Talks
May 25, 2013, 08:42:05 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Help coding an RSI/SMA cross indicator  (Read 6383 times)
ergys1
Newbie
*
Posts: 4


« on: April 22, 2009, 01:41:19 PM »

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);
  }
 
//+-----------------------------------------------------------------
Logged
Tradecision Support Team
Hero Member
*****
Posts: 336


« Reply #1 on: April 23, 2009, 02:08:47 AM »

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);
  }
 
//+-----------------------------------------------------------------
Logged
ergys1
Newbie
*
Posts: 4


« Reply #2 on: April 25, 2009, 06:54:20 PM »

Thanks Guys - this actually shows only the spikes as the indicators cross - I want to be able to show the two lines (RSI and SMA) with different colors in the same subchart as well as a BUY or Sell arrow on the main chart's bar/candlestick. Thanks again

Logged
Tradecision Support Team
Hero Member
*****
Posts: 336


« Reply #3 on: April 27, 2009, 02:26:33 AM »

Dear Ergys1,

We have sent you the response via email.


Sincerely,
Tradecision Support Team



Thanks Guys - this actually shows only the spikes as the indicators cross - I want to be able to show the two lines (RSI and SMA) with different colors in the same subchart as well as a BUY or Sell arrow on the main chart's bar/candlestick. Thanks again


Logged
ergys1
Newbie
*
Posts: 4


« Reply #4 on: April 28, 2009, 03:40:59 AM »

HI,

I have not received anything yet. Thanks
Logged
Tradecision Support Team
Hero Member
*****
Posts: 336


« Reply #5 on: April 29, 2009, 03:32:51 AM »

Dear Ergys1,

We have resent our previous reply to the email address mentioned in your profile.

Sincerely,
Tradecision Support Team


HI,

I have not received anything yet. Thanks
Logged
ergys1
Newbie
*
Posts: 4


« Reply #6 on: April 29, 2009, 07:50:16 AM »

Hi

I sent you a personal message with an alternate email address - my registered email address has received emails from the admins on this site - could you please try and resend it for me?

Thanks,

Ergys1
Logged
Tradecision Support Team
Hero Member
*****
Posts: 336


« Reply #7 on: April 29, 2009, 08:00:59 AM »

Dear Ergys1,

We have not received your message yet.
Did you send it to the following email address: support@tradecision.com?


Sincerely,
Tradecision Support Team

Hi

I sent you a personal message with an alternate email address - my registered email address has received emails from the admins on this site - could you please try and resend it for me?

Thanks,

Ergys1
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!