Pro back-testing bullish / bearish heikin-ashi simple signal / variable
Forums › ProRealTime English forum › ProOrder support › Pro back-testing bullish / bearish heikin-ashi simple signal / variable
- This topic has 17 replies, 3 voices, and was last updated 2 years ago by JS.
-
-
08/31/2022 at 2:40 AM #199923
Dear all,
Apologies, first of all, for my ignorance in this subject:
I am trying to simply combine the bullish heikin-ashi (green candle) closure with one moving average overcrossing (for longs) and a bearish heikin-ashi (red candle) clousure with moving average undercrossing (for bearish). The application does not have the variables to back-test on the basis of such condition of a heikin-ashi signal (bullish or bearish signal -first green or red candle) – (case by case). Hence, I would like to ask if any of you could be so kind to let me know how would the variable in the backtesting code should read to that effect. Thank you very much in advance.
08/31/2022 at 4:33 AM #199924Apologies for the second post in a row (unfortunately I could not amend the previous one, sorry for this).
Meanwhile, I found a previous topic dealing partly with my question (pending to be answered; how to combine heikin-ashi with crossing (over and/or under a simple moving average): https://www.prorealcode.com/topic/heikin-ashi-auto-buy-sell-based-on-collor-change/
Based on that information I came up with the below “back test code” for the SP500 but it is not showing any results when I ask the application to generate the report, (I must be missing something due to my ignorance):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354// Festlegen der Code-ParameterDEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert// Heikin Ashi setuponce xOpen = openxClose = (open + close + high + low) / 4if barindex > 0 thenxOpen = (xOpen + xClose[1]) / 2endifxLow = min(low,min(xClose,xOpen))xHigh = max(high,max(xClose,xOpen))//Bullish = xClose > xOpenBearish = xClose < xOpen// Bedingungen zum Einstieg in Long-Positionenindicator1 = CALL Average[50](close)c1 = (Bullish AND Bearish[1]CROSSES OVER indicator1)IF C1 THENBUY 1 CONTRACT AT MARKETENDIF// exit LONG trade on a Bearish candlestickindicator1 = CALL Average[50] (close)c2 = (Bearish CROSSES UNDER indicator1)IF c2 THENSELL AT MARKETENDIF// Heikin Ashi setuponce xOpen = openxClose = (open + close + high + low) / 4if barindex > 0 thenxOpen = (xOpen + xClose[1]) / 2endifxLow = min(low,min(xClose,xOpen))xHigh = max(high,max(xClose,xOpen))//Bullish = xClose > xOpenBearish = xClose < xOpen// SHORT trades when switching from bullish to bearishindicator1 = CALL Average[50] (close)c3 = (Bearish AND Bullish [1] CROSSES UNDER indicator1)IF c3 THENSELLSHORT 1 CONTRACT AT MARKETENDIF// exit SHORT trade on a Bullish candlestickindicator1 = CALL Average[50] (close)c4 = (Bullish CROSSES UNDER indicator1)IF c4 THENEXITSHORT AT MARKETENDIF08/31/2022 at 6:49 AM #19992708/31/2022 at 9:04 PM #19999108/31/2022 at 11:15 PM #199996Hi @jonpt88
When you use 1 moving average and you want to go both long and short, your base code is limited to:
(xClose = (Open + Close + High + Low) / 4)
If xClose crosses over Average[50](Close) then
Buy 1 contract at Market
EndIf
If xClose crosses under Average[50](close) then
SellShort 1 contract at Market
EndIf
1 user thanked author for this post.
08/31/2022 at 11:39 PM #19999709/18/2022 at 5:45 PM #20097509/18/2022 at 5:53 PM #20097609/23/2022 at 3:55 AM #20122409/23/2022 at 8:43 AM #201232Hi @jonpt88
I have modified your first code, Heikin Ashi + Moving Average
You can now back test the code
For optimization, you can run the period of the Moving Average, for example, between 1 and 100
Heikin Ashi + Average1234567891011121314151617181920212223242526272829303132333435363738394041// Festlegen der Code-ParameterDEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviertOnce n=16// Heikin Ashi setuponce xOpen = openxClose = (open + close + high + low) / 4if barindex > 0 thenxOpen = (xOpen + xClose[1]) / 2endifxLow = min(low,min(xClose,xOpen))xHigh = max(high,max(xClose,xOpen))//Bullish = xClose > xOpenBearish = xClose < xOpen// Bedingungen zum Einstieg in Long-Positionenindicator1 = Average[n](close)c1 = (Bullish AND Bearish[1]) and xClose Crosses Over indicator1IF C1 THENBUY 1 CONTRACT AT MARKETENDIF// exit LONG trade on a Bearish candlestickc2 = (Bearish and xClose Crosses Under indicator1)IF c2 THENSELL AT MARKETENDIF// SHORT trades when switching from bullish to bearishc3 = (Bearish AND Bullish[1]) and xClose Crosses Under indicator1IF c3 THENSELLSHORT 1 CONTRACT AT MARKETENDIF// exit SHORT trade on a Bullish candlestickc4 = (Bullish and xClose Crosses Over indicator1)IF c4 THENEXITSHORT AT MARKETENDIF1 user thanked author for this post.
09/23/2022 at 7:54 PM #20125409/23/2022 at 7:57 PM #20125509/23/2022 at 7:59 PM #20125609/23/2022 at 8:20 PM #201257You can add an extra condition with RSI for example:
C1 = (Bullish and Bearish[1]) and xClose Crosses Over indicator 1 and RSI(16) Crosses Over 20
C3 = (Bearish and Bullish[1] and xClose Crosses Under indicator 1 and RSI(16) Crosses Under 80
1 user thanked author for this post.
09/23/2022 at 8:36 PM #201258 -
AuthorPosts
Find exclusive trading pro-tools on