Heiken Ashi Smoothed Strategy – Help Please
Forums › ProRealTime English forum › ProOrder support › Heiken Ashi Smoothed Strategy – Help Please
- This topic has 10 replies, 4 voices, and was last updated 3 years ago by SB-FO.
-
-
03/02/2021 at 1:39 AM #162910
I’m trying to turn the smoothed Heiken Ashi smoothed : Forum ProBuilder support – ProRealTime (prorealcode.com) from the blog into an equity strategy, which I still need to backtest. I think it is missing the price as I cannot get it to make a trade. Code is below. Happy to post backtest as a strategy once complete.
Stuart
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859DEFPARAM CumulateOrders = False // Cumulating positions deactivatedDEFPARAM FLATBEFORE = 093000DEFPARAM FlatAfter = 154500capital = 100000 + strategyprofitEquity = capital / closemyCurrentProfit = STRATEGYPROFIT// t and the deviation of the mean://t = 0 = average // Simple//t = 1 = exponentialaverage//t = 2 = weightedaveraget = 3 = wilderaverage//t = 4 = triangularaverage//t = 5 = endpointaverage//t = 6 = timeseriesaverageP = 6P1 = 2T1 = WeightedAverageif barindex > p + 1 thenmo = average[p,t](open)mc = average[p,t](close)ml = average[p,t](low)mh = average[p,t](high)//endifonce haopen=mohaclose=(mo+mc+ml+mh)/4haopen=(haopen[1]+haclose[1])/2endifHAopen1 = average[p1,t1](haopen)HAclose1 = average[p1,t1](haclose)// Draw indicatorGraph HAopen1 COLOURED(34,139,3) AS “Heiken Smoothed Cloud Open”Graph HAclose1 COLOURED(225,0,0) AS “Heiken Smoothed Cloud Close”// Conditions to enter long positionsIF NOT LongOnMarket AND HAopen1 Crosses Over HAclose1 THENBUY Equity SHARES AT MARKETENDIF// Conditions to exit long positionsIf LongOnMarket AND HAopen1 Crosses Under HAclose1 THENSELL AT MARKETENDIF////Conditions to enter short positionsIF NOT ShortOnMarket AND HAopen1 Crosses Under HAclose1 THENSellshort Equity SHARES AT MARKETENDIF// Conditions to exit short positionsIF ShortOnMarket AND HAopen1 Crosses Over HAclose1 THENEXITSHORT AT MARKETENDIF03/02/2021 at 8:45 AM #162917You know that you have to rem-out lines 37, 38 (//Graph…) before launching?
03/02/2021 at 9:27 AM #16292403/02/2021 at 5:29 PM #162968Nicolas,
First, thank you. Second, I am probably displaying my ignorance below, but this is how we learn.
While that works, results are not the same as the indicator when using 3, 2 seems to be closer. I had surmised that T1 was a smoothing type and thus thought I could define the smoothing / averaging type, in this case WeightedAvergae? Using a number might also mean it is just using a number. How should I know which?
Flatafter / flatbefore did not influence the graphing, but point taken. I had understood form my reading that PRT will just sell at the defined time no matter what time frame for the strategy? Flat before will start at the defined time and wait for the next signal after defined start time.
Cheers, Stuart
03/02/2021 at 7:06 PM #16297703/02/2021 at 8:57 PM #162981Thank you all. I have made the changes and yes, it works. My questions now are:
- where is any documentation that define T, thus the averaging types ?
- Will PTR backtest the various types of averaging by adding as a variable T and 0-6?
Again, thank you all for your help. Il post backtest results once completed.
Stuart
03/02/2021 at 9:36 PM #162985https://www.prorealcode.com/documentation/average/
Yes you can run T as a variable, 0-6 in v10.3 or if you’re using v11 then it’s 0-8 as follows:
0 = SMA
1 = EMA
2 = WMA
3 = Wilder
4 = Triangular
5 = End point
6 = Time series
7 = Hull (PRT v11 only)
8 = ZeroLag (PRT v11 only)
03/02/2021 at 10:10 PM #16298703/02/2021 at 10:21 PM #162990it knows insofar as the syntax is
average[p,t]
where p is the period and t is the type.
1 user thanked author for this post.
03/02/2021 at 10:29 PM #162992average[p,t] where p is the period and t is the type.
….and if no value for t is defined then it defaults to zero and returns a simple moving average.
1 user thanked author for this post.
03/02/2021 at 11:33 PM #162995 -
AuthorPosts