AMIBROKER: SWAMICHARTS

In “Introducing SwamiCharts” in this issue, authors John Ehlers & Ric Way present a new way to display classic indicators. They call their technique SwamiCharts.

Implementing SwamiCharts in AmiBroker Formula Language is easy, thanks to its powerful array processing. The resulting code is very short compared to the way it may need to be implemented in some other platforms. The code is shown here. To use it, enter the formula in the AFL Editor, then press the Insert Indicator button to display the chart.

The formula implements SwamiCharts stochastics, but you can easily create SwamiCharts out of any indicator of your choice. Simply replace “StochK” with another indicator, as explained in the commented code below. Just make sure that indicator has a normalized range of zero to 100 (such as RSI, stochastics, MFI, etc.) or adjust the scaling factor (100) accordingly.

A sample chart is shown in Figure 4.

Image 1

FIGURE 4: AMIBROKER, SWAMICHARTS. Here is a daily chart of SPY (upper pane) and the SwamiChart stochastic (lower pane).


Title = "SwamiStochastics"; 

for( N = 6; N <= 48; N++ ) 
{ 
 // Replace this line with the indicator of your choice, like RSI( N )
 indicator = StochK( N, 4 ) / 100; 

 red = IIf( indicator >= 0.5, 255 * ( 2 - 2 * indicator ), 255 ); 
 green = IIf( indicator < 0.5, 255 * 2 * indicator, 255 ); 
 blue = 0; 

 Color = ColorRGB( red, green, blue ); 

 PlotOHLC( N, N+1, N, N, "", Color, styleCloud | styleNoLabel ); 
}

—Tomasz Janeczko, AmiBroker.com
www.amibroker.com

Teline4-tabs1 - Site

  • Traders' Tips

  • Letters To The Editor

Teline4-tabs2 - Site

  • Q & A

  • Novice Traders' Notebook

Teline4-tabs3 - Site

  • Books For Traders

  • News & Products

Teline4-tabs4 - Site

  • Free Articles

  • At The Close

SUBSCRIBE TO OUR FREE
EMAIL NEWSLETTER!