Kama & SMA Trading System Dax Discussion Thread
Forums › ProRealTime English forum › ProOrder support › Kama & SMA Trading System Dax Discussion Thread
- This topic has 4 replies, 4 voices, and was last updated 4 years ago by
Indiana400.
Viewing 5 posts - 1 through 5 (of 5 total)
-
-
09/01/2019 at 10:42 PM #106157Kama-SMA RB Mod MM123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154//************************************************************************// Kama & Sma Trading System DAX mtf//************************************************************************//DEFPARAM CumulateOrders = FalseDEFPARAM PreLoadBars = 2000DEFPARAM FLATBEFORE = 080000DEFPARAM FLATAFTER = 210000once multiplier=1once fraction=72once newlevel=72once oldlevel=72once startpositionsize=1once positionsize=startpositionsizeif strategyprofit>newlevel thenmultiplier=multiplier+0.05oldlevel=newlevelnewlevel=strategyprofit+multiplier*fractionpositionsize=multiplier*startpositionsizeelsif strategyprofit<oldlevel and multiplier>=1 thennewlevel=strategyprofitoldlevel=strategyprofit-multiplier*fractionmultiplier=multiplier-0.05positionsize=multiplier*startpositionsizeendif////////////////////////////////////////////////////////////////////////TIMEFRAME (default)//ONCE nLots = 1ONCE LongTrading = 1 //1=allowed 0=bannedONCE ShortTrading = 1 //1=allowed 0=banned//ONCE TP = 500 //200 pipsONCE SL = 30 //50 pips//TimeForbidden = OpenTime < 080000 AND OpenTime > 210000LongCond = (Not TimeForbidden) AND LongTradingShortCond = (Not TimeForbidden) AND ShortTrading//TIMEFRAME (1 hour, updateonclose) //h1IF Not OnMarket THENBarCount = 0ELSEBarCount = BarCount + 1ENDIF//------------------------------------------------------------------------------------// Kama & Sma Strategy////https://www.forexstrategiesresources.com/trend-following-forex-strategies/111-kama-strategy///Period = 2 //2 (standard 10)FastPeriod = 2 //standardSlowPeriod = 30 //standard//Fastest = 2 / (FastPeriod + 1)Slowest = 2 / (SlowPeriod + 1)if barindex >= (Period + 1) thenNum = abs(close-close[Period])Den = summation[Period](abs(close-close[1]))ER = Num / DenAlpha = SQUARE(ER *(Fastest - Slowest )+ Slowest)Kama = (Alpha * Close) + ((1 -Alpha)* Kama[1])elseKama = closeendif//------------------------------------------------------------------------------------Sma = average[22,0](close) //22//------------------------------------------------------------------------------------a1 = Kama CROSSES OVER Sma// --- SHORTb1 = Kama CROSSES UNDER Sma////////////////////////////////////////////////////////////////////////TIMEFRAME (default) //1 minONCE TradeON = 1IF IntraDayBarIndex = 0 THENTradeON = 1ENDIFTradeBar = BarCountIF Not OnMarket AND TradeBar <> TradeBar[1] THENTradeON = 1ENDIF//************************************************************************// LONG trades//************************************************************************IF a1 AND TradeON AND LongCond THENBUY positionsize CONTRACT AT MARKETTradeON = 0ENDIF//************************************************************************// SHORT trades//************************************************************************IF b1 AND TradeON AND ShortCond THENSELLSHORT positionsize CONTRACT AT MARKETTradeON = 0ENDIF//SET TARGET pPROFIT TPSET STOP pLOSS SL//////////////////////////////////////////////////////////////////////////////////////////////////////////// Trailing Stop//------------------------------------------------------------------------------------IF Not OnMarket THENTrailStart = 10 //10 Start trailing profits from this pointBasePerCent = 0.100 //10.0% Profit to keepStepSize = 6 //6 Pips chunks to increase PercentagePerCentInc = 0.100 //10.0% PerCent increment after each StepSize chunkRoundTO = -0.5 //-0.5 rounds to Lower integer, +0.4 rounds to Higher integerPriceDistance = 7 * pipsize//8.9 minimun distance from current pricey1 = 0y2 = 0ProfitPerCent = BasePerCentELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONGx1 = (close - tradeprice) / pipsize //convert price to pipsIF x1 >= TrailStart THEN //go ahead only if N+ pipsDiff1 = abs(TrailStart - x1)Chunks1 = max(0,round((Diff1 / StepSize) + RoundTO))ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc))ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))y1 = max(x1 * ProfitPerCent, y1) //y = % of max profitENDIFELSIF ShortOnMarket AND close < (TradePrice - (y2 * pipsize)) THEN//SHORTx2 = (tradeprice - close) / pipsize //convert price to pipsIF x2 >= TrailStart THEN //go ahead only if N+ pipsDiff2 = abs(TrailStart - x2)Chunks2 = max(0,round((Diff2 / StepSize) + RoundTO))ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc))ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))y2 = max(x2 * ProfitPerCent, y2) //y = % of max profitENDIFENDIFIF y1 THEN //Place pending STOP order when y>0SellPrice = Tradeprice + (y1 * pipsize) //convert pips to priceIF abs(close - SellPrice) > PriceDistance THENIF close >= SellPrice THENSELL AT SellPrice STOPELSESELL AT SellPrice LIMITENDIFELSESELL AT MarketENDIFENDIFIF y2 THEN //Place pending STOP order when y>0ExitPrice = Tradeprice - (y2 * pipsize) //convert pips to priceIF abs(close - ExitPrice) > PriceDistance THENIF close <= ExitPrice THENEXITSHORT AT ExitPrice STOPELSEEXITSHORT AT ExitPrice LIMITENDIFELSEEXITSHORT AT MarketENDIFENDIF
Code with modifications for opening times, stop loss and money management
4 users thanked author for this post.
09/02/2019 at 7:37 AM #106172Is this a modded version of this strategy? Kama & Sma Trading System DAX mtf
09/02/2019 at 7:49 PM #106266Hi
Yes it is, I did link this thread from the original strategy thread where I wasn’t able to post the code
10/25/2020 at 9:53 AM #14838212/30/2020 at 6:52 PM #155724Hi Can you post the new modded version. The result i am getting from the original version or very poor. Profit rate of 0.58. I also cannot seem to be able to go back as far as you on the 1 min chart.
Many thanks
-
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
Find exclusive trading pro-tools on
Similar topics: