# Different setting for different time frame

Hi all

how to apply different setting for different time frame base on the code below .

i mean daily time frame ( RSI setting is 14-periods ) .

weekly time frame ( RSI setting is 9 -periods ) .

monthly time frame ( RSI setting is 5 -periods ) .

``````
//          original code by fxshart  at    https://forum.amibroker.com/t/how-to-reducing-the-code-or-simplify-it/36969/7?u=needhelp

mx = Matrix(8,1);
rownum = MxGetSize(mx,0);
mx[0][0] = in5Minute;
mx[1][0] = in15Minute;
mx[2][0] = 2*in15Minute;
mx[3][0] = inHourly;
mx[4][0] = 4*inHourly;
mx[5][0] = inDaily;
mx[6][0] = inWeekly;
mx[7][0] = inMonthly;

for ( i = 0; i < rownum; i++ )
{
TimeFrameSet( mx[i][0] );
inter_val = Interval(2);

RSI_period = 14 ;

RSI_OPT_PERIOD_A = Optimize ( "RSIa", RSI_period, 2, 70, 1 ); // rsia Optimize CLOSE

/////////////////////////// RSI parameter inDaily /////////////////

RSI_CLOSE_DA =   RSIa(  C , RSI_OPT_PERIOD_A ) ;

/////////////////////////// END RSI parameter inDaily /////////////////

TimeFrameRestore();

R_MAQ_SI_level_10 = 10 ;
R_MAQ_SI_level_20 = 20 ;
R_MAQ_SI_level_30 = 30 ;
R_MAQ_SI_level_40 = 40 ;
R_MAQ_SI_level_50 = 50 ;
R_MAQ_SI_level_60 = 60 ;
R_MAQ_SI_level_70 = 70 ;
R_MAQ_SI_level_80 = 80 ;
R_MAQ_SI_level_90 = 90 ;

if ( i == 5  ) {

// Gui/Gfx  ( textbox )
// for daily    period rsi = 14

}

if ( i == 6  ) {

// for weekly    period rsi = 9
}

if ( i == 7  ) {

// for monthly    period rsi = 5
}

}
``````

thank you

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.