Backtest - Dynamic Trailing Stop

I’m trying to get a dynamic trailing stop working in the Backtester.

My understanding is that a trailing stop needs to go in the Stops section, not the Exit Criteria.

The image below is the script I would really like to work - using ATR. But the Backtester doesn’t seem to like ATRTSCAN and ignores the script.

I also tried using a percentage stop:-

s1 = STOP(STOPTYPE=Percent, CALC=High, TRAILING=True, STOPVALUE=10.00);

s2 = STOP(STOPTYPE=Percent, CALC=High, TRAILING=True, STOPVALUE=40.00);

m1 = IF(ROC(BARS=52) < MA(ROC(BARS=52), BARS=8, STYLE=Exponential, CALC=Close),s1,s2);

CLOSE() < m1

But the Backtester used a 10% trailing stop all of the time, regardless of my other condition.

Where am I going wrong? Or it this even possible?

Thanks for any suggestions.

snip

 

Anyone?

Hi,

Have you applied the script to a chart to confirm it is doing what you expect it to there? That’s the first step.

If the script is working as expected (or once you’ve adjusted it to work as you want), i’d suggest not adding it to the Stops section in the back tester, it’s designed for basic stops only. Instead add it to the Exits section and place an OR between it and the other exit criteria you’ve setup.

Hi Matthew and thanks for your reply.

Yes, I have tried to apply the ATRTSCAN script as above to a Show Plot and it shows nothing - I seem to remember reading somewhere that ATRTSCAN will only work in the Stops section of the Backtester.

Below is the working script I use on my charts for the trailing stop:-

a30 = ATR(BARS=10, MULT=1.00);

a10 = ATR(BARS=10, MULT=5.00);

a1 = if(ROC(BARS=52) > MA(ROC(BARS=52),BARS=8, CALC=Close, STYLE=Exponential), a10, a30);

c1 = HIGH() - a1;

RATCHET(c1, START=2019-02-08)

But, the trailing stop is dependent on the START date, so how do I code the START date to automatically reflect the different dates of entry in the Backtester?

Many thanks

Merrilee

 

 

Hi,

Can you send a copy of your back testing file setup to support for review.

The file will be found here:

My Documents - Optuma - Local - Searches - Back Tests