Experts: Example of RSI Automated

 

Example of RSI Automated:

This is my 1st published code, it is very simple code example: RSI 14 (price close) — open buy when it is < 25, close buy when it is > 50, open sell when it is > 75, close sell when it is < 50.

Author: Mohammad Soubra

 
Welcome
 
Automated-Trading:

Example of RSI Automated:

Author: Mohammad Soubra

Have you made back-tests?
 

Thank you for this simple EA, its a good idea to use the RSI as a trading tool but still there is some modifications i think needed to be done to come up with a successful EA.

I will try to test some modification and when i reach to a successful result i will publish it here. 

 
calli:
Have you made back-tests?

yes my friend

just it is for code base

it is not a product

I know the back test will not be great

so take care

repeat: just a code not to trade 

 
Wasim Zayed:

Thank you for this simple EA, its a good idea to use the RSI as a trading tool but still there is some modifications i think needed to be done to come up with a successful EA.

I will try to test some modification and when i reach to a successful result i will publish it here. 

yes please

I am also waiting for that

 

:)

 

 

as I have been answered Calli above, it is not for trading. it is just a code in this community library 

 

Hi Mohammad,


Thanks for the contribution, it's always nice to see other people's examples and how they code.

If I may, I would like to make a few comments for others (and perhaps yourself) in code efficiency.  I believe it's important to keep the OnTick() and start() functions as lean as possible when writing an EA.  For example, in your code example after taking a position when the RSI is below 25, you then check if the RSI is above 75 for a short position.  We know with 100% certainty that the conditions will never occur on the same tick, so we could exit the function once the order has been opened.  Also, once you've taken a position, you then re-select the order and modify the stop loss and take profit with a call to OrderModify().  This could have been done at the same time you opened the order.  The new code would then look like this...


      if((iRSI(NULL,0,14,PRICE_CLOSE,0)<25)) // Here is the open buy condition
        {
         TheStopLoss=0;
         TheTakeProfit=0;
         if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
         if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
         result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,TheStopLoss,TheTakeProfit,"EXAMPLE OF RSI AUTOMATED",MagicNumber,0,Blue);
         if(result>0) return;
        }


There's also a potential bug in the next section of code where it's possible the order will be closed (either long or short) and then a call to OrderModify() if the user selects a tight value for TrailingStop.  The solution would be to place a 'return' when the order is closed.


Keep up the great work, looking forward to more of your code!

Cheers!

 
Claude Beaudoin:

Hi Mohammad,


Thanks for the contribution, it's always nice to see other people's examples and how they code.

If I may, I would like to make a few comments for others (and perhaps yourself) in code efficiency.  I believe it's important to keep the OnTick() and start() functions as lean as possible when writing an EA.  For example, in your code example after taking a position when the RSI is below 25, you then check if the RSI is above 75 for a short position.  We know with 100% certainty that the conditions will never occur on the same tick, so we could exit the function once the order has been opened.  Also, once you've taken a position, you then re-select the order and modify the stop loss and take profit with a call to OrderModify().  This could have been done at the same time you opened the order.  The new code would then look like this...


      if((iRSI(NULL,0,14,PRICE_CLOSE,0)<25)) // Here is the open buy condition
        {
         TheStopLoss=0;
         TheTakeProfit=0;
         if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
         if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
         result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,TheStopLoss,TheTakeProfit,"EXAMPLE OF RSI AUTOMATED",MagicNumber,0,Blue);
         if(result>0) return;
        }


There's also a potential bug in the next section of code where it's possible the order will be closed (either long or short) and then a call to OrderModify() if the user selects a tight value for TrailingStop.  The solution would be to place a 'return' when the order is closed.


Keep up the great work, looking forward to more of your code!

Cheers!

Thanks for your time

the written code by you above is similar of my code

the most important for the programmer to arrive the aim what ever the language or code...

 

with respect of your opinion

 

yes I am planning to post more codes 

 

feel free to update the code as u wish and post the modification here 

 
Thank you Mohammad
 
Mitsubishi4arab:
Thank you Mohammad

oh...

welcome

 

feel_free_to_modify_this_EA_as_you_wish_and_inform_us_about_the_updates 

 
Dears all, 
I am preparing a new code for a meta trader 4 EA
It is the same but on the stochastic oscillator
Very soon will be published
This depends on the community admin
Reason: