iRSI EA can not change from default value of 14 to 3?

 

Hi,

I would like to change the RSI period to 3 from the default value of 14.

For some reason when i try to change the period to the value of 3. When i try to back test my strategy it will default the value to 15.

Does anyone else also has this problem or just me?

Please feel free to give me some advice.

thanks you

My code are as below:

//+------------------------------------------------------------------+

//| toy moving average EA.mq4 |

//| Copyright 2013, MetaQuotes Software Corp. |

//| http://www.metaquotes.net |

//+------------------------------------------------------------------+

#property copyright "Copyright 2013, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net"

extern double lots = 0.10;

extern int takeprofit = 100;

extern int stoploss = 100;

extern int magic = 1234;

extern int period = 3;//for change in RSI

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start()

{

//----

double R1,R2;

R1 = iRSI(NULL,0,Period(),PRICE_CLOSE,0);

R2 = iRSI(NULL,0,Period(),PRICE_CLOSE,1);

if(OrdersTotal()==0)// check if the order is currently no position

{

if (R2<30&&R1>30)

{

OrderSend(Symbol(),OP_BUY,lots,Ask,3,Ask-Point*stoploss,Ask+Point*takeprofit, "buy trade",magic,Green);//open buy trade

}

if (R2>70&&R1<70)

{

OrderSend(Symbol(),OP_SELL,lots,Bid,3,Bid+Point*stoploss,Bid-Point*takeprofit, "Sell trade",magic,Red);//open sell trade

}

}

if(OrdersTotal()==1)//check if the order open is 1 or not

{

if(R2<30&&R1>30)

{

OrderSelect(0,SELECT_BY_POS,MODE_TRADES);//use this code for selecting the trade

if(OrderType()==OP_SELL)//if the order is open sell

OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);//close sell Order

}

if(R2>70&&R1<70)

{

OrderSelect(0,SELECT_BY_POS,MODE_TRADES);//use this code for selecting the trade

if(OrderType()==OP_BUY)//if the order is open buy

OrderClose(OrderTicket(),OrderLots(),Bid,3,Green);//close buy Order

}

}

//----

return(0);

}

//+------------------------------------------------------------------+ 
 

Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.

 
toy5429274:

Hi,

I would like to change the RSI period to 3 from the default value of 14.

For some reason when i try to change the period to the value of 3. When i try to back test my strategy it will default the value to 15.

Does anyone else also has this problem or just me?

Please feel free to give me some advice.

thanks you

My code are as below:


I guess you are running your backtest on M15 timeframe.

Where in this code is the period of RSI changed ?

 
toy5429274: I would like to change the RSI period to 3 from the default value of 14.
  1. Where are you even trying to set it to 3?
    double iRSI(string symbol, int timeframe, int period, int applied_price, int shift)
    R1 = iRSI(NULL,0,                            Period(),       PRICE_CLOSE,0);
                                                   ^ Length of the RSI =  1 on M1  chart, 
                                                                       = 15 on M15 chart
  2. Check your return codes What are Function return values ? How do I use them ? - MQL4 forum
  3. Adjust for 4/5 digit brokers
Reason: