Short only strategy working in chart, but not in backtest. Error 701

/// This sets up the bars on the chart
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

// This sets up the styles for the indicators
LLowPrice = ParamField("LLowPrice",1);
LLfastcolor = ParamColor("LLfastcolor", colorAqua );
FastStyle = ParamStyle("FastStyle", styleDashed | styleNoLabel);

//Default Settings
LL_lookback = 252;
LL_FilterNumDays = 3;
LL_TicksBelow = 1; 
ATR_lookback = 14;
ATR_StopMulti = 2;

LL = llv( Low, LL_lookback);

myATR = ATR(ATR_lookback);  //set the hourly ATR

//// Strategy buy/sell signals  //////////////////////////
EntryQty = 1000 / Close;
SetPositionSize( EntryQty, spsShares ); 

LLbarsAgo = BarsSince(Ref(LL,0) < Ref(LL,-1));
printf( "LLbarsAgo: " + NumToStr( LLbarsAgo ) + "\n" ); 


ApplyStop( stopTypeTrailing, stopModePoint, ATR_StopMulti * myATR, True, True  );

shortPrice = Min(Ref(LL,-1) - .01 *LL_TicksBelow, Open);

coverPrice = Open ;

short = Close <= Ref(LL,-1) - .01 * LL_TicksBelow AND Ref(LLbarsAgo,-1) >= LL_FilterNumDays;
cover = open;

short = ExRem( short, cover );
cover = ExRem( cover, short ); 

PlotShapes(IIf(short, shapedownArrow, shapeNone),colorWhite,  0, shortPrice, Offset=-15); 
PlotShapes(IIf(cover, shapeupArrow, shapeNone),colorWhite, 0, coverPrice, Offset=-15);

This code will run fine on a single chart, but when I try to backtest it it gives an Error 701. "Missing Buy/Sell variable assignments."

I've tried putting in some mock Buy/Sells even though this is a short-only strategy, just to get around this, and that will make the error go away, but then no signals are generated on the backtest.

I've read in the manual, and all over the forums but cannot figure out why this short only strategy won't work.

Really the error explains everything by itself:

Error 701. "Missing Buy/Sell variable assignments."

It is in the users guide:

So..... obviously you have to have

Buy = False; // no long trades
Sell = False; // 
1 Like

I did read the manual over and over. No where did it explicitly say to set those to false like that. Now that you say it like this, it is very clear. It would help to have this in the manual.

Nowhere? How about


I do not see:
Buy = false;
Sell = false;

on this page. And when you click on the link underneath it is a broken link.

Believe me I am not trying to be argumentative. I simply am trying to figure this out. I am a 20yr TS user, and the people I work for want me to learn Ami, so here I am. Thank you for your assistance.

Or in backtester settings/general/position choose "short" if you don't buy in the AFL


Buy = Sell = 0;

@vjsworld as @PWFores has mentioned, you could alternatively do this in the back tester settings,

1 Like