Time filter

Questions about MultiCharts and user contributed studies.
shanemcdonald
Posts: 196
Joined: 08 Aug 2012
Has thanked: 41 times
Been thanked: 41 times

Time filter

Postby shanemcdonald » 31 Aug 2014

Henry,

Do you have the time filter code for easylanguage ?

I saw the time filtercode you posted in .net fm and wondered if you can do same thing in powerlanguage ?

thanks

shane

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Time filter

Postby JoshM » 31 Aug 2014

From reading your other topic I guess you're looking for something like this:

Code: Select all

// Only trade during the main session
if (Time > 900) and (Time < 1530) then begin

// Perform the calculations,
// order submitting here

end;

shanemcdonald
Posts: 196
Joined: 08 Aug 2012
Has thanked: 41 times
Been thanked: 41 times

Re: Time filter

Postby shanemcdonald » 31 Aug 2014

Hi

Is it really that simple ?

I am new to easylanguage. I like the simplicity of it.

Do you know how you can flatten everything at 15:30 in relation to your code ?

thank you for your help,

shane

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Time filter

Postby JoshM » 01 Sep 2014

Do you know how you can flatten everything at 15:30 in relation to your code?
It is indeed simple compared to MultiCharts .NET or other, more elaborative programming languages. But being simple doesn't make it easy by definition. :]

To close all positions after the session:

Code: Select all

// As soon as it is later than 15:30:00..
if (Time_s > 153000) then begin

// Close all long contracts
if (MarketPosition(0) > 0) then
Sell ("XL") all contracts next bar at market

// Close all short contracts
else if (MarketPosition(0) < 0) then
BuyToCover ("XS") all contracts next bar at market;

end;

shanemcdonald
Posts: 196
Joined: 08 Aug 2012
Has thanked: 41 times
Been thanked: 41 times

Re: Time filter

Postby shanemcdonald » 01 Sep 2014

hi

thank you very much for your help with this.
I appreciate it !

regards
Shane

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Time filter

Postby TJ » 01 Sep 2014

When liquidating, you do not need to check for MarketPosition. The flattening order will only be sent if you have a position.

You can simplify the code as follows:

Code: Select all

// As soon as it is later than 15:30:00..
if (Time_s >= 153000) then
begin

Sell ("XL") all contracts next bar at market;
BuyToCover ("XS") all contracts next bar at market;

end;
This is assuming you are autotrading in sync, and you do not have any additional manual orders or orders from other strategies.


Return to “MultiCharts”