Exit Criteria In Backtester

Hi,

I am looking for a different exit when index is above certain threshold. So i am using it with if statement as follows.

d1=GETDATA(CODE=NIFTY50:NSE, CURRENCY=INR);

m1=ma(d1, BARS=100, STYLE=Exponential, CALC=Close);

h1 = d1>m1

e1 = low() CrossesBelow 0.80 * HIGHESTHIGH(RANGE=All History, INCBAR=True);
e2 = low() CrossesBelow 0.90 * HIGHESTHIGH(RANGE=All History, INCBAR=True);
IF(h1,e1,e2)

But this is not working in exit criteria is something wrong with this script.

I don’t think IF statements can be used in exit criteria like that.

Try something like this:

d1=GETDATA(CODE=NIFTY50:NSE, CURRENCY=INR);

m1=ma(d1, BARS=100, STYLE=Exponential, CALC=Close);

h1 = d1>m1 and low() CrossesBelow 0.80 * HIGHESTHIGH(RANGE=All History, INCBAR=True);
h2 = d1<m1 and low() CrossesBelow 0.90 * HIGHESTHIGH(RANGE=All History, INCBAR=True);
//Signal;
h1 or h2