- Joined
- 28 December 2013
- Posts
- 6,394
- Reactions
- 24,331
3. The idea is worthy of additional analysis but for me, I'm time-poor.
#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") );
This is so awesome!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.
You include a whole set of afl northgate data functions.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
foo=iif (BarIndex() >= (LastValue(BarIndex()) -1), 1, 0);
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") );
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.
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?
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.?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.?
@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 day data?
[edit] Pretty sure I understand where I'm getting confused. Noob mistake, sorry [/edit]
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.
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)
@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)
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 featureHAHAHA .. 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.
If you're highly small cap isn't XSO and not XJO more relevant?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..
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?