Exclude date ranges

1 replies

Brett Pattinson

Subscriber, bbp_participant, 2 replies.

Visit profile

1 year ago #282005

Hi,

For long term trading strategies I use the SKEW as a trade filter, ie. when not to trade and go to cash.

In SQX, how would I go about creating a date filter to prevent trading during set dates.

Example:

01 Oct. 2018 – 30th Dec 2018

01 Jan. 2020 – 30th March 2020

Ideally I would like to add or remove from any strategy at will, so happy if it is a custom block or trade signal or any other recommendation.

This is what it would look like in MT5:

//SKEW Trade Filter for MT5

input datetime InpSkipFrom2020 = D’1.1.2020′;

input datetime InpSkipTill2020 = D’1.4.2020′;

input datetime InpSkipFrom2022 = D’1.1.2022′;

input datetime InpSkipTill2022 = D’30.10.2022′;

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

1 year ago #282011

Hi,

there are basically at least 2 ways of doing this.

First you could make a new custom block that will represent “calendars” of those days. You can check here for more information https://strategyquant.com/codebase or request help directly here https://strategyquant.com/codebase/request-coding/

Another way would be a use of a custom function in MQL5 (MT5). The function would also return True / False based on where today’s date is matching your calendar.

You place the MQL function into this file \user\extend\Code\MetaTrader5\CustomFunctions\CustomFunctions.mq5 and refer to it in AlgoWizard – see the pic attached

Attachments:
You must be logged in to view attached files.

0

Viewing 1 replies (of 1 total)