- Joined
- 28 December 2013
- Posts
- 6,511
- Reactions
- 24,646
Because you can enter on current bar's open also.
But entering on current bars open while indicator value is calculated at current bar's close is a stupid idea.
YOU are the one being responsible for your code but not the software.
Garbage in -> garbage out.
And yes, there is not just EOD.
Hi Wysiwyg
Yes I accept captain black's explanation and I accept the reinforcements made by you.
Amibroker Backtest program makes the decision to BUY on the same day as it's generated and not myself (if no Trade Delay is used) Amibroker uses the open price of the day which is illogical, meaning if a BUY signal is generated TODAY using the results at the End of Trading NOBODY can wind back time BUT Amibroker CAN. Amibroker CAN and DOES have the ability to purchase the security at todays OPEN.
Amibroker having the ability to wind back time to BUY at today OPENING price in it's calculations defies logic.
Amibroker by default should have a End Of Day Radio Button in the Settings under the tab "TRADES" that can be selected. When running a Backtest Amibroker would use the next day as the LOGICAL next time the security can be physically purchased at the OPEN Weighted Average Price by default, so in reality that's how I thought the system would run.
If there is an EOD Radio Button to select I would appreciate someone letting me know.skate
Buy = C > DonchianUpper;
BuyPrice = Open;
Sell = C < MA(C,50);
SellPrice = Open;
SetTradeDelays(1,1,1,1);
Buy = Ref(C > DonchianUpper,-1);
BuyPrice = Open;
Sell = Ref(C < MA(C,50),-1);
SellPrice = Open;
Greetings all --
I see my name in some of the recent messages, but I don't see the code attributed to me. So, my comments may be off the mark. Sorry if that is the case.
That said ----
Future leaks occur when the code "reads" or "knows" data that would not yet be available in real time. Some trading system development platforms attempt to make it impossible to look into the future. It is often very valuable to intentionally use future data during development of trading ideas. AmiBroker allows use of future data, leaving it up to the person coding and testing to be aware and take precautions.
Sometimes what appears to be a simple change enables a future leak and is easily overlooked. For example, changing the time at which a signal is acted upon from Close to Open. If this is hidden in an #include file, or in one of the alternatives being testing in an optimization, it can be hard to find.
Here are three symptoms of a future leak:
1. The "check code and profile" function available from the Formula Editor informs you that there is a future leak. Note that this option is not perfect -- code inside an include is not checked, and computations of variables applied to price or time may create may create a future leak during execution that cannot be determined during compilation.
2. The equity curve looks way too good.
3. When the program is run using "bar replay" from the Tools menu, indicators, including buy and sell arrows, change when new data is received.
I hope this helps,
Best regards,
Howard
QUESTION
I was backtesting my strategy and achieving pleasing results before I read Howard Bandy answer to a members question wanting to know the formula to execute a BUY the next day after the signals is generated - meaning the BUY is execute at the next day's opening price.
As that's how I plan to trade I added this code to my strategy.
Once I added the code below to my strategy my Backtest results went from Net Profit of $26,044 to a Net Loss of -$3,534
I wouldn't have thought buying the next day compared to buying the same day would make such a difference to my Backtest results.
Can anyone shed light on how this could be possible?
The Code I added
/////////////////////////////////////////////////
BuyPrice = Open;
SellPrice = Open;
SetTradeDelays(1,1,1,1);
/////////////////////////////////////////////////
skate.
TO CLEAR UP THE CONFUSION
Habakkuk kindly replied to my concern and gave me a suggestion of placing SetTradeDelays(1,1,1,1); to my code that I quickly applied:
This is an extract lifted from Habakkuk reply giving me help..
On a more serious note, it's usually best to use explicit trade delay code, rather than just commenting out, i.e.
SetTradeDelays(1,1,1,1);
or
SetTradeDelays(0,0,0,0);
Howard you also said in your reply to the member:
Statements in the afl code take precedence over settings made on the Settings dialog box. I recommend that you always write code in the afl that explicitly sets the execution price.
I, like everyone else on this forum values your knowledge and I accept what you say is Gospel.
The Code you supplied that I added to my strategy
/////////////////////////////////////////////////
BuyPrice = Open;
SellPrice = Open;
SetTradeDelays(1,1,1,1);
/////////////////////////////////////////////////
I quickly added your code to my strategy immediately after reading your post and went from receiving great results from my Backtest without a trade delay to very disappointing results after the insertion of the Trade Delay code.
I posted my query seeking an answer to why by changing the Trade Delay by one day could have a DRAMATIC change to the result in the Backtest reports.
I know this forum has some of the smartest bunnies around and even a very knowledgeable duck - I knew someone would answer a question I could figure out..
skate
A question about running a backtest..
If you run a backtest on the same universe of securities with the same setting, one after the other - should the report results be the same every time?
So there is no confusion - I run the backtest 10 times straight AFTER EACH OTHER - I take a note of the report results, I than hit the backtest button again run the Backtest again take a record of the report results and repeat ten times in a row - should the backtest report results display exactly the same report results TEN TIMES?
OR can the 10 consecutive Backtests 'run seconds apart' display 10 different report results?
skate
A question about running a backtest..
If you run a backtest on the same universe of securities with the same setting, one after the other - should the report results be the same every time?
So there is no confusion - I run the backtest 10 times straight AFTER EACH OTHER - I take a note of the report results, I than hit the backtest button again run the Backtest again take a record of the report results and repeat ten times in a row - should the backtest report results display exactly the same report results TEN TIMES?
OR can the 10 consecutive Backtests 'run seconds apart' display 10 different report results?
skate
If you're getting different results then one issue may be if you have positionscore set to random.
Thanks..
That was the culprit..
PositionScore = mtRandomA();
skate
When designing a trading system, I find it helps to imagine myself at some particular time, then adjust the rule calculation, BuyPrice, and Delay statements so that all the calculations are both consistent and appropriate for potential use as a real trading system.
Sounds like a job for Custom Backtester.
http://www.amibroker.com/guide/a_custombacktest.html
Best,
Howard
I'm back with another question.
I've been testing a system based on Nick Radge's Weekend Trend Trader. I'm OK with the basic code and have run some back-testing so I can see that the code is working.
SetForeign( "XAO" );
Filter1 = MA( C, 10 ) > C;
RestorePriceArrays();
Filter2 = ROC(C,20)> 30;
Filter = Filter1 AND Filter2;
Hh = Ref(HHV(H,20),-1);
Buy = Iif(Filter,Cross(C,Hh),0);
BolliBot = BBandBot(C,100,1);
Sell = C<= BolliBot;
I am testing this code on Qantas [QAN] and for the time frame 05/12/2014 to 31/12/2014. A buy is being generated on 5/12/2014. However from my analysis, the filter on XAO 10 week MA should exclude the trade.
I would welcome any comment on where my code is incorrect.
If you're using an index filter then you need to have the "pad and align data to reference symbol" box in the AA settings ticked and also the reference symbol set to "XAO".
Captain Black -thanks foir your reply, but I do have this setting tick. So this is not the issue
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?