Kama & Sma Trading System DAX mtf
Forums › ProRealTime English forum › ProBuilder support › Kama & Sma Trading System DAX mtf
- This topic has 7 replies, 3 voices, and was last updated 4 years ago by segie.
Viewing 8 posts - 1 through 8 (of 8 total)
-
-
01/06/2020 at 12:56 PM #116041
Hi,
Can the attached code be converted to an indicator with “buy” or “sell” text/ signals?
Regards,
Segie
Kama & Sma Trading System DAX mtf123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134//************************************************************************// Kama & Sma Trading System DAX mtf//************************************************************************//DEFPARAM CumulateOrders = FalseDEFPARAM PreLoadBars = 2000////////////////////////////////////////////////////////////////////////TIMEFRAME (default)ONCE nLots = 1ONCE LongTrading = 1 //1=allowed 0=bannedONCE ShortTrading = 1 //1=allowed 0=banned//ONCE TP = 200 //200 pipsONCE SL = 50 //50 pips//TimeForbidden = OpenTime < 090000 AND OpenTime > 190000LongCond = (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 nLots CONTRACT AT MARKETTradeON = 0ENDIF//************************************************************************// SHORT trades//************************************************************************IF b1 AND TradeON AND ShortCond THENSELLSHORT nLots 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 MarketENDIFENDIF01/06/2020 at 2:09 PM #116055Try this.
I couldn’t test it since I haven’t my PC available:
123456789101112131415161718192021222324252627282930// Kama & Sma//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 Smax = 0If a1 thenx = 1Elsif b1 thenx = -1EndifReturn x01/06/2020 at 2:25 PM #116056Hello,
Me it works TF 15 minute.
Attention French time1 user thanked author for this post.
01/06/2020 at 3:45 PM #11606501/06/2020 at 5:09 PM #116077In my code I can’t see any source if error at line 3.
If it’s the code in the ITF file, then I cannot open it now.
If you post that code I might help you.
01/07/2020 at 12:39 PM #11612101/07/2020 at 2:13 PM #116129Try deleting those characters (even if they are a blank).
Or you may import the attached file, in case copy & paste was not correct.
1 user thanked author for this post.
01/07/2020 at 8:01 PM #116165 -
AuthorPosts
Viewing 8 posts - 1 through 8 (of 8 total)
Find exclusive trading pro-tools on
Similar topics: