Buy N bars after the Parabolic goes from a top to below
Author: DIY
Creation Date: 12/23/2016 1:04 AM
profile picture

DIY

#1
Hello Eugene

I would like to alter the script in order for a buy to be for example 6 bars after the parabolic goes from on top of the data points to below. I have tried various alterations but none work.

Regards, Ian
profile picture

DIY

#2
Here is the screenshot
profile picture

Eugene

#3
Hi Ian,

Sharing strategy code as screenshots is suboptimal as technicians will not retype it. Please use suitable formats for posting screenshots, error messages or code. Here's how.

1. If it's a modal Windows error dialog, strike Ctrl-C to copy the underlying error message and Ctrl-V to paste it when replying (a standard Windows shortcut).
2. For a WealthScript Strategy, do a Ctrl-A (Select All) before copying to select its entire code (or select a snippet manually).
3. Please only attach text as text (TXT) and images as images (PNG preferred, MS Paint which is built in any Windows will do it).

Last but not least, please clarify what this means: "after the parabolic goes from on top of the data points to below". Feel free to illustrate with a screenshot.

Thanks.
profile picture

DIY

#4
Thanks, hope this works. I will make a note of the instructions.

"after the parabolic goes from on top of the data points to below" means the up/down arrows in the Screenshot.


CODE:
Please log in to see this code.
profile picture

Eugene

#5
Got it. Here you go:

CODE:
Please log in to see this code.


The delay will be one bar greater than usual since the script first has to determine whether the crossover of the High/Low price and the Parabolic has taken place, and to act on the next bar since the High/Low price is unknown to the script until the close / next bar's open. You can change entry/exit to take place *AtClose(bar).
profile picture

Cone

#6
Here's a simpler take on the idea. There's a difference however. Eugene's code doesn't check for the "setup" until after a position is exited, which results in missing some signals. Could be good, could be bad, but it's different than the code below which will not miss a signal within "delay" bars after an exit.

The results are a little closer if you uncomment the first statement in the entry logic. There are still subtle differences depending on multiple crossovers/unders while a position is active. Requirements have to be very specific to get precisely what you want!

CODE:
Please log in to see this code.
profile picture

DIY

#7
Thanks Eugene and Cone. I adjusted Eugene's script to get closer. That is the delay only works on the Buy signal parameter ie a delay in x bars which can be adjusted.

The remaining problem is to eliminate buys/sells if the parabolic crossover is equal to or less than the delay period. I think the pink patches will explain. The buy/sell work perfectly for the ones on the left of the screenshot

CODE:
Please log in to see this code.
profile picture

DIY

#8
Hello again. I modified Cone's script. As can be seen the triangle works and the diamond does not work. Hope this clarifies things.
profile picture

Cone

#9
That's a requirements problem. The code is buying n+1 bars after the crossover, just like you wanted. The problem is that it crossed under before the buy, so the strategy has to wait for the series to crossover and crossunder again to get the exit.

What are your requirements for this situation? (i.e., what would you do if you were trading this strategy?)
Do you really want to use Market orders? Your original strategy above used Stops.
profile picture

DIY

#10
Hi Cone, when I ran the DataSet on Parabolic (and some other Indicators) it became clear on sorting that to buy before the 5th or less cross under to buy then there was a higher probability of making a loss. That is if there are 5 or less bars indicating an uptrend then you can expect mainly losses and these are the ones that greatly bring down the overall profit. This partly extends up to 10 bars but of course it is partly self defeating as you miss out on possible growth during the first 5 bars (or 10 bars). Thus I am interested in having a script that I could test this hypothesis by DataSet modelling. Even though the modified script is not perfect it is showing some promise.

I must look up Market orders? Hope this makes sense, Ian
profile picture

Cone

#11
It makes sense, but I asked to define the rules more concisely to cover the situation I described above. That is, if a crossover occurs on bar - delay, do you still want to buy on bar + 1 if a crossunder occurred between that time? I would guess that you don't want to enter a trade in these whipsaw situations. The code below requires that the High be above the parabola for each of the n delay bars (plus the current bar) before buying.

CODE:
Please log in to see this code.
profile picture

DIY

#12
Thanks Cone and Eugene for all the effort. This what I was after. Preliminary runs look as though my hypothesis does not work as it is self defeating but you never know until you try, This is science. Of course I would not use parabolic by itself instead probably use ADX as suggested in the literature.

Regards, Ian
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).