Kama & Sma Trading System DAX mtf

Kama & Sma Trading System DAX mtf

Coded for micro DAX €1 (simply multiply by 25 to run on standard DAX €25 or by 5 to run on mini DAX €5), 1-hour TF.

I used the Multiple Time Frame support to allow Breakeven/Trailing Stop to run on 1-minute bars (default TF).

Strategy from https://www.forexstrategiesresources.com/trend-following-forex-strategies/111-kama-strategy/.

Compared to the original version at the above link, I only optimized the SMA (called MVA in the above site) and set it to 22, instead of 7.

I also added SL & TP plus my own Breakeven/Trailing Stop code snippet.

Lines 10-11 allow to enable/disable Long/Short trading (both enabled by default).

Lines 21-25, along with lines 54-61 and lines 67 and 74, ban further trading before a whole 1-hour bar has elapsed, in case a trade exits within a few 1-minute bars. In such case the 1-hour signal is still set and valid, but it would most likely lead to a losing trade since the momentum is likely to have faded.

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. CN • 08/21/2019 #

    You mean coded for the 1-min TF?

  2. robertogozzi • 08/21/2019 #

    It’s a Multiple Time Frame strategy.
    It must be launched from a 1-minute chart, but signals are generated on the 1-hour TF.

    • Philstrading • 08/21/2019 #

      Ok I just noticed your lower down comment about opening u pnew topic… sorry about that…. I’ll maybe traul the code a little and backtest, but backtestingon 4hr gives good results.. Think Ineed tounderstand its principles though to manage properly so a coding traul may be my best option…. Cheers for the code in principle anyway.. Currently its trailing stop for positive stoploss so that seems to be working.. Thumbs up there, Hi Robert. problem with open time – I copied this code try and MTF running from the 4hr doensnt pose an issue, whereas normally one woul dneed to go to the LTF as you’ve said elsewhere. I’ve backtested this off the 4hr with good results so thought to try live, though a bit dubious about running unwritten code as I’ve started doing my own, I have put it up live to review on live testing. The issue this morning was that it opened a trade at 0400hrs.??!!?!?! Looking at the code there’s no reference to not timeforbidden (not timeForbiddenEntry AND ) that I can see in the enter trade code… So this code seems to backtest on the 4hr OK, and it launches from the 4hr wihtuot error messages and appears to treigger trades and closes them off . So question is since the trade opened at 0400hrs this morning London time do I have to contact PRT support tickets? or is it a coding error.. I’ve added the code but cant see it displayed ….

    • robertogozzi • 08/21/2019 #

      Sorry for replaying so late, I really missed your post.
      There is a discussion thread here https://www.prorealcode.com/topic/kama-sma-trading-system-dax-discussion-thread/
      Lines 17-18 deal with trading hours.

  3. CN • 08/21/2019 #

    Sure Roberto, but didn’t get any trades on the 1H TF, so trading TF should be 1-min 🙂

  4. robertogozzi • 08/21/2019 #

    Yes.
    You need to search MTF to read what it is all about and understand how it works.
    You will only see trades on your 1-minute chart.

  5. Jesper • 08/21/2019 #

    What should be multiplied in order to compensate för other contracts size?

  6. robertogozzi • 08/21/2019 #

    Line 9, nLots is the number of contracts, you can change it as best suits you.

    • Jesper • 08/21/2019 #

      Ah, that’s what I thought as there were no ties in to the actual logics. Thanks!

  7. Edurecio • 08/21/2019 #

    I do not understand.
    Even if you change “time forbidden,” the system still produces the same results, with entries within that range.

    TimeForbidden = OpenTime 190000

  8. Jungblom • 08/21/2019 #

    I have ran this now for today and now @15:00 i got a “Alert triggerd for a sell Qty-1” and @ 15:05 I got a new alert on Buy (exit) qty +1 but no trades where triggerd why is that? Running with max position size of 2 contracts. when i backtest it a trade should have been done at these timestamps.

  9. robertogozzi • 08/21/2019 #

    If you want to discuss about inner workings or detail, please open a new topic on the ProOrder Support Forum and always attach detailed pics (instrument,TF,date and time should be visible), along with details posted.
    Thank you.

  10. winnie37 • 08/21/2019 #

    it could be tested on larger historic?

  11. robertogozzi • 08/21/2019 #

    If someone has access to 200K data history might post results (it would be better to start a topic on the ProOrder support forum). Upcoming v11 will support up to 1M bars of data history.

    • Gregg • 08/21/2019 #

      Hi Roberto, thanks for this new strategy but I don’t understand why I can’t backtest it with 200K units… it stops after 6 trades.

    • robertogozzi • 08/21/2019 #

      There must be an issue with candlestick data from March 7th through March 12th. which causes backtest to stop at 15:04 om March 7th.
      If you make your backtest start from 00:00 March 13th, then it works fine.
      I will report this to PRT/IG.

  12. avatar
    Anonymous • 08/21/2019 #

    Hi, I found the same problem with the time forbidden code but I have messed about with it using some code that I use for day trading and money management along with altering the stop size based on the trades taken in the last 100k bars.

    • robertogozzi • 08/21/2019 #

      There must be an issue with candlestick data from March 7th through March 12th. which causes backtest to stop at 15:04 om March 7th.
      If you make your backtest start from 00:00 March 13th, then it works fine.
      I will report this to PRT/IG.

  13. avatar
    Anonymous • 08/21/2019 #

    https://www.prorealcode.com/topic/kama-sma-trading-system-dax-discussion-thread/

  14. Jan Wind • 08/21/2019 #

    Sorry if I missed the latest discussions recently, but is MTF now usable and reliable in PRT production environment ?

  15. robertogozzi • 08/21/2019 #

    MTF was officially made available to all customers 2-3 months ago after almost a year being beta tested.

  16. Zebra • 08/21/2019 #

    OpenTime < 090000 AND OpenTime > 190000 should probably be OpenTime < 090000 OR OpenTime > 190000

  17. alfcont • 08/21/2019 #

    Is this trading system generating profit on micro DAX future?

  18. frenqle • 08/21/2019 #

    can i put a completely different strategy under this strategy in the same code? or do i have to put 2 strategies separate in prorealtime?

    • robertogozzi • 08/21/2019 #

      You can read this topic (https://www.prorealcode.com/topic/multiple-strategies-within-one-trading-system/#post-41278) and keep posting there, if you need to.

  19. Gaby • 08/21/2019 #

    Thanks Roberto to post this Kama SMA strategy.

  20. pat95162 • 08/21/2019 #

    Bonjour
    J’ai beau essayer de le faire fonctionner sur du 1H, 15 min 5 min ou 1 min, rien ne fonctionne.
    Quelle est la procédure à suivre pour avoir vos résultats ?

    • robertogozzi • 08/21/2019 #

      Cela fonctionne bien, peut-être que vous avez fait un mauvais copier-coller, je ne sais pas.
      Ouvrez un thread dans le support ProOrder et publiez le code.

  21. RemiNhAPQM • 08/21/2019 #

    Bonjour,
    merci pour le super partage, la stratégie offre des très beaux résultats.
    Je ne suis pas expert dans le code de ProOrder et du coup je n’arrive pas à comprendre les principes de base du stop suiveur que vous avez codé, pouvez-vous mes les expliquer rapidement ?
    Un grand merci par avance,
    Cordialement.

  22. frenqle • 08/21/2019 #

    Hi there, I have been using this code for months now.. I adjusted some code and it worked fine.. recently it started having trouble it started giving me the following error:

    The trading system was stopped because the historical data loaded was insufficient to calculate at least one indicator during the evaluation of the last candlestick. You can avoid this in the future by changing the number of preloaded bars with the instruction DEFPARAM (ex: DEFPARAM Preloadbars = 10000).

    So I tried to search for errors.
    Now I entered the original code which is posted here on prorealcode to see if it still works. I run it on the DAX 10 minutes, but this code also gives the same error.
    Does anyone know why this code isn’t working anymore? Are there software updates or something?

    Hope to hear from you!

  23. frenqle • 08/21/2019 #

    Every 10 minutes it gives this error..

  24. robertogozzi • 08/21/2019 #

    There’s no apparent reason, as far as I know.
    You can increase line 6 up to 10000.
    You can try shutting down your system, then restarting it. Maybe this will do.

  25. frenqle • 08/21/2019 #

    I tried it all several times..:(.. I can’t get it to work anymore for 2 weeks now

  26. robertogozzi • 08/21/2019 #

    I also was returned the same error message.
    I opend a ticket with PRT assistance. I will let you know any answer as soon as I get it.

    • frenqle • 08/21/2019 #

      Lets hope they give some answers. I opened a ticket too but I got no response.

  27. frenqle • 08/21/2019 #

    No news??

  28. robertogozzi • 08/21/2019 #

    It’s too early, usually it takes a couple of weeks or more.
    I’ll post any news as I get it.

    • robertogozzi • 08/21/2019 #

      ProRealTime reported no issues with the PreLoaded bars.
      I tested it on DAX, 1-minute TF, and it opened trades regularly now.
      There must have been a temporary issue while IG was working with some updates.

  29. frenqle • 08/21/2019 #

    Great thanks a lot! Will run it on 10 minutes again!

  30. frenqle • 08/21/2019 #

    But it has not opened positions since 13 of april.. thats what the backtest says…

  31. robertogozzi • 08/21/2019 #

    On 1-minute TF it works, on a 10-minute TF it may be due to lack of signals.

    • frenqle • 08/21/2019 #

      I have it on 1 minute but still 13 april is the latest its doing

    • robertogozzi • 08/21/2019 #

      The error you reported has been fixed, now the strategy enter trades regularly in AutoTrading.
      I have experienced that sometimes the backtest doesn’t open trades AFTER April 14th, 2021. I tried to close backtest, then switch to 50K units, then 200K, then back to 50K, on both 1-minute and 10-minute TF’s and sometimes it worked, sometimes it didn’t.
      I reported this issue to ProrealTime. Please so do you.

  32. frenqle • 08/21/2019 #

    Done!! thanks Roberto, it is running again!

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar

+28 more likes

Related users ' posts
jonashultgren Thanks! Very good work
Bastrucco Hi John, thank you very much for this strategy. Works quite well. Have you also considered u...
adconsulting SCUSA . ECCO IL CODICE defparam cumulateorders = true // false is working well once ord...
wally Hola soy nuevo en el mudo robots. Alguien seria tan amable de poner el archivo itf.file ya q...
Darren Nash I found this works well on the DOW
ChemaGeek Bonjour Nicolas, j'ai récemment découvert cet indicateur (Regularized Momentum 2017) et je l...
YvesRobert Bonjour, nouveau sur PRT (qq jours), j'essaie un peu de voir quel type d'indicateur me convi...
cdc.andersson Hello, I´m trying to paste the code and start testing but can´t get it to work in PRT. Shoul...
Lupo32 Thank You Aaron
superfalcio I'm having no more issue on the new Prorealtime release 11.1
Paris On est bien d accord que l indicateur repeint ....
Nicolas naturellement si la bougie du timeframe supérieur n'est pas terminé
ThePenntChemist Does this show 5min time frame?
IV Mcm Good job !
Vonasi There are actually two ways to calculate standard deviations and I seem to have used the ver...
segie Can something similar be done with Supertrends?
Vonasi Not sure I fully understand what you are asking for. Are you asking for MTF Supertrend level...
Kris75 very interesting; thanks !
FXmike hey my friends, thank you for this great code. my problem is he make no trade open. backtest...
FXmike Can i put a Action that my start contract is smaller than 1 ? 0.3 or 0.5 ? In wich Position...
phoentzs I wrote the code for M15 back then and also variants in H1 and M1. Everything works so far....
Jan Wind Thanks for sharing ! The Gain/Loss ratio is a bit low, 1,16, hardly offset the risks take...
drive whats the period ?
Ciurno981 il suffit de changer le nombre de contrats à acheter
Ciurno981 Does anyone have the data at 200,000 units, why would I like to see over 5 years?
Ludwig Bonjour Merci pour le code, je souhaite intégrer un break even et mette en place un réinves...
Dom Hello, hello....je commence le trading et découvre par la même occasion le codage....et ce n...
Nicolas Merci, ça fait plaisir !
Be-n Bonjour tout le monde ! Dans l'indicateur de tendance, j'ai du mal à saisir la nuance entre ...
jiddan78 how to convert to afl amibroker ?
Nicolas We do not supply free coding assistance for AFL Amibroker on the website. You can ask for pa...
Ngomsi @ Vonasi, how to use timeframe , 13 minutes ,21 minutes, 34 minutes,et 55 minutes with this...
samsampop Hi robertogozzi - thank you very much for sharing this strategy. I have performed various ...
robertogozzi Thank you samsampop.
Dotan Hello guys I really appreciate this coding effort but can I use this code for Mt5 Forex Trad...
Gubben So far so good. After a long drawdown it was winning four times in five weeks. Since 24 jul...
pat95162 Salut Pourquoi je n'ai pas les même résultats que vous
UkCoopDownUnder Any hints for us, on which variables we should be optimising ? As of November 2020, the cu...
TempusFugit Interesting idea and with a lot of room for improvement.... maybe a trailing stop? Thanks fo...
Jan Wind Unglaubich das dieser Strategie Gewinne generiert ! Es erschient leider nicht so gleichmaßi...
Peter I recognized a possible problem with the timeframe / Defparam variables. As far as I know, t...
ALZ Hello, currently, I don't have the same result as above and don't no if it works good in...
JJ Tec Hola. Me gustaría contactar contigo para ver la estrategia..
nilsla1981 Has someone already tested in real ?
JOKAMAURICE Thank you but I don't really understand. The values don't fit with what I see on my chart. I...
Alberto Aguilera Hi! Thanks for your strategy Anyone can check it with 200 bars?
TempusFugit Hi, this simple system for DOW and only shorts has worked quite well, maybe because of its q...
phoentzs Unfortunately, I never pursued this strategy further. Maybe I should take a look with what ...
illenza
3 years ago
ribes65 Buongiorno Illenza, Il tuo indicatore è molto efficace, ma non funziona su tutte le azion...

Top