Wanted help to backtesting indicator type Larry Williams
Forums › ProRealTime English forum › ProOrder support › Wanted help to backtesting indicator type Larry Williams
- This topic has 17 replies, 3 voices, and was last updated 4 years ago by Zigo.
-
-
05/09/2020 at 12:43 PM #130733
I manually tested a version of the Larry Williams approach, the results where not outstanding but nevertheless I can see possibilities. The principle : entering the market, depending on the previous candle. Normally it is usted on a dayly timeframe and on forex pairs, but I have transformed it to every timeframe and every instrument. Manually it works.
In reality I tested the indicator yesterday on a 45 min graph. The parameters didn’t seemed optimal and trerefore I tried to programme a backtest scenario but, it failed.
Here is the indicator:
Larry Williams Lines 2.012345678910111213141516171819202122232425Defparam drawonlastbaronly = truef=0.2KH= high[1]KL=low[1]up=KH* f/100Dn=KL*f/100P=openU= P + upL= P - dn//TekenenDRAWSEGMENT(barindex, u, barindex[3], u)coloured(5,155,5,255)DRAWSEGMENT(barindex, L, barindex[3], L)coloured(175,75,75,255)DRAWTEXT(" Go Long above =#U#", barindex, U, dialog, bold, 20)coloured(5,155,5,255)DRAWTEXT(" Go Short under =#L#", barindex, L, dialog, bold, 20)coloured(175,75,75,255)TP=u+(0.89*(u-l))St=l-(0.89*(u-l))DRAWSEGMENT(barindex, TP, barindex[3], TP)DRAWSEGMENT(barindex, St, barindex[3], St)DRAWTEXT(" TP Long / Stop Short=#TP#",barindex,TP, dialog,standard, 20)coloured(255,255,255,255)DRAWTEXT(" TP Short / Stop Long=#St#", barindex, St, dialog,standard, 20)coloured(255,255,255,255)return u,l05/09/2020 at 12:51 PM #13073405/09/2020 at 12:56 PM #130737I show the backtest who works but give Always 0 trades.
Backtest Williams 2.0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354Defparam cumulateorders=falsef=0.2KH=high[1]KL=low[1]up=KH*f/100Dn=KL*f/100p=openU=P+upL=P-dn//Go Longif high > U thenbuy 1 contract at marketendiftargetpriceLong= u+1.618*(u-l)stoppriceLong = L-(u-l)if longonmarket thenif targetpriceLong thensell at marketendifelseif stoppriceLong thensell at marketendifendifif close thensell at marketendif//Go Shortif low < L thensellshort at marketendiftargetpriceshort= L-1.618*(u-l)stoppriceshort = u+(u-l)if shortonmarket thenif targetpriceshort thenexitshort at marketendifelseif stoppriceshort thenexitshort at marketendifendifif close thenexitshort at marketendif05/09/2020 at 1:43 PM #13074805/09/2020 at 1:55 PM #130751As you can see, the results are not so good. But what I trying for, is if I have a trade (long or short) then the target as well as the stoploss is clear but I’m not shure about the timestop. The meaning is to consider every candle whether there is a trade or not. And start each candle again to obtain maybe an automatic system.
05/09/2020 at 1:55 PM #130752but give Always 0 trades
You sure it’s 0 trades and not 0 bar trades??
Surely with conditions below the trade is going to close as soon as it opens??
I’ll run it on my Platform early evening, but I must get out in the garden! 🙂
1234567if close thensell at marketendifif close thenexitshort at marketendif05/09/2020 at 2:03 PM #13075405/09/2020 at 2:59 PM #13076105/09/2020 at 3:14 PM #130765Apart from the mistakes that GraHal pointed out you also can’t use your calculated levels as conditions on their own. You have to compare them to something such as close > targetpricelong bt this would sell at the close of a candle. I’m guessing that you want to close when the level is hit so you need to use pending orders.
I have modified your code to use pending orders but really the code needs a few more fixes such as only buying if you are between your exit levels and making sure you have exit orders on the market when you place the entry orders etc.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061Defparam cumulateorders=falsef=0.2KH=high[1]KL=low[1]up=KH*f/100Dn=KL*f/100p=openU=P+upL=P-dn//Go Longif high > U thenbuy 1 contract at marketendiftargetpriceLong= u+1.618*(u-l)stoppriceLong = L-(u-l)if longonmarket then//if targetpriceLong thensell at targetpricelong limit//endif//else//if stoppriceLong thensell at stoppriceLong stop//endifendif//if close then//sell at market//endif//Go Shortif low < L thensellshort at marketendiftargetpriceshort= L-1.618*(u-l)stoppriceshort = u+(u-l)if shortonmarket then//if targetpriceshort thenexitshort at targetpriceshort limit//endif//else//if stoppriceshort thenexitshort at stoppriceshort stopendif//endif//if close then//exitshort at market//endifgraphonprice targetpriceshortgraphonprice stoppriceshortgraphonprice targetpricelonggraphonprice stoppricelonggraphonprice ugraphonprice l05/09/2020 at 4:27 PM #130770Thanks,
At stoppriceshort is not what I want.
Because if the price is higher then stoppriceshort I lose the difference between price and stoppriceshort, thats not what I want. (It can still be a winning trade if price is between enterprice and TP)
If neither TP and Stopprice (long or short) is not reached before the end of the intradaybarindex. The trade has to stop (at close?) of that intradaybarindex.
05/09/2020 at 7:19 PM #130792We can only guess what you want. You need to set out exactly what strategy you have in mind down to every detail if you want someone else to code it or help you fix it. For example we have no idea if you want to sell at the calculated levels or any time price closes outside of them. We also don’t know if you want the levels fixed at the time of entry or changing with every new bar after entry.
Much more clear definitive info is needed!
05/09/2020 at 8:52 PM #130807The indicator show the conditions to go long or short at the open of each candle. I will illustrate this with two graphics a 15 min and a 90 min. The second last candle is only used to calculate conditions for the last candle and the result is immediately printed at the opening of the last candle. The high and the low of the second last candle (High[1] and low[1]) are used to calculate those values. Fact: there is Always a last and a second last candle which timeframe you ever take.
The factor (f) is in both cases (both graphics) 0.2 or 20% of the range (U-L) of the second last candle.
At the moment price touches the Green or Red line we are in the market long or short depending. If one change line 20 and 40 in the backtest we change the targetPrice, the same for the stoplossprice line 40 and 41. Beside variable f as % of the range, we can take for example f2 (instead of 1.618) as factor for TP and f3( instead of 1) for Stoploss as variables as well.
TP and Stoploss are well defined. If TP or stoploss are not reached, there will be a third exit and that will be the close of the last candle.
In fact I am searching for a timestop at the candle in action (maybe the last second of that candle). Because the first second of the next candle there are new conditions.
As conclusion in the 15 min graph we have no entry no trade, in the 90 min graph there is a gain of 38.8€.
05/09/2020 at 9:31 PM #130810Much more clear definitive info is needed!
…and yet somehow I am more confused than I was before! 🙂
05/10/2020 at 1:49 PM #13089405/10/2020 at 8:09 PM #131016 -
AuthorPosts
Find exclusive trading pro-tools on