Back Test Results

I’m trying to identify the actual entry date in the back tester where there are multiple buy signals prior to the exit signal, but I’m stuck!

I’ve simplified the entry and exit criteria below to save space, but the idea should be able to work no matter what the criteria. Anyway, what I’ve come up with isn’t working:


MA1 = MA(BARS=10, STYLE=Weighted, CALC=High) ;
MA2 = MA(BARS=50, STYLE=Weighted, CALC=High) ;


Rising = Close() > MA1 ;
ExitSignal = Rising and Rising[1] ;
ExitDate = BARDATE(ExitSignal) ;


EntrySignal = MA1 CrossesAbove MA2 ;
EntryDate = BARDATE(EntrySignal) ;

// Is there an exit between last two entry signals?

Seq1 = IF(ExitDate > EntryDate[1] AND ExitDate < EntryDate, 1 , 0) ;

BuyDate = IF(Seq1 == 1, EntryDate[1], EntryDate) ;


I suggested an enhancement to create a BACKTESTENTRYDATE (, but then thought I should be able to do it with scripting, but no joy.

Any help would be much appreciated!!

Hi Kim,

I see the issue here - TimeSinceSignal would exit all trades at once and you want the exit to happen only on a trade by trade basis.

A couple ways around this now would be to use the Max Hold Days setting. That will exit your trades after x days no matter what. There are no other filters though.

I think what we would need to do is add a “Time Stop” in the stops section. We can not do it in the Exit Criteria as that is only price-related TA. eg if you added your Entry and Exit on a chart as Show Bars, that is all the Backtester sees. That is why we pull out the stops into a separate section.

I’m about to start a major project on the testers and I will add a time stop to my list.

All the best


Hi Mathew,

A “Time Stop” would be a great addition, but wouldn’t solve my problem. I’ll have another go at describing it, hopefully better than last time.

I have an entry script that once it generates one buy signal, can generate several more signals before the trade is exited. The problem is that the back tester is unaware of which signal was used for the entry, so it uses the latest entry.

As an example, today is 21/10/20. Let’s assume Signal 1 occurs on 1/10/20 and is the entry used in the back tester; as at today the trade is down 15%. Let’s also assume Signal 2 occurs on 20/10/20 and the trade is still active. I want to use TIMESINCESIGNAL to check where the trade is after 20 days and exit if it is down by 10% or more, but in the back tester TIMESINCESIGNAL will use Signal 2 not Signal 1, so the trade won’t be exited until 9/11/20 (20 days after 20/10) at the earliest, longer if there’s a subsequent Signal 3. The same problem is true of the other “SINCE” tools.

My thinking is that in the back test results, Signal 1 will be used so there must be some indicator for the system to recognise that it’s the first trade found by the script. Exposing that indicator to the scripting language would solve the problem.

Cheers - and thanks again to all of you for the brilliant product and fantastic support.


hmmm - ok. I’ll add this to my notes and we’ll see what I can come up with when I get there.

Apologies for the double up, but as a few other people have raised it, I thought I’d share that link - to which I’ve also added my thoughts.