Australian (ASX) Stock Market Forum

Dump it Here

Think you might need to set trade delays in the settings.
The thing is that the buy offer is the close plus 3% and if Monday's open is higher than the 3% the trade isn't taken. This is were back testing falls over or is less accurate.
 
The thing is that the buy offer is the close plus 3% and if Monday's open is higher than the 3% the trade isn't taken. This is were back testing falls over or is less accurate.

I dropped the code in and ran a backtest for a long date range as my standard. Result were massive and that instantly rings alarm bells.

Started comparing trades in the backtest against the chart and noticed same as you willoneau. Looking at the code, tradedelays set at zero but there is a ref,-1 on COND1 but not the rest.

About the 3%, it's not within the Buy but is just a number used to place at the broker before the open Monday.
 
Last edited:
Back tested results drop a lot with the change.

Yes, you are correct in the downgrade in results, however Skate's BB Strategy still posts strong results with CAR/MDD of the order of 1.20. Without the trade delay CAR/MDD was showing in excess of 6.00 - probably a clue here, "too true to believe".

@Skate, again thanks for the posting of the strategy - it has provided me with a wealth of learning :)
 
Yes, you are correct in the downgrade in results, however Skate's BB Strategy still posts strong results with CAR/MDD of the order of 1.20. Without the trade delay CAR/MDD was showing in excess of 6.00 - probably a clue here, "too true to believe".

@Skate, again thanks for the posting of the strategy - it has provided me with a wealth of learning :)
I agree great learning curve
 
Skate's BB Strategy still posts strong results with CAR/MDD of the order of 1.20

I don't think buying/selling at the close was the intention for this system?

Maybe wrapping the BUY and SELL in Ref,-1 as SetTradeDelays( 0, 0, 0, 0 ); overrides the settings.
 
I don't think buying/selling at the close was the intention for this system?

Maybe wrapping the BUY and SELL in Ref,-1 as SetTradeDelays( 0, 0, 0, 0 ); overrides the settings.

Whilst I don't have AmiBroker as yet and therefore am unable to read the system code, using code like Ref(BUY,-1) and Ref(SELL,-1) along with SetTradeDelays( 0, 0, 0, 0 ) as suggested by Sir Burr is akin to a BUY or SELL signal on the current bar and setting trade delays to one 1 bar should result in the same outcome.

Cheers,
Rob
 
I don't think buying/selling at the close was the intention for this system? Maybe wrapping the BUY and SELL in Ref,-1 as SetTradeDelays( 0, 0, 0, 0 ); overrides the settings.
Whilst I don't have AmiBroker, using code like Ref(BUY,-1) and Ref(SELL,-1) along with SetTradeDelays( 0, 0, 0, 0 ) as suggested by Sir Burr is akin to a BUY or SELL signal on the current bar and setting trade delays to one 1 bar should result in the same outcome.
Whilst I don't have AmiBroker, using code like Ref(BUY,-1) and Ref(SELL,-1) along with SetTradeDelays( 0, 0, 0, 0 ) as suggested by Sir Burr is akin to a BUY or SELL signal on the current bar and setting trade delays to one 1 bar should result in the same outcome.

Both posts by @rnr & @Sir Burr are 100% but when using Amibroker backtest mode it needs additional code.

Let me clear this up
@Sir Burr I've been watching the interaction between members & I'm impressed that they are thinking deeply about the BB code uploaded. @CNHTractor highlighted the issue yesterday with backtesting irregularities he was finding. I use the Exploration mode (delays included in the array) for the buy & sell signals (using the other information to enter the pre-auction) so the backtest is irrelevant. Backtesting means Jack to me & my coding reflects this. The code is from 2016. Look at the trade delay explanation & it will make sense

Exploration Mode = The trade delay settings are correct
SetTradeDelays( 0, 0, 0, 0 ); // Trade delays FALSE, the delay is in the array (CORRECT CODE)

Buy Condition = The trade delay settings are correct

Cond1 = Ref(BuySetUp,-1); The (-1) is the trade delay
Buy = cond1; This line is the "buy" that references the array (Cond1) that has a built-in delay that's referenced by [ Ref(BuySetUp,-1) ]

Backtest Mode = The trade delay settings need to be changed
(backtesting needs these delays)
SetTradeDelays( 1, 1, 1, 1 ); // Trade delays TRUE, the delay is for backtesting (CORRECT CODE)

Chart Mode = correct = using either will be irrelevant as the Plot has the delay (-1)
PlotShapes( Ref( Buy, -1 ) * shapeHollowSquare, colorWhite, 0, O, 0, 0 ); // Displays a white square on the buy bar (-1 is the trade delay also called the entry bar)
PlotShapes( Ref( Sell, -1 ) * shapeHollowCircle, colorYellow, 0, O, 0, 0 ); // Displays a yellow circle on the sell bar (-1 is the trade delay also called the entry bar)

Please Note
If you want to use the strategy for backtesting add the delay (for Backtest) as explained in the documentation, the SetTradeDelays() function "Sets trade delays applied by the backtester." It doesn't affect plotting.

SetTradeDelays using ( 1, 1, 1, 1 ) for backtesting
Allows controlling trade delays applied by the backtester


FUNCTION
Sets trade delays applied by the backtester. This function allows you to override trade delays from the "Settings" page. It is important to understand what trade delays really do. They in fact internally apply the following:

Buy = Ref( Buy, -buydelay );
Sell = Ref( Sell, -selldelay );

A must read
Inside backtester after your formula is executed but before backtester starts trade simulation. It is functionally equivalent to having above 2 lines at the end of your formula. Note that NO OTHER variables are affected by trade delays, therefore for example, if your position sizing depends on values found in buy/sell/short/cover variables *and* if you are using non-zero trade delays you need to account for that in your code. EXAMPLE settradedelays( 1, 1, 1, 1 )

Important
I would appreciate an honest assessment for others to read
I wanted members to scrutinise the BB code & think about the coding. Run backrests & compare notes. The last thing I want others to do was to add it to their list of other codes never to see the light of day.

Exploration & Charts
Theses are both 100% correct & if you used only these your trading would be as the code has been designed.

I'm pleased with the banter, it's the only way we learn

Skate.
 
The thing is that the buy offer is the close plus 3% and if Monday's open is higher than the 3% the trade isn't taken. This is were back testing falls over or is less accurate.
I actually did check that in some BT where you voluntarily put a condition that ref o,1 is lower than c*1.02
 
View attachment 105048 View attachment 105049 View attachment 105049 View attachment 105049 View attachment 105048 Thanks Skate for uploading this system plus the clear explanation above of the trailing stop, which even though i have read the manual i still found confusing.
I ran a back test back to 2009 (XAO) with the returns per attached, can someone verify if possible so i know im doing the backtest correctly please. Seems like excellent returns and max. system drawdown of only 9.08% for the period which is excellent.

View attachment 105068 @Skate the results are simply incredible.

After try to break it by changing the moving average period significantly on HI and LW ref and BB periods, as well as switching from weekly to daily on all variations, I haven't found a single negative year or unspectacular result on any backtest. It indicates extreme robustness.

In fact it seems too good to be true.

The results confirm your strong view that exits are so important to minimise open profit loss and drawdown. You've really nailed that area. Wow, super impressed.

I don't know what I'm doing wrong then because I get relatively poor results from the backtest on the strategy.
 
Backtesting means Jack to me & my coding reflects this.

OK fully sense makes. Look at documentation :)

A tip for that Index bar on the bottom of charts that won't sit still.

Index = Foreign("$XAO.au","C");
IndexBuyfilter = Index > MA( Index , 100 );
IndexSellfilter = Index < MA( Index , 100 );
indexfilter = IIf( IndexBuyfilter, True, False );
RibbonColor = IIf( indexfilter, colorGreen, colorRed );
Plot( 1, "", RibbonColor, styleArea | styleOwnScale | styleNoLabel, -0.0001, 190 );
 
Hi Skate,

Given the copious amount of system testing that you have carried out to date, have you tested any strategy that allows for more than one position to be held, at the same time, in any of the securities included in the back-test?

Cheers,
Rob
 
AFAIK tradedelays only works in backtester mode. It's a way of adding a delay only to the backtester without adding a delay to the Explorer or Chart results.

So ( please don't shoot me ), setting tradedelays should have no effect on the exploration results.

https://forum.amibroker.com/t/under...tween-backtest-tradedelays-and-explore/7354/7

I think the following document is a bit confusing too.

https://www.amibroker.com/guide/afl/settradedelays.html

The code should say something more like this.

if( Status( "Action" ) == actionBacktest ) // ** Might be actionPortfolio (BT 2nd pass) ??
{
Buy = Ref( Buy, -buydelay );
Sell = Ref( Sell, -selldelay );
Short = Ref( Short, -shortdelay );
Cover = Ref( Cover, -coverdelay );
}

Oh And thanks for sharing your BB system. I love catching up on this thread and finding gems like that make it worthwhile.
 
Hi Skate

As the IGL sale proceeds exceeded $1000, I would have thought Commsec's brokerage would have been $19.95 on the sale not $10?
From the Commsec site
Brokerage fee amount by transaction value1
Trade

Trade online and settle your trade to a CDIA or CommSec Margin Loan2

  • $10.00 (Up to and including $1,000)
  • $19.95 (Over $1,000 up to $10,000 (inclusive))
  • $29.95 (Over $10,000 up to $25,000 (inclusive))
  • 0.12% (Over $25,000)





View attachment 105088

View attachment 105089

Skate.[/QUOTE]
 
Top