There is a problem with SetTradedelay & buyprice that I can’t figure out; apologies for potential stupid error here and thanks in advance if someone can help me find the problem. I detected an issue with a rotation system, as it did not seem to be correctly implementing executing my settings from the afl code, yet the problem was not occurring on non-rotation systems.
To debug the problem, I have gone back to the most basic version:
- New clean install of 6.20.1 x32 bit.
- Only used the unmodified database that comes with the install.
- Using the ExampleRotational.afl version that comes with install.
Always in the past, as consistent with the manual, the afl code commands with SetTradedelay & buyprice (etc) always overrode whatever the Backtester settings from the Trades tab. However, now when I change the afl code for SetTradedelay & buyprice, the results do not properly change, further, changing the backtester settings trade tab choices are somehow overriding the afl code settings.
To illustrate and simply this, I ran it with the simple rotation with following alf settings lines
SetTradeDelays( 0, 0, 0, 0 );
BuyPrice = CoverPrice = SellPrice = ShortPrice = Close;
1st run settings in pdf “Sample Rotation SDC +in system options.PNG”, using the backtester settings trades of “trade current bar on close”.
2nd run attached pdf “Sample Rotation SDC +different in system options.PNG”, everything identical, with identical afl, only changing the backtester settings trades to “trade next bar on open”. The trading results change, overriding the afl settings, and you can see the buy price is now set to open, not close.
Here is a Dropbox link (https://www.dropbox.com/sh/8qknbvyjmm9lrin/AAClo8MgksgH9chngqmhDopqa?dl=0 ) where you can download PDFs of the two full test runs, including stats, trades, afl used, settings. The naming convention is the same as the PNG settings picture.
What am I missing?
formn = ParamStr( "set name", "Rotation Test SDC" ); SetFormulaName(formn); MaxPositions = 4; SetOption("MaxOpenPositions", MaxPositions ); SetOption("WorstRankHeld", MaxPositions + 2 ); SetPositionSize( 100 / MaxPositions, spsPercentOfEquity ); // ----------- Execution Delay Time -------------------------- // Same Day Close SetTradeDelays( 0, 0, 0, 0 ); // same day BuyPrice = Close; CoverPrice = SellPrice = ShortPrice = Close; // trade the close // Nxt day Open //SetTradeDelays( 1,1,1,1); // 1 day delay //BuyPrice = CoverPrice = SellPrice = ShortPrice = open; // trade the open SetBacktestMode( backtestRotational ); // offsetting by large positive number // makes sure that our score is always positive and we don't enter short trades PositionScore = 10000 - ROC( C, 252 ); type or paste code here