Hi guys, I would like to share with you this strategy I have implemented. Work with Heiken Ashi candles on the Dax H1, Nasdaq H1 and ITA 40 H1 indices.
I tried to do backtest on forex H1 and H1 commodities but it doesn’t work and also on indices in other timeframes besides H1 but I didn’t find good results. I share the code with you so that some of you more experienced can improve the drawdown or add some filters that improve the performance.
For me it is always a pleasure to compare myself with the most experts so feel free to comment to give your opinions.
Thank you all
PS This is the first time that I have published a strategy because I have started programming again after a long time, I have not been able to insert more photos of the results and the code file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
DEFPARAM PreLoadBars = 300 DEFPARAM CumulateOrders = False //DEFPARAM FLATBEFORE = 070100 // Trading System doesn't open trade after 00:00 and before this time hhmmss //DEFPARAM FLATAFTER = 205900 // Trading System doesn't open trade after this time hhmmss //Finestra Temporale Finestra = CurrentTime > Prima and CurrentTime < Dopo // HA - Definition Heikin-Ashi**************************** once xOpen = open xClose = (open+close+high+low)/4 if barindex > 0 then xOpen = (xOpen[1]+xClose[1])/2 endif xLow = min(low,min(xClose,xOpen)) xHigh = max(high,max(xClose,xOpen)) xRange = abs(xHigh - xLow) xBody = abs(XClose - xOpen) //******************************************************* //Indicator MyRSI = RSI[14](close) // Close Position on Friday after Time: hhmmss*********** TempoScaduto = OpenDayofWeek = 5 and CurrentTime > 205900 // Add "n" Point/Pips at MystopLoss //Npips = 2 * pipsize //Condizione BUY******************************************* c2 = xRange < xRange[1] // il range della candela che crea il segnale è minore di quello della candela precedente c3 = xClose > xOpen // Candela Rialzista c31= xClose[1] < xOpen[1] //la candela precedente è ribassista c33 = MyRSI[1] < BuyRsi or MyRSI[2] < BuyRsi //MyStop1 = abs((xClose - Lowest[2](xLow))- Npips) // il minimo tra 2 minimi fa - Npips //MyProfit1 = TradePrice + (abs (MyStop1*2)) //Condizione SELL****************************************** c4 = xRange < xRange[1] // il range della candela che crea il segnale è minore di quello della candela precedente c5 = xClose < xOpen // Candela Ribassista c51 = xClose[1] > xOpen[1] // la candela precedente è rialzista c55 = MyRSI[1] > SellRsi or MyRSI[2] > SellRsi //MyStop2 = abs((xClose + Highest[2](xHigh))+ Npips) // il massimo tra due massimi fa + Npips //MyProfit2 = TradePrice - (abs (MyStop2*2)) // Condizioni per entrare su posizioni long****************** IF NOT LongOnMarket and c3 and c31 and C33 and Finestra THEN BUY 1 CONTRACTS AT MARKET SET STOP pLOSS sellstop //se inserisco MySTop1 devo togliere la "p" prima di LOSS SET TARGET pPROFIT gain //se inserisco MyProfit1 devo togliare la "p" prima di PROFIT ENDIF // Condizioni per uscire da posizioni long********************** If LongOnMarket AND TempoScaduto THEN SELL AT MARKET ENDIF // Condizioni per entrare su posizioni short******************** IF NOT ShortOnMarket and c5 and c51 and c55 And Finestra THEN SELLSHORT 1 CONTRACTS AT MARKET SET STOP pLOSS perditashort //se inserisco MySTop2 devo togliere la "p" prima di LOSS SET TARGET pPROFIT gainshort //se inserisco MyProfit2 devo togliare la "p" prima di PROFIT ENDIF // Condizioni per uscire da posizioni short************************ IF ShortOnMarket AND TempoScaduto THEN EXITSHORT AT MARKET ENDIF //************************************************************************ //trailing stop function trailingstart = x //trailing will start @trailinstart points profit trailingstep = y //trailing step to move the "stoploss" //reset the stoploss value IF NOT ONMARKET THEN newSL=0 ENDIF //manage long positions IF LONGONMARKET THEN //first move (breakeven) IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN newSL = tradeprice(1)+trailingstep*pipsize ENDIF //next moves IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN newSL = newSL+trailingstep*pipsize ENDIF ENDIF //manage short positions IF SHORTONMARKET THEN //first move (breakeven) IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN newSL = tradeprice(1)-trailingstep*pipsize ENDIF //next moves IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN newSL = newSL-trailingstep*pipsize ENDIF ENDIF //stop order to exit the positions IF newSL>0 THEN SELL AT newSL STOP EXITSHORT AT newSL STOP ENDIF //****************************************************** |
Share this
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 :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
ciao, prova a togliere il giorno del venerdì sia dal nasdaq che dal dax. si riduce il drawdown e aumenti i guadagni.
inserisci nel programma :
TradingDay = OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 4
e poi aggiungi la condizioni di entrata nel programma
per il mib lo spread è troppo alto e non lo vedo bene, gli antri 2 sono bene secondo me
ciao
Alberto
Buonasera, I downloaded the ” Sistema HA – ITA 40 – 1 HOUR ” but when i run that, it says a lot of variables are not utilized…. did you or someone checked that?
Thanks for this @lupo32, I’ve taken a copy of sistema-ha-dax-1-hour.itf this morning and simplified some of the code, taking out some of the unused variables and conditions. I’m getting really good backtest results and will play with it further! (struggling to paste the code atm)
Thank You Aaron
ITF: drive.google.com/file/d/1p6BnBGLZ-3iB1DavsGi13n0yPa3PUqes/view?usp=sharing
Hello, I´m trying to paste the code and start testing but can´t get it to work in PRT. Should it be fully functional or is this pieces of the code?
I’m having no more issue on the new Prorealtime release 11.1