There is not any full backtest code example on your end!
We (readers) can not walk on water and are not able to look at other peoples PCs from miles distances away.
Certainly (or rather for sure).
Again no one here knows what you have done. You have just posted a short incomplete snippet of a bigger picture. Your observation has to reproducible. Your example does nothing else other than changing between different assignments.
Must read here.
There aren't any detailed information about your results in your post!
Since you did not provide details at all:
Generally trade prices like BuyPrice, Sellprice, ... added to AFL do override the ones of Backtest settings - Trades page. There are exceptions though...
Trade prices of code do not override the ones of backtest settings dialog:
- if using SetBacktestMode( backtestRotational ) (or old method EnableRotationalTrading() )
The rotational trading mode uses "buy price" and "buy delay" from the Settings | Trade page as trade price and delay for both entries and exits (long and short)
- If using ApplyStop then:
ExitAtStop = 0 uses SellPrice/CoverPrice variables in backtestRegular mode only , in other modes it uses trade prices from the Settings dialog (not overridable via SellPrice/CoverPrice)
Where have you actually set Param setting? From chart (only)?
If so and you expect it would apply that setting of chart in analysis too then you are on wrong track.
Analysis window has its own separate Param window.
(Besides better use hardcoded settings in analysis since param* settings are shared between multiple analysis windows -> all analysis windows have chart id value of zero.)
BTW following one is a reproducible complete example. Not sure what is so difficult about providing one(?)
TrdDly = ParamToggle("Trade at","CLOSE|OPEN",1);
if( TrdDly > 0 )
BuyPrice = SellPrice = Open;
BuyPrice = SellPrice = Close;
m = MA( Close, period = 20 );
Buycond = Cross( Close, m );
Sellcond = Cross( m, Close );
Buy = Ref(Buycond, -TrdDly);
Sell = Ref(Sellcond, -TrdDly);
Short = Cover = 0;
PlotShapes( Buycond * shapeUpArrow + Sellcond * shapeDownArrow,
IIf( Buycond, colorGreen, colorRed ), layer = 0,
y = IIf( Buycond, L, H ), dist = -12 );
PlotShapes( (Buy + Sell) * shapeSmallCircle,
IIf( Buy, colorGreen, colorRed ), layer = 0,
y = IIf( Buy, BuyPrice, SellPrice ), dist=0 );
Plot( C, "Price", colorDefault, styleBar );
And as you can see if executing upper code prices are getting overridden.
Trade prices at OPEN (via AFL code)
Analysis result list showing the same entries/exits. And overriding Close price settings of Analysis settings - Trades page.
Trade prices at CLOSE (via AFL code)
Analysis result list showing the same entries/exits again.
BTW this has been a detailed response.