Backtest based on existing Buy / Sell periods

Hello guys,

I thought it would be dead easy but I must be very tired...

Anyway here's the issue : I want to backtest a system for which I only have buy/sell dates (i.e. it's not my system, it's a signal provider's system).

e.g. Buy/Be long from 27/05/2021 to 18/06/2021, Buy / be long from 18/06/2021 to 24/06/2021...etc

I thought I could just use something like this (my windows settings match DD/MM/YYYY):

BuyPeriod1 = (DateTimeDiff( DateTime(), StrToDateTime("18/06/2021") ) >= 0) AND (DateTimeDiff( DateTime(), StrToDateTime("24/06/2021") ) < 0);
BuyPeriod2 = (DateTimeDiff( DateTime(), StrToDateTime("27/05/2021") ) >= 0) AND (DateTimeDiff( DateTime(), StrToDateTime("18/06/2021") ) < 0);
BuyPeriod3 = (DateTimeDiff( DateTime(), StrToDateTime("26/05/2021") ) >= 0) AND (DateTimeDiff( DateTime(), StrToDateTime("27/05/2021") ) < 0);
BuyPeriod4 = (DateTimeDiff( DateTime(), StrToDateTime("24/05/2021") ) >= 0) AND (DateTimeDiff( DateTime(), StrToDateTime("26/05/2021") ) < 0);

Buy = BuyPeriod1 OR BuyPeriod2 OR BuyPeriod3 OR BuyPeriod4;

Sell = NOT Buy;

However it doesn't work, it stays long all the time.

Does any of you have an idea of what might be wrong ?

Thanks a lot,

@BenA you must have been very tired. Your dates are contiguous and so you are continuously on a Buy signal.

An official Knowledge Base article that is tangentially related to your question might also be worth a look,

A very useful post that we should remind all forum users to examine,

2 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.