2017-01-10

Hello All,

Firstly my trade setup:

I use Bill Williams profitunity system for trend indication, KAMA - Kauffman adaptive moving average for entry exit and pivot points and trendlines for understanding overall structure. *

Yes this is no holy grail, I get fair share of false triggers, but still I am happy with this . I trade only in Nifty futures/options, applying the studies to Nifty spot. (Yes I know, many experts here would differ on this) *

For positional trades, when I am not in front of screen, I am happy with zerodhas kite.

For dedicated intraday trading I sit in front of Pi. *

Now; Zerodha has made available the Profitunity alligator and the pivot points, BUT for KAMA I'm stuck with Metastock (Sorry, never had opportunity to try out Amibroker). So for that alone, I spend my entire time copy pasting 5min bar data from Pi to Metastock, just to see if a trade is triggered, very very cumbersome! *

I would love to automate my entire strategy and leave it on Full-on Autopilot, but reading through many of zerodhas blogs I realized its not easy, and definetly not free!! *

Now all I have to do is write a Alert/EA in Pi for KAMA, as I already have the formula in Metastock, it was easy to start with:- *

******************

Metastock Formula for KAMA-

If(Cum(1)=5, Ref(C,-1)+(Pwr((Abs((C-Ref(C,-4))/Sum(Abs(ROC(C,1,$)),4)))*((2/3)-(2/31))+(2/31),2))*(C-Ref(C,-1)), PREV+(Pwr((Abs((C-Ref(C,-4))/Sum(Abs(ROC(C,1,$)),4)))*((2/3)-(2/31))+(2/31),2))*(C-PREV))

******************

To get basic understanding of the formula:

http://stockcharts.com/school/doku.p...moving_average

*

Learning Tradescript(Simple coding language in Pi) was fairly easy, BUT my desperate attempt at writing this formula/Alert came to an abrupt halt at the last step where to compute KAMA we need the previous days KAMA value!!! *….and for computing previous days KAMA value we need day before yesterdays KAMA value……and so on

However my futile attempt resulted in this… ******************

# very basic attempt to code KAMA in Pi

SET ERperiods = 10

SET EMAfast = 2

SET EMAslow = 30 *

Set close10 = ref(Close, 10)

Set close9 = ref(Close, 9)

Set close8 = ref(Close, 8)

Set close7 = ref(Close, 7)

Set close6 = ref(Close, 6)

Set close5 = ref(Close, 5)

Set close4 = ref(Close, 4)

Set close3 = ref(Close, 3)

Set close2 = ref(Close, 2)

Set close1 = ref(Close, 1) *

SET change = abs(close- close10) *

SET volatility = ABS(close-close1) + ABS(close1-close2) + ABS(close2-close3) + ABS(close3-close4) + ABS(close4-close5) + ABS(close5-close6) + ABS(close6-close7) + ABS(close7-close8) + ABS(close8-close9) + ABS(close9-close10) *

SET ER = ABS(Change/volatility) *

SET SC = [ER * (2/(EMAfast+1) - 2/(EMAslow+1)) + 2/(EMAslow+1)]^2 *

SET KAMA *= KAMAp + SC * (close-KAMAp)

SET KAMAp = REF(KAMA, 1) * ******************************

Stuck at this stage, any help would be great help! Regards,

Khaleel

Show more