RSI Filter

 

Hello Again!

After having my time filter working and understand the coding of time in a good matter moving on to the next topic.

I try to code an Rsi Filter, in to my existing EA, that allows trading only on certain levels.

Lets say my EA gives me a buy singnal and RSI<30 then RSIBuy=true and RSI>30 is RSISell=false and the same oppesite.

I have not implemented the code yet, i believe im of track with this, so please point me in the right direction. 

That what i have so far as code. 

Thanks alot and sorry about my english.

extern bool      UseRSI=true;
extern int       RSIperiod=14;
extern double    RSIBuyPoint=30;
extern double    RSISellPoint=70;

bool BuyRSI,SellRSI;

int start()
   { 
     if (UseRSI)
     double r1 = iRSI(NULL,0,RSIperiod,PRICE_CLOSE,1);
     double r2 = iRSI(NULL,0,RSIperiod,PRICE_CLOSE,2);
     {
     if (r2<RSIBuyPoint && r1>RSIBuyPoint)
     BuyRSI=false;
     else
     BuyRSI=true;
     {
     if (r2>RSISellPoint && r1<RSISellPoint)
     SellRSI=false;
     else
     SellRSI=true;
   }
}
}
return(0);

   //  implement before OrderSend 
   //  if (BuyRSI)
   //  else
   //  if(SellRSI)   
 
pieronetto:

Hello Again!

After having my time filter working and understand the coding of time in a good matter moving on to the next topic.

I try to code an Rsi Filter, in to my existing EA, that allows trading only on certain levels.

Lets say my EA gives me a buy singnal and RSI<30 then RSIBuy=true and RSI>30 is RSISell=false and the same oppesite.

I have not implemented the code yet, i believe im of track with this, so please point me in the right direction. 

Your English is just fine  

extern bool      UseRSI=true;
extern int       RSIperiod=14;
extern double    RSIBuyPoint=30;
extern double    RSISellPoint=70;

bool BuyRSI,SellRSI;

int start()
   { 
   if (UseRSI)
      double r1 = iRSI(NULL,0,RSIperiod,PRICE_CLOSE,1);  // if UseRSI == false this line will not be executed
   
   double r2 = iRSI(NULL,0,RSIperiod,PRICE_CLOSE,2);     //  . . . .  but this line and all that follow will.
   {                                                 //  what is this brace for ?
   if (r2<RSIBuyPoint && r1>RSIBuyPoint)
      BuyRSI=false;
   else
      BuyRSI=true;
   {                                                //  what is this brace for ?
   if (r2>RSISellPoint && r1<RSISellPoint)
      SellRSI=false;
   else
      SellRSI=true;
   }
   }
   }
return(0);

 See my comments in your code above . . .  I think you misunderstand   { }  braces.   

 
RaptorUK:

Your English is just fine  

 See my comments in your code above . . .  I think you misunderstand   { }  braces.   

 

Hello Raptor!

Quick respond, thanks.

I guess, i have the braces right but to make the ,if (UseRSI), work for all lines im not understanding it. Do i have to drup it on all lines extra, semes to be wrong.

Or include braces for and after the filter?

And thanks again for you time!

extern bool      UseRSI=true;
extern int       RSIperiod=14;
extern double    RSIBuyPoint=30;
extern double    RSISellPoint=70;
bool BuyRSI,SellRSI;
int start()
{
   if (UseRSI)
   { 
     double r1 = iRSI(NULL,0,RSIperiod,PRICE_CLOSE,1);
     double r2 = iRSI(NULL,0,RSIperiod,PRICE_CLOSE,2);
     if (r2<RSIBuyPoint && r1>RSIBuyPoint)
     BuyRSI=false;
     else
     BuyRSI=true;
     if (r2>RSISellPoint && r1<RSISellPoint)
     SellRSI=false;
     else
     SellRSI=true;
   }
}



return(0);
   //  before OrderSend 
   //  if (BuyRSI)
   //  else
   //  if(SellRSI)  
 
pieronetto:

Hello Raptor!

Quick respond, thanks.

I guess, i have the braces right but to make the ,if (UseRSI), work for all lines im not understanding it. Do i have to drup it on all lines extra, semes to be wrong.

Or include braces for and after the filter?

That looks better  

The return is in the wrong place for the start() function . . . 

 
RaptorUK:
That looks better  
Thanks, and befor OrderSend i put this and get      'else' - unexpected token 
  
    if (BuyRSI)
    else
    if(SellRSI)
 
pieronetto:
Thanks, and befor OrderSend i put this and get      'else' - unexpected token 
  

Because . . .

if (BuyRSI)
   //  do something  ;

else
   if(SellRSI)
      //  do something ;

 You will probably not need the else.

 
Your Code
Simplified booleans
     if (r2<RSIBuyPoint && r1>RSIBuyPoint)
     BuyRSI=false;
     else
     BuyRSI=true;
BuyRSI = !(r2<RSIBuyPoint && r1>RSIBuyPoint);

// Note: I think you meant the opposite, 
// was below, now above, buy. Drop the !
 

Thanks for you replies.  I have to start from the beginning. I do believe i misunderstud samthing wrong and i changed my logice to a little different approch of this RSI filter.

So if my existing EA gives me a buy singnal and (RSi>0=BuyRSIAllowTrading) that means there would be nothing in the way to open the trade.

So if my existing EA gives me a buy singnal and (RSI>50=Buy RSIAllowTrading)that means there would be nothing in the way to open the trade over or even 50 RSI

I havend implementet any of this codes yet dont even know the are working, just compile them.

Please let me know how im doing on this. That makes any sense to you?

Thanks

and again sorry about my worse english

extern bool      UseRSI=true;
extern int       RSIperiod=14;
extern double    RSIBuyPoint=0;
extern double    RSISellPoint=100;
bool BuyRSIAllowTrading,SellRSIAllowTrading;
int start()
{ 
     if (UseRSI)  
  {     
     bool BuyRSIAllowTrading=!(iRSI(NULL,0,RSIperiod,PRICE_CLOSE,0)>=RSIBuyPoint);

     BuyRSIAllowTrading=true;    
     
     bool SellRSIAllowTrading=!(iRSI(NULL,0,RSIperiod,PRICE_CLOSE,0)<=RSISellPoint);

     SellRSIAllowTrading=true;   
   }
  }
return(0);
   //  before OrderSend 
   //  if (BuyRSIAllowTrading)
   //  if(SellRSIAllowTrading)   
     
 

Hello!

Im still working on this filter and im out of ideas and i believe im completly of track now.

Still trying to get rsi>50=Buy and rsi<50 to sell or allow trading need a big push in the right way.

Thanks 

Dont like to give up right here.

 
M'I getting some where with this,im trying to ?
extern int       RSIperiod=14;
extern double    RSIBuyPoint=50;
extern double    RSISellPoint=50;
bool BuyRSI,SellRSI;
int start()
{ 
    if (UseRSI)  
  {     
     double RSI  = iRSI(NULL,0,RSIperiod,PRICE_OPEN,0);
     if (RSI > RSIBuyPoint)
     BuyRSI=false;
     else
     BuyRSI=true;
     if (RSI < RSISellPoint)
     SellRSI=false;
     else
     SellRSI=true;
   }
  }
return(0);
   //  Put this before OrderSend 
   //  if (BuyRSI)
   //  else
   //  if(SellRSI) 
 
pieronetto:
M'I getting some where with this,im trying to ?
So exactly what is your problem ?
Reason: