Exclude trading times

Questions about MultiCharts and user contributed studies.
yonobarn
Posts: 8
Joined: 23 Apr 2011
Has thanked: 4 times

Exclude trading times

Postby yonobarn » 09 Apr 2012

Is there a way to identify a time on a particular date, and not trade x minutes either side of that time on that date?

For example, the input is 1120410 (April 10, 2012) and 900 (9:00am) and we do not want to trade 30 minutes before or 60 minutes after.

Data is 1 minute bars.

Many thanks in advance.

User avatar
Roman MultiCharts
Posts: 50
Joined: 28 Nov 2011
Has thanked: 21 times
Been thanked: 66 times

Re: Exclude trading times

Postby Roman MultiCharts » 11 Apr 2012

Hello yonobarn,

Here's the samle code that you can use in your strategy


Code: Select all

inputs:
Date_To_Trade(1120411),Start_Time(900);

variables: Trading_Time(True);

If date = Date_To_Trade then
begin

If Time  >  Start_Time-70 and Time < Start_Time then Trading_Time = false;
If Time  >  Start_Time  and Time < Start_Time+60 then Trading_Time = false;
If time > Start_Time+60 then Trading_Time = true;


If Trading_Time = True then
   begin

//your strategy script
   
   end;
end;
These users thanked the author Roman MultiCharts for the post:
yonobarn


Return to “MultiCharts”