Line break chart backtesting
Author: Alex_Hurko
Creation Date: 5/9/2013 10:19 AM
profile picture

Alex_Hurko

#1
Hi,
I have some questions about line break charts.

Does indicator calculated at open and high of line break candles or it calculated at open and high of simple candles?
profile picture

Cone

#2
Indicators and backtests are always based on the basic bars (i.e., Bars object) loaded in chart. To test Line Break or other Chart Style methods, you can use classes built for that purpose. There are a few strategies already available in your installation that demonstrate this, and more details are covered in the WealthScript Programming Guide: Backtesting with ChartStyles.Trending.

If you have any specific questions, just ask.
profile picture

Alex_Hurko

#3
How can I use line break candles in my code? I created a simple code and load strategy with it at line break chart. It works incorrect. But it works good at OHLC bars.


profile picture

Eugene

#4
Just dropped by to say that you can copy/paste Strategy code here inside CODE tags. Images can be attached too ("Add Attachments") for your convenience.
profile picture

Cone

#5
Again, at the risk of repeating, strategies work with the daily, minute, or whatever bars you load. This is the Bars object.

Your code won't work with respect to line break "bars", which I call columns as a general term for all the trending chart style "bars". Please look at the "Line Break Basic [Rev A]" Strategy for an example of the programming required. It creates a TLineBreak object whose line break properties are tested on each bar. If you're not a programmer it's going to be tough to follow, I'll admit.

Tip. To better visualize trade on a line break chart style, right click the chart, select Chart Style Settings, and put a check next to Overlay HLC chart. Check it out.
profile picture

Cone

#6
Here's how you'd program the strategy with respect to the line break chart. Note! Line Break is always based closing prices of the underlying bars, so again, the trades are best visualized using the HLC Overlay.

Also, note that you need to match the line break setting (3 lines by default) in the strategy with the Chart Style setting, otherwise the strategy won't look to be in synch with the chart.

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

Alex_Hurko

#7
thank you very much. just one more question. Can i use an operator to call the Line Break candle opening/closure?
CODE:
Please log in to see this code.
I need to use these bars values to fix my own movin average
E.g. thу following line does not compile:
CODE:
Please log in to see this code.

There is no info on it in help section or guidlines. I would be glad to receive the sample of Line Break bar closure code.
profile picture

Cone

#8
Again, the information is in the WealthScript Programming Guide (reference in my first post). You just have to know how to use it ;) Specially, see "Members of WealthLab.ChartStyles.Trending.Column".

So,
CODE:
Please log in to see this code.


Now the question is how to find a moving average of the last several column highs or lows. I thought there was a method to easily iterate through the columns, but it turns out you have to "find" the columns yourself. Anyway, you can create a function to return the average at any given bar, and fill a series with it for plotting. Here you go -

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

Cone

#9
Give me a few minutes to work out a crossover strategy. I think we just found the next TSL article :)
profile picture

Cone

#10
Here's the whole crossover strategy:
1. Buy when the High of a Column (Line) crosses over the n-period average of the Column Highs
2. Sell when the Low of a Column (Line) crosses under the n-period average of the Column Highs

The trick us to make sure you wait for a new column to form before you do another action. And (since I haven't looked at this in years) I forgot that the HLC overlay chart gives you a feeling of peeking ahead due to the way the boxes are drawn "early" and end on the bar that contributes to the next line. You'll see, though, that the code does not peek.

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

Alex_Hurko

#11
thank you! You post is very usefull!
profile picture

pscanlon1

#12
Sorry for a post two years later, but where is the docs on this TLineBreak???

I would like to do something similar, but use VWAP instead?

What I really want to do is make sure that the entire previous candle crossed Over/Under the vwap line. not a partial cross

profile picture

Eugene

#13
QUOTE:
Sorry for a post two years later, but where is the docs on this TLineBreak???

Please look under the Help menu > WealthScript Programming Guide > Backtesting with ChartStyles.Trending > Column Class (Reference) > Line Break > TLineBreak.
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).