RSI Filter - page 2

 
RaptorUK:
So exactly what is your problem ?

Thanks Raptor!

Im trying to implement an Rsi filter that allows me to use per choise, Use RSI=true or false.

Allows long trade when rsi>50 and short when rsi<50

RSI=false it should not turn of the existing EA 

Is just an extra filter per choise 

 
pieronetto:

Thanks Raptor!

Im trying to implement an Rsi filter that allows me to use per choise, Use RSI=true or false.

Allows long trade when rsi>50 and short when rsi<50

RSI=false it should not turn of the existing EA 

Is just an extra filter per choise 

Yes I know,  but when you run your code what is it not doing that it should or what is it doing that it shouldn't ?
 
RaptorUK:
Yes I know,  but when you run your code what is it not doing that it should or what is it doing that it shouldn't ?

If(UseRsi)=false the existing EA wont open any trades but he should

 and when if(UseRsi)=true the EA works normal and the rsi filter does nothing.

extern bool      UseRSI=true;
extern int       RSIperiod=14;
extern double    RSIBuyPoint=50;
extern double    RSISellPoint=70;
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;
   }
  }
// before OrderSend 
    if (BuyRSI)
    if(SellRSI)
   return(0);
   
 
pieronetto:

If(UseRsi)=false the existing EA wont open any trades but he should

 and when if(UseRsi)=true the EA works normal and the rsi filter does nothing.


If UseRsi is false then BuyRSI and SellRSI are still at their default values . . .  it also looks like you have one too many braces . .

extern bool      UseRSI=true;
extern int       RSIperiod=14;
extern double    RSIBuyPoint=50;
extern double    RSISellPoint=70;
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;
      }
   }                       //  this is the closing brace for the start function
 
   // before OrderSend 
   if (BuyRSI)            //  this is outside of start()
      if(SellRSI)
         return(0);
 

Thanks to Raptor again i got it working so far.

only if i put rsi=false the rest of the EA wont open any trades.

Please a litle hint. I like to have the rest of the EA working if i put rsi=false.

Thanks 

extern bool      UseRSI=true;  
extern int       RSIperiod=14;    //rsi period
extern double    RSIBuyPoint=51;  //allow long entry above or equal RSIBuyPoint
extern double    RSISellPoint=49; //allow short entry beneath or equal RSISellPoint

bool BuyRSIAllowTrading,SellRSIAllowTrading;

{     
    if (UseRSI)  
  {     
     double RSI  = iRSI(NULL,0,RSIperiod,PRICE_OPEN,0);
     if (RSI<RSIBuyPoint)
     BuyRSIAllowTrading=false;
     else
     BuyRSIAllowTrading=true;
     if (RSI>RSISellPoint)
     SellRSIAllowTrading=false;
     else
     SellRSIAllowTrading=true;
}
}   
   //  if(BuyRSIAllowTrading).......put in to buy conditions
   //  if(SellRSIAllowTrading)......put in to sell conditions
 
pieronetto:

Thanks to Raptor again i got it working so far.

only if i put rsi=false the rest of the EA wont open any trades.

Please a litle hint. I like to have the rest of the EA working if i put rsi=false.

Thanks 

 

Happy holidays everyone
 
pieronetto:

Thanks to Raptor again i got it working so far.

only if i put rsi=false the rest of the EA wont open any trades.

Please a litle hint. I like to have the rest of the EA working if i put rsi=false.

You need to show more of your code . . .  we can't see how you are using your bools in relation to opening trades . . .
 
RaptorUK:
You need to show more of your code . . .  we can't see how you are using your bools in relation to opening trades . . .

Here are my sell and buy conditions i believe ths change need to be made here.

Thanks for beeing on today.

void CheckForOpen() {
   int    res,tr;
//---- sell conditions
   if(SellRSIAllowTrading)  
   if(sellsig){
           if (co==0 && lastsig!=Time[0]) {
             res = OpenAtMarket(OP_SELL,lot);
             lastsig=Time[0];
           }
      return;
   }
//---- buy conditions
   if(BuyRSIAllowTrading)
   if(buysig){
           if (co==0 && lastsig!=Time[0]) {
             res = OpenAtMarket(OP_BUY,lot);
             lastsig=Time[0];
           }
      return;
   }
}
 
pieronetto:

Here are my sell and buy conditions i believe ths change need to be made here.

Thanks for beeing on today.

 

Why wouldn't I be here today ?

 

As I said before . . .

RaptorUK:

If UseRsi is false then BuyRSI and SellRSI are still at their default values . . .  

 . . .  but you have changed the variable names.

Look at this and understand why it will work . . .

void CheckForOpen() {
   int    res,tr;
//---- sell conditions
   if(SellRSIAllowTrading || !UseRSI)    // changed this line 
      if(sellsig){
           if (co==0 && lastsig!=Time[0]) {
             res = OpenAtMarket(OP_SELL,lot);
             lastsig=Time[0];
           }
      return;
   }
//---- buy conditions
   if(BuyRSIAllowTrading || !UseRSI)   // changed this line
      if(buysig){
           if (co==0 && lastsig!=Time[0]) {
             res = OpenAtMarket(OP_BUY,lot);
             lastsig=Time[0];
           }
      return;
   }
}
 
RaptorUK:

Why wouldn't I be here today ?

 

As I said before . . .

 . . .  but you have changed the variable names.

Look at this and understand why it will work . . .

Thank you very much it works  now just fine but i do not understand the code line please point me to some text i can read about it.

thanks again. 

Reason: