Error 43 in backtestRegularRawMulti mode

Hello,

I am trying to code a simple system (non rotational) which can have multiple open positions per symbol and at the same time using stopTypeLoss. I tried with SetBacktestMode (backtestRegularRawMulti); but I go an error " Error 43. Variable stops are not supported in Rotational Trading mode".

I need help how can I code multiple open positions and stopTypeLoss at the same time?

Then why are you using Rotation mode?

You have not posted your code.

First, you didn't post the code. Posting code is essential. Otherwise we can't point you to the exact line you have wrong in your code.
And one of ApplyStop lines in your code is wrong.
So POST THE CODE when asking any question about AFL.

Secondly, the error message WAS a little bit misleading. The restriction applies to any backtest mode other than backtestRegular.
And actually wording of the error message in recent versions (such as 6.40) is different. It says:

Error 43. Variable stops are not supported in Rotational and Raw backtest modes

So you must be using old version, if you get old message.

Only in backtestRegular you are allowed to have variable stops (i.e. stops where the "amount" varies bar by bar).
In all other modes you can only have stops where the "amount" argument to ApplyStop is scalar value (not array).

The error is of course explained in the users guide:
http://www.amibroker.com/guide/errors/43.html

The solution is to FIX your code (i.e. ApplyStop calls).

Here is my code :

BandPeriod = Param("Band_Period", 7,1,5000,1); 
BandPeriodExit = Param("Band_Period_Exit", 1,1,5000,1); 
SLMultiple = Param("SL Multiple", 10,1,5000,1); 
SL_ATR_Period = Param("SL_ATR_Period", 100,1,5000,1); 



upper_band = HHV(H,BandPeriod);
lower_band = LLV(L,BandPeriod);


upper_band_exit = HHV(H,BandPeriodExit);
lower_band_exit = LLV(L,BandPeriodExit);



Buy = Cross(Ref(lower_band, -1),C);
Short = Cross(C, Ref(upper_band, -1));

Sell = Cross(C, Ref(upper_band_exit, -1)) ;
Cover = Cross(Ref(lower_band_exit, -1),C) ;



BuyPrice = Open;
ShortPrice = Open;
SellPrice = Open;
CoverPrice = Open;

SetTradeDelays(1,1,1,1);



//
RiskPerContract = SLMultiple * ATR( SL_ATR_Period );
ApplyStop( stopTypeLoss, stopModePoint, RiskPerContract,1 );


// risk 1% of entire equity on single trade
PositionRisk = 1;
PctSize =  PositionRisk * MarginDeposit  / ( RiskPerContract * PointValue );
SetPositionSize( PctSize, spsPercentOfEquity );

I want the above code to produce multiple open positions per symbols and at the same time to use Stop Loss as function of ATR (as in the code). So, how can I do it?

In short, ATR stops are variable on bar by bar basis. If you want to use them you have to use regular backtest mode.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.