Heiken Ashi TMS/TDI strategy

Heiken Ashi TMS/TDI strategy

Hi guys.

My first contribution to the strategy site. It’s based on several codes from the site, but mainly the TDI and TMS from both Nicolas and Reiner. I changed the strategy a bit so it fits the Oil- Brent Crude. It seems like that every strategy that I test need to be “adjusted” to the particular instrument. Does anyone do the same, or do you strictly keep the rule? Anyway the code has no zero bar profit nor does it have SL or TP coded, in fact it has only 15 trades over 3 month. It sure could be more “perfect” as there are some entries that could be more profitable. Unfortunately I can only backtest it 3 month. Apparently IG only hold 3 month of data for Crude Oil. It’s tested with a 3 point spread. Anyway here it is, please comment 🙂

Cheers

Kasper

 

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. Nicolas • 08/06/2016 #

    Thank you Kasper for your contribution to the Library. I know this kind of strategy code can help a lot of people around here. You have put together a lot of other people pieces of work in one strategy to make yours and that’s fine. I can say that the objective of the website has been completed 🙂 Sharing our coding knowledge to help each other to better and quickly achieve the hard learning curves to build effective codes, even if they are not perfect. I can see code from Grizzly too and from Adolfo.
    About the strategy, I tested it on PRT-CFD history (which is longer than the IG one), and I find it good too since mid-2015 (no history before that). Understand that the profit curve is not straight, but not deal with massive drawdown at all. Hope to see more from you soon 🙂 

  2. mr.brymas • 08/06/2016 #

    Hi! Thanks for sharing. I´m able to backtest the code a year. Here´s the result:
    http://picgur.org/images/2016/08/07/Skarmavbild2016-08-07kl.17.37.03.png

    • Elsborgtrading • 08/06/2016 #

      thanks for the test. Still not bad, but room for improvement 🙂

    • ALEALE • 08/06/2016 #

      Dear Mr. Brymas ,could you test the optimazed strategy of Elsbortrading below for 1 year ?Thanks All
       

  3. grizzly • 08/06/2016 #

    Great work. I see you’ve used some of my code too 🙂

  4. Dymjohn • 08/06/2016 #

    Hi Casper,
    I see you’ve been busy. Wondering if it would be better  to remove on “shortexit” mab<50 and on “Longsell” mab>50. On recent history this reduces profits but only  minimally but avoids seeing large erosion on the latest trade.
    John

    • Elsborgtrading • 08/06/2016 #

      hi john. Yes quite busy. Regards the  numbers I just found a way to optimise the them. I did not had the time yet

  5. Elsborgtrading • 08/06/2016 #

    The reason i added those limmit is to catch the false breakout of a trade. It will save many orders that othervise would have a huge drawback

  6. Elsborgtrading • 08/06/2016 #

    Hello guys. Using the optimization technique I was able to produce a more profitable code. still without the huge drawback. also it eliminated the one loss I had. I also added an extra streak to the Money Management code. 4 in a row- since we were doing so well.  I’d still like if someone could be kind and test it back further as I still only have data since may 2016
    //-------------------------------------------------------------------------
    //TDI OIL Brent Crude (1£ Contracts) 2H ElsborgTrading V3
    //
    // based on Trend Surfer DAX-Reiner/Nicholas-TMS
    //http://www.prorealcode.com/prorealtime-trading-strategies/trend-surfer-dax/
    //http://www.prorealcode.com/topic/trading-made-simple-tms-system/
    //http://www.forexmt4.com/_MT4_Systems/Traders%20Dynamics/TDI_1.pdf
    //-------------------------------------------------------------------------

    // code-Parameter
    DEFPARAM CumulateOrders = true

    //DEFPARAM FlatAfter = 230000
    //DEFPARAM Flatbefore = 030000

    //MONEY MGT//

    Equity = (Strategyprofit+20000)
    Risk = round(Equity/100000)
    Losses = positionperf(1)<0 and positionperf(2)<0 and positionperf(3)<0
    streak = positionperf(1)>0 and positionperf(2)>0 and positionperf(3)>0
    Streak2= positionperf(1)>0 and positionperf(2)>0 and positionperf(3)>0 and positionperf(4)>0
    if losses then
    PositionSize = max(abs(round(max(3+risk-2,risk-2))),2)
    elsif not losses then
    PositionSize = max(abs(round(max(3+risk,risk))),2)
    endif
    if streak then
    PositionSize = max(abs(round(max(5+risk,risk))),2)
    endif
    if streak2 then
    PositionSize = max(abs(round(max(7+risk,risk))),2)
    endif

    //TDI indicator
    //parameters :
    lengthrsi=13
    lengthrsipl=2
    lengthtradesl=7

    //overbought and oversold values of the TDI indicator
    upperzone = 65
    lowerzone = 7
    //upperzone = upz
    //lowerzone = loz

    //heiken ashi
    xClose = (Open+High+Low+Close)/4
    if(barindex>2) then
    xOpen = (xOpen[1] + xClose[1])/2
    xHigh = Max(xOpen, xClose)
    xLow = Min(xOpen, xClose)
    endif

    //indicators
    r = rsi[lengthrsi](close)
    mab = average[lengthrsipl](r)
    mbb = average[lengthtradesl](r)
    yellowMA = average[5](TypicalPrice)
    yellowMAshifted = yellowMA[2]

    //trade conditions
    longCondition = mab crosses over mbb AND mab<50 AND xHigh>yellowMAshifted
    shortCondition = mab crosses under mbb AND mab>51 AND xLow<yellowMAshifted

    //Longsell=mab crosses under mbb AND mab<upperzone and mab>56 AND xlow>yellowMAshifted
    //Shortexit= mab crosses over mbb AND mab>lowerzone and mab<56 AND xhigh>yellowMAshifted
    Longsell=mab crosses under mbb AND mab<upperzone and mab>55 AND xlow>yellowMAshifted
    Shortexit= mab crosses over mbb AND mab>lowerzone and mab<58 AND xhigh>yellowMAshifted
    //Longsell2=mab crosses under lowerzone
    //Shortexit2=mab crosses over upperzone
    //***************************

    // open position
    // long
    IF Not LONGONMARKET AND longcondition THEN
    BUY PositionSize CONTRACT AT MARKET
    ENDIF

    // short
    IF Not SHORTONMARKET AND shortCondition THEN
    SELLSHORT PositionSize CONTRACT AT MARKET
    ENDIF

    // close position

    IF LONGONMARKET and Longsell then//or longsell2 THEN
    SELL AT MARKET
    ENDIF
    IF SHORTONMARKET and Shortexit then//or shortexit2 THEN
    EXITSHORT AT MARKET
    ENDIF

    // stop and profit
    //SET STOP pLOSS sl
    //SET TARGET pPROFIT tp

     

  7. miguel33 • 08/06/2016 #

    Ho notato che sembra dia buoni risultati su GBP/USD  (la prima versione del codice) 
    Chi può postare un backtest più lungo ?
    Grazie.
    Miguel 

  8. grizzly • 08/06/2016 #

    Can i suggest, that this piece of code:
    Risk = round(Equity/100000)be changed to
    MaxPositionA = 50
    Risk = min(round(Ratio*Equity/100000)*1,MaxPositionA)
    Otherwise, risk -> infinity haha

    • Elsborgtrading • 08/06/2016 #

      Very nice Grizzly. I properly would have done some beginners programming like this, but yours has more “pronage” 🙂 My code is only running on Live demo for at least 3 month before considering investing real money in it. Mainly due to the small backtesting range- but if It would make it to real investment, I thing I also would start with only 1 contract
      If PositionSize>=50 then
      PositionSize=50
      endif
      to begin with

    • Elsborgtrading • 08/06/2016 #

      Grizzly, what should Ratio be?

  9. DerPat • 08/06/2016 #

    I am also interested in your forward testing, as backtesting results are useless.

    • Elsborgtrading • 08/06/2016 #

      I agree, but since we don’t have any SL or TP at all, or any Profit on zero candle, I think it safe to say that this backtest is more useful. However 3 month is somewhat not enough.

avatar
Register or

Likes

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

+2 more likes

Related users ' posts
imonix Have been trying this on demo since Monday before deciding whether to go live with it. Using...
Roberto Blázquez I'm sorry, I've tried it since November 2012 and it's bad results.
rafadonl2 is not taken into account in the procedure. It considers only if it is a doji or when candle...
Guibourse Okay thanks, just a question : how do you plot your two lines in the same window as price ? ...
rafadonl2 sorry, I don't understand your question. Indicator draws Heikin Ashi candle, not price cand...
bearbull As per PhilipSchultz question above, has anybody managed to add code for when it turns blue,...
Ybr35 Bonjour Nicolas, lorsque je lance l'indicateur, il m'est indiqué que je dois définir les var...
Nicolas L'idéal est de télécharger le fichier itf joint sur cette page et de l'importer dans la plat...
wtangsiri Bonsoir Qu'appelez vous l'axe vertical et comment le définir ? Merci pour votre aide.
rafadonl2 Pardonnez-moi mais je ne sais pas ce que vous entendez par "axe vertical". Serait-ce la lig...
rafadonl2 Je viens de voir ce que vous voulez dire. Comme pour tout autre indicateur, vous devez défin...
rafadonl2 Prueba la nueva version que acabo que poner. Incluye regresion lineal y elimina señales en t...
rafadonl2 prueba la nueva version que acabo de poner. Usa regresion lineal y elimina muchas señales en...
rafadonl2 te adjunto el código. //Reglas en Heikin-Ashi: //1- Secuencia de cuerpos verdes = tenden...
Nicolas Pour les demandes spécifiques, merci d'ouvrir un sujet sur le forum des screeners en respect...
Djamal Zidane hello tout le monde , marcara ton objectif est tjrs de l'actualité?
Gover66 Hello, I would like to limit the screener to the last 5 bars only, is this possible?
Doctrading Chez IG markets, on est effectivement plus limité.C'est pourquoi j'utilise ProRealTime CFD. ...
pascal3431 il semble que cette stratégie ne fonctionne pas avec des stop loss : y a t'il un moyen de li...
alfcont The first time that the system open a position it should buy or sell one contract, after the...
tahar Bonjour, je travaille sur un ecran noir et les bougies sont extremement palotes, on distingu...
Alai-n Voir Echantillons de Couleurs RVB : https://www.prorealcode.com/documentation/category/instr...
Guillaume34 Bonjour, quelqu'un à t'il réalisé ce code à l'identique mais pas dans une fenêtre sous le gr...
Nicolas
9 years ago
Nicolas Any timeframe possible, this indicator is only an RSI with bands made of standard deviation.
nellycopter hi do you have the TDI indicator pls..
Nicolas You can download the TDI indicator here: https://www.prorealcode.com/prorealtime-indicators/...
Nicolas oui c'est possible, je pense même que cela a été codé X fois déjà, je vais chercher.
iloco17 Bonjour Nicolas Par rapport à ce code je souhaiterais la ligne de code qui permet d'identi...
Nicolas Merci de formuler une demande dans le forum ProScreener.
Nicolas
9 years ago
Guibourse HI, I wonder how to change the mid line color depending on its growing or declining evolutio...
Brent38 Bonjour à tous, Post tardif, mais on débute tous un jour, et moi je découvre Prorealcode. ...
Nicolas Oui en effet, le TDI c'est un RSI lissé avec des écarts types sur sa moyenne.

Top