Margin trading - removing buy/sell

Hi,

I currently want to make a backtest and only perform margin trading

I'm define my variables as

Cover = (strategy conditions in my code);
Short = (strategy conditions in my code);

Now, I only want it to perform either Cover or Short, not "buy" or "sell"
But I cant get around the correct way to write it, even if I write
buy = Cover;
sell = Short;

(My mistake is probably there), on the "Scan" I still get buy/sell...which I want to avoid and only open margin positions, I tried just taking the buy/sell out or apply a "null" function, but its not working.

Thanks for the help and support

If you want to scan/output Short/Cover only then simply use Short Cover variables but not Buy Sell.

m = MA( Close, 20 );

Short = Cross( m, Close );
Cover = Cross( Close, m );

Buy = Sell = 0;

And if you want to backtest Short direction (only) then you have to make sure that in Analysis setting - General - Positions there is either Short or Long and Short selected.

29

2 Likes