Implementing RSI(14) timeframe with Gaps

Hi,

I am trying to implement RSI(14) on a 5 minute chart with 15 minutes timeframe (with Gaps). I have written the below code but the RSI output are not same.

Can anyone highlight what would be the correct code.

_SECTION_BEGIN("RSI");

TimeFrameSet(in15Minute);
SetChartOptions(0,0,chartGrid30|chartGrid70);
periods = Param( "Periods", 15, 1, 200, 1 );
Plot( RSI( periods), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style")  );
TimeFrameRestore();

_SECTION_END();

Check your INPUT DATA. Most likely you are feeding different data.

@Tomasz , the input data is also of 5 minutes in Amibroker.

Hello sandeeppanja,

your code is wrong, to draw an RSI from an higher TF (15m) into an lower TF (5m) chart you have to expand your arrays. Please see this sample without Gaps:

// RSI 2x Timeframe > Chart TF for example in1Minute ( := Lower ), result: RSI in5Minute and RSI in15Minute ( := Higher )

n = Param( "RSI(n)", 14, 2, 144 );

// in5Minute --------------------------------------------------------------------------------------

TimeFrameSet( in5Minute );
rsi5 = RSI( n );
TimeFrameRestore();

Plot( TimeFrameExpand( rsi5, in5Minute, expandFirst), "RSI-5m", colorWhite, styleLine, 0, 0, 0, 0, 2 );

// in15Minute --------------------------------------------------------------------------------------

TimeFrameSet( in15Minute );
rsi15 = RSI( n );
TimeFrameRestore();

Plot( TimeFrameExpand( rsi15, in15Minute, expandFirst), "RSI-15m", colorCustom12, styleLine, 0, 0, 0, 0, 2 );

// ------------------------------------------------------------------------------------------------

Plot( 30, "", colorBrightGreen, styleLine | styleNoLabel, 0, 0, 0, -1, 1 ); 
Plot( 50, "", colorLightGrey, styleLine | styleNoLabel, 0, 0, 0, -1, 1 );
Plot( 70, "", colorRed, styleLine | styleNoLabel, 0, 0, 0, -1, 1 ); 

Best regards,
Peter

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