{"id":1304,"date":"2016-01-17T00:01:57","date_gmt":"2016-01-16T23:01:57","guid":{"rendered":"http:\/\/www.amibroker.com\/kb\/?p=1304"},"modified":"2016-01-29T00:05:13","modified_gmt":"2016-01-28T23:05:13","slug":"adding-custom-grid-levels-to-rsi-indicator","status":"publish","type":"post","link":"https:\/\/www.amibroker.com\/wordpress\/kb\/2016\/01\/17\/adding-custom-grid-levels-to-rsi-indicator\/","title":{"rendered":"Adding custom grid levels to RSI indicator"},"content":{"rendered":"
Built-in RSI indicator offers the ability to display one of predefined grid levels to indicate oversold and overbought regions. This can be done in Axes&Grid<\/strong> tab of Parameters<\/strong> window available under right-mouse button.<\/p> <\/p> If we require more flexibility, then as an alternative, we could modify the code and call PlotGrid function to display the custom grid lines. This allows to specify any level for the grids. A modified formula is presented below:<\/p> <\/p>SetChartOptions<\/span>( <\/span>0<\/span>, <\/span>chartShowArrows<\/span>, <\/span>0 <\/span>);
<\/span>periods <\/span>= <\/span>Param<\/span>( <\/span>"Periods"<\/span>, <\/span>15<\/span>, <\/span>1<\/span>, <\/span>200<\/span>, <\/span>1 <\/span>);
<\/span>oversold <\/span>= <\/span>Param<\/span>( <\/span>"Oversold level"<\/span>, <\/span>15<\/span>, <\/span>1<\/span>, <\/span>100<\/span>, <\/span>1 <\/span>);
<\/span>overbought <\/span>= <\/span>Param<\/span>( <\/span>"Overbought level"<\/span>, <\/span>85<\/span>, <\/span>1<\/span>, <\/span>100<\/span>, <\/span>1 <\/span>);
<\/span>Plot<\/span>( <\/span>RSI<\/span>( <\/span>periods<\/span>), <\/span>_DEFAULT_NAME<\/span>(), <\/span>ParamColor<\/span>( <\/span>"Color"<\/span>, <\/span>colorCycle <\/span>), <\/span>ParamStyle<\/span>(<\/span>"Style"<\/span>) );
<\/span>PlotGrid<\/span>( <\/span>oversold <\/span>);
<\/span>PlotGrid<\/span>( <\/span>overbought <\/span>)<\/code>