Australian (ASX) Stock Market Forum

Dump it Here

My take on Barney's explanation
The volume-weighted adjusted price (VWAP) is the true "average" price. Barney suggested the (VWAP) has more importance when deciding which positions to be entered rather than accepting the displayed price. The VWAP identifies the true average by factoring in the volume of transactions at a specific price point that's not based on the closing price. (In a nutshell, this is the idea)

The logic behind the strategy
I could have made a trading strategy using just the VWAP & taking those positions with a closing price above it. But as Barney wanted it as a filter, so that's how I have coded it. The VWAP Filter will be used as an additional confirmation annexed to the buy condition.

For the more technical
Using the closing price above or below the VWAP is just crazy. As the summary mentions the differences between (VWAP & SMA) I'll use both to determine the relationship between the two.

More to follow.

Skate.
 
Using the VWAP & SMA
First, I had to determine the VWAP optimised range (lookback period) for my calculations, then calculate the SMA optimised range to complete my calculations. I settled for a 50-period for the VWAP & 100-period for the SMA.

Dumbing it down
This post would be excruciating to read following the logic I've used to calculate these parameters formulating the VWAP filter. In easy speak, the closing price must be greater than the average volume of the (VWAP range) & above the SMA of the (SMA range).

Barney's idea made a difference
I've added Barney's idea of a VWAP filter to "Nick's Day Trading Strategy" for comparison "between the backtest reports". Nick's Day Trading idea performed well & using the VWAP as a filter did make an improvement. The improvement was slight but that was due to the robustness of Nick's methodology in his coding. To be fair to Barney, I've coded my idea from his explanation & examples, also the graph he posted.

More to follow.

Skate.
 
Let's compare if Barney's idea can make a difference
I've used the same backtest period as before (1st July 2020 to the end of trade 12th April 2020)

The shoot-out contenders:
(1) Skate's Version of Nick's Day Trading "VWAP" Strategy &
(2) Skate's Version of Nick's Day Trading strategy.

The takeaway
1. Using the VWAP indicator did the job nicely, keeping the strategy out of 8 fake-outs - with less exposure.
2. Another spin-off - the win% increased & the Drawdown decreased.
3. The idea is worthy of additional analysis but for me, I'm time-poor.

Comparison 2020-2021 NICK's VWAP Capture.jpg

Summary
The results are indicative of "how I interpreted" Barney's idea. Being dismissive at first, I owed it to Barney to make an effort to explore if using a VWAP filter would be beneficial - trading systematically. I'm sure with more time I could better approach his original idea from other angles. Correctly coded & implemented - I'm sure the VWAP indicator would have an advantage in any trading strategy.

Skate.
 
3. The idea is worthy of additional analysis but for me, I'm time-poor.

Thanks @Skate

If you are able to come up with something that impressive and you are "time poor"

I'd love to see what happens when you are "time affluent" :nailbiting: :)

I have no idea how you code what you do, but I am suitably impressed with how you do it none the less!?

I have no doubt you will find other ways to play around with and tweak the VWAP and maybe incorporate it into other strategies?

If it ends up being useful (hopefully valuable), that would be fantastic!

Cheers:cool:
 
Here is an excerpt from a system I'm working on...

Code:
#pragma nocache;

// Norgate Data Functions
#include_once <..\Norgate Data\Norgate Data Functions.afl>;

// Unadjusted (historic) Close
UnadjClose = NorgateOriginalCloseTimeSeries();

// Check for delisted securities
OnSecondLastBarOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() == (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") ) ;
OnLastTwoBarsOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() >= (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") );

Most of this code is straight from Norgate's documentation: https://norgatedata.com/amibroker-faq.php#exitpriortodelisting

When I run Code Check & Profile on this code, Amibroker says I am referencing future data:

1618322042738.png

Any idea why using these Norgate functions as documented would generate that warning?

Thanks,
Scott
 
T
Let's compare if Barney's idea can make a difference
I've used the same backtest period as before (1st July 2020 to the end of trade 12th April 2020)

The shoot-out contenders:
(1) Skate's Version of Nick's Day Trading "VWAP" Strategy &
(2) Skate's Version of Nick's Day Trading strategy.

The takeaway
1. Using the VWAP indicator did the job nicely, keeping the strategy out of 8 fake-outs - with less exposure.
2. Another spin-off - the win% increased & the Drawdown decreased.
3. The idea is worthy of additional analysis but for me, I'm time-poor.

View attachment 122766

Summary
The results are indicative of "how I interpreted" Barney's idea. Being dismissive at first, I owed it to Barney to make an effort to explore if using a VWAP filter would be beneficial - trading systematically. I'm sure with more time I could better approach his original idea from other angles. Correctly coded & implemented - I'm sure the VWAP indicator would have an advantage in any trading strategy.

Skate.
This is so awesome!
 
Here is an excerpt from a system I'm working on...

Code:
#pragma nocache;

// Norgate Data Functions
#include_once <..\Norgate Data\Norgate Data Functions.afl>;

// Unadjusted (historic) Close
UnadjClose = NorgateOriginalCloseTimeSeries();

// Check for delisted securities
OnSecondLastBarOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() == (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") ) ;
OnLastTwoBarsOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() >= (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") );

Most of this code is straight from Norgate's documentation: https://norgatedata.com/amibroker-faq.php#exitpriortodelisting

When I run Code Check & Profile on this code, Amibroker says I am referencing future data:

View attachment 122780

Any idea why using these Norgate functions as documented would generate that warning?

Thanks,
Scott
You include a whole set of afl northgate data functions.
Even if not using them or all of them,it is a fair bet some may look ahead?
You should try the future check on this include alone,and check if the warning pops up
 
You include a whole set of afl northgate data functions.
Even if not using them or all of them,it is a fair bet some may look ahead?
You should try the future check on this include alone,and check if the warning pops up

With further testing, I've distilled it down to this section of the code.

Paste this into a new AFL editor (Formula ##.afl) and run the Code Check & Profiler:

Code:
foo=iif (BarIndex() >= (LastValue(BarIndex()) -1), 1, 0);

This modification also suppresses the Norgate warning:

Code:
OnSecondLastBarOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (/*BarIndex() == (LastValue(BarIndex()) -1) OR */ DateTime() >= GetFnData("DelistingDate") ) ;
OnLastTwoBarsOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (/*BarIndex() >= (LastValue(BarIndex()) -1)) OR */ DateTime() >= GetFnData("DelistingDate") );


As I said, the code is straight from the Norgate documentation.

I've sent a support ticket to Norgate. I'll post the reply.
 
From Norgate Support/Richard Dale:

Hi Scott,

Those two lines of code are actually AmiBroker AFL code. They operate independently of our plugin.

They are used in a very specific scenario - that is, to exit a position prior to delisting.

Is this an artificial construct? Yes.
Is it a "future leak"? Yes - it references future bars.
Why even do it? This is the only way we know how to exit a security in backtesting in AmiBroker. If you DON'T do this, then your backtest will never exit any position held until the last bar.
Is it an issue? No.
What would happen in real-life trading? The DelistingDate field is never populated until a stock has actually delisted, so this part of the exit rule would never be triggered.
How should I handle delistings in real-life trading? This is up to your own trading rules. Some people won't enter a stock if the company has a delisting notice active (see company announcements/SEC filings etc.). Others are happy to enter positions on stocks with a takeover offer underway, but have other additional rules (such as exit the position, if no competing takeover offer has arrived within X days).
How do I check for "real" future leaks? Comment the code out.

My only feedback to Norgate is to update https://norgatedata.com/amibroker-faq.php#exitpriortodelisting with this additional information.
 
To calculate the dip
Take the Average True Range (ATR) of the last 5-days & subtract it from today’s low, this is known as the ‘stretch’. Then the signals are "ranked" using the Rate of Change (ROC) over the last 5-days. Any positions opened during the day will be exited ‘market on close’.

First post so sorry if this is a stupid question or has already been answered elsewhere.

In order to generate a buy signal you need to detect an intraday price level lower than the stretch I believe?

If that's true you need intraday data to backtest this strategy (probably required to test exit strategy as well). Can I ask what the source of your historical intraday data is?
 
First post so sorry if this is a stupid question or has already been answered elsewhere.

In order to generate a buy signal you need to detect an intraday price level lower than the stretch I believe?

If that's true you need intraday data to backtest this strategy (probably required to test exit strategy as well). Can I ask what the source of your historical intraday data is?

@enthused1, thank you for making your first post in the "Dump it here" thread. My previous post you are referring to was lifted from Nick's website. The "stretch" is the terminology he used that's "attached below in italics".

To be blunt
In answering Barney's question, I was working within the constraints that I have. (Norgate's EOD silver subscription). I coded my interpretation of the VWAP & added it to Nick's Daily Strategy.

My methodology
I've previously explained that I calculated the "Daily" volume-weighted adjusted/average price (VWAP) over 50 periods. I used the entry condition from the Chartist website (Building a Day Trading System) using the 5-period (ATR), (ADX) & (ROC) that formed the entry condition. I simply annexed my version of the (VWAP) to Nick's buy condition.

The basics of (VWAP)
The (VWAP) identifies the "true average" by factoring in the volume of transactions at a specific price point that's not based on the closing price that (@barney referenced). There is a multitude of ways to code a trading strategy using the VWAP, I gave one quick example.

Deviations from what Nick posted
1. Nick uses a 40-position portfolio - I used a 20-position portfolio (20 X5k positions).
2. Nick exits market on close’ - Doing it Nick's way, the $19.95 commission would be a killer.
3. I exit using the volatility of the Bollinger Bands in conjunction with a trailing stop.
4. I used a 100-period SMA as an additional confirming indicator. (new)

From the Chartist website

=================================================================
So let’s go left field and try the following idea…

Calculate the ADX for the last 5-days. If the reading today is greater than yesterday, and the reading today is greater than 5-days ago and the reading today is greater than 10 days ago, we’ll buy a dip tomorrow.

To calculate the dip, take the Average True Range (ATR) of the last 5-days and subtract it from today’s low. This is known as the ‘stretch’.

We’ll then rank the signals using the Rate of Change (ROC) over the last 5-days. Then, using the Pattern Day Trader margin, we’ll use a maximum of 40 positions and allocate 10% capital to each.

Any positions opened during the day will be exited ‘market on close’.

=================================================================

Skate.
 
Last edited:
With further testing, I've distilled it down to this section of the code.

Paste this into a new AFL editor (Formula ##.afl) and run the Code Check & Profiler:

Code:
foo=iif (BarIndex() >= (LastValue(BarIndex()) -1), 1, 0);

This modification also suppresses the Norgate warning:

Code:
OnSecondLastBarOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (/*BarIndex() == (LastValue(BarIndex()) -1) OR */ DateTime() >= GetFnData("DelistingDate") ) ;
OnLastTwoBarsOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (/*BarIndex() >= (LastValue(BarIndex()) -1)) OR */ DateTime() >= GetFnData("DelistingDate") );


As I said, the code is straight from the Norgate documentation.

I've sent a support ticket to Norgate. I'll post the reply.
More an amibroker subject but not all warnings and not all future looking code is bad, can be useful for display matter, etc..as long as your decision process /explore etc does not look forward, you are good.?
 
More an amibroker subject but not all warnings and not all future looking code is bad, can be useful for display matter, etc..as long as your decision process /explore etc does not look forward, you are good.?

Yeah I guess it's learning the discernment between the two. But I'm not sure I'll ever outgrow the initial feeling of panic from:

1618363011667.png

Having Tomasz SCREAM at me has never been good for my psyche ;)

Anyway I've got the workaround from Richard Dale now.

P.S.: Who ever reads the rest of that gibberish in this window anyway - what a load of useless information (to me anyway)
 
@enthused1, thank you for making your first post in the "Dump it here" thread. My previous post you are referring to was lifted from Nick's website. The "stretch" is the terminology he used that's "attached below in italics".

To be blunt
In answering Barney's question, I was working within the constraints that I have. (Norgate's EOD silver subscription). I coded my interpretation of the VWAP & added it to Nick's Daily Strategy.

My methodology
I've previously explained that I calculated the "Daily" volume-weighted adjusted/average price (VWAP) over 50 periods. I used the entry condition from the Chartist website (Building a Day Trading System) using the 5-period (ATR), (ADX) & (ROC) that formed the entry condition. I simply annexed my version of the (VWAP) to Nick's buy condition.

The basics of (VWAP)
The (VWAP) identifies the "true average" by factoring in the volume of transactions at a specific price point that's not based on the closing price that (@barney referenced). There is a multitude of ways to code a trading strategy using the VWAP, I gave one quick example.

Deviations from what Nick posted
1. Nick uses a 40-position portfolio - I used a 20-position portfolio (20 X5k positions).
2. Nick exits market on close’ - Doing it Nick's way, the $19.95 commission would be a killer.
3. I exit using the volatility of the Bollinger Bands in conjunction with a trailing stop.
4. I used a 100-period SMA as an additional confirming indicator. (new)

Many thanks for your answer Skate. I really appreciate you taking the time.

Just so we are crystal clear you are doing the whole backtest, soup to nuts, using only Norgate EOD data?

[edit] Pretty sure I understand where I'm getting confused. Noob mistake, sorry [/edit]
 
Last edited:
Many thanks for your answer Skate. I really appreciate you taking the time.

Just so we are crystal clear you are doing the whole backtest, soup to nuts, using only Norgate EOD day data?

[edit] Pretty sure I understand where I'm getting confused. Noob mistake, sorry [/edit]

@enthused1, at the moment I'm only using Norgate EOD data. The backtests "performance" should be taken with a grain of salt (even though my backtest results are restricted to the last 6-12 months). When I post comparisons, they do give an indication between results. (that's it in a nutshell)

In the past
I have made over 160 posts explaining that the backtest results I posts mean "Jack" for the very reason you have mentioned. Also trading in the pre-auction, the results vary from backtesting. (Also previously discussed & explained)

In my strategy development days, I had Norgate Platinum subscription level using (NDU) 3 years before it was released to the public. My trading strategies have been fully tested & evaluated using the full set with historical constituents (25 years of data). They are now all mature trading systems.

Having 3 Norgate subscriptions
These days I don't require the features of a Platinum subscription package (including historical constituents) as I considered my development days are over. Retaining 3 Platinum subscriptions is overkill in my opinion.

Backtesting means JACK
I've stated before, backtest results mean "Jack" to me but they do give an indication between test results using different parameters.

Backtesting means JACK
Without getting into another exchange, I want to re-stated that (IMHO), Amibroker backtest results mean "Jack" & hold little interest in assessing the true performance of a strategy. I'm first to admit that they do give an indication if the methodology behind the strategy being backtested is sound or not.

Actual trading results
Results from live trading are the "true measure" of your trading strategy as it confirms if your "trading plan" is solid.

Skate.
 
Yeah I guess it's learning the discernment between the two. But I'm not sure I'll ever outgrow the initial feeling of panic from:

View attachment 122790

Having Tomasz SCREAM at me has never been good for my psyche ;)

Anyway I've got the workaround from Richard Dale now.

P.S.: Who ever reads the rest of that gibberish in this window anyway - what a load of useless information (to me anyway)

HAHAHA .. Anyone who hasn't been screamed at by Tomasz hasn't posted on the Amibroker forum.

As @qldfrog said not all future warnings are bad. Another commmon example is trading tomorrow at a pre determined price. You want to test if tomorrow it reaches that price for backtesting ... BANG future leak.

I think the really bad thing is that the code check doesn't point you directly to where the future looking references are. This could lead you to a situation where you THINK you know where that 1 future leak is, but have accidentally introduced a second which is masked by the first.

It would be good if amibroker had an #ignore parameter so you could turn off future leak warnings for lines you KNOW are future leaks.
 
@enthused1, at the moment I'm only using Norgate EOD data. The backtests "performance" should be taken with a grain of salt (even though my backtest results are restricted to the last 6-12 months). When I post comparisons, they do give an indication between results. (that's it in a nutshell)

I'm quite skeptical and wouldn't act on anything I can't reliably confirm myself.

In the past
I have made over 160 posts explaining that the backtest results I posts mean "Jack" for the very reason you have mentioned. Also trading in the pre-auction, the results vary from backtesting. (Also previously discussed & explained)

I guess I need to read more of your historical posts. Apologies for the interruption, which was unnecessary as I should have thought about this more deeply before pulling the trigger. I'll try not to make the same mistake in the future.

Thanks again for your responses.
 
HAHAHA .. Anyone who hasn't been screamed at by Tomasz hasn't posted on the Amibroker forum.

As @qldfrog said not all future warnings are bad. Another commmon example is trading tomorrow at a pre determined price. You want to test if tomorrow it reaches that price for backtesting ... BANG future leak.

I think the really bad thing is that the code check doesn't point you directly to where the future looking references are. This could lead you to a situation where you THINK you know where that 1 future leak is, but have accidentally introduced a second which is masked by the first.

It would be good if amibroker had an #ignore parameter so you could turn off future leak warnings for lines you KNOW are future leaks.
Definitively, i have some code i use with known future leak that i have to comment to check then uncomment.that would be a well needed feature
 
Not complaining vs today, but i noticed my systems have a tendency to do well/very well on days where the asx is actually slightly down.has anyone noticed the same and has a possible explanation?
I understand i am highly small caps etc.
On big asx200 falls, the systems follow..
 
Not complaining vs today, but i noticed my systems have a tendency to do well/very well on days where the asx is actually slightly down.has anyone noticed the same and has a possible explanation?
I understand i am highly small caps etc.
On big asx200 falls, the systems follow..
If you're highly small cap isn't XSO and not XJO more relevant?
 
Top