Function which runs at set intervals during a 1hr bar

Questions about MultiCharts and user contributed studies.
champski
Posts: 71
Joined: 28 Jun 2011
Has thanked: 20 times
Been thanked: 1 time

Function which runs at set intervals during a 1hr bar

Postby champski » 17 Apr 2014

Hi,

I'd like to be able to run a "check" every 10 minutes to see what the current price is during a 1hr bar.
Is this possible at all?

Regards
Champski

User avatar
Smoky
Posts: 507
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 97 times
Been thanked: 115 times

Re: Function which runs at set intervals during a 1hr bar

Postby Smoky » 17 Apr 2014

Take a look about "RecalcLastBarAfter(600);" ;)

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

Re: Function which runs at set intervals during a 1hr bar

Postby TJ » 17 Apr 2014

Hi,
I'd like to be able to run a "check" every 10 minutes to see what the current price is during a 1hr bar.
Is this possible at all?
Regards
Champski
you can simply add a 10 minute chart to your window.

champski
Posts: 71
Joined: 28 Jun 2011
Has thanked: 20 times
Been thanked: 1 time

Re: Function which runs at set intervals during a 1hr bar

Postby champski » 21 Apr 2014

Sorry guys, I should have been more specific.
This is for automated trading. I use a 1hr chart and need to know what the price is after 50 minutes. If the price meets my condition(s) then I would like to enter a trade immediately. Normally I wait until the end of the bar to enter the trade but I'd like to find a way to enter 10 minutes early.

I had a look at using RecalcLastBarAfter(500) but I can't see that it's going to do what I need in this scenario.

Any assistance would be greatly appreciated.

Regards
Champski

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

Re: Function which runs at set intervals during a 1hr bar

Postby TJ » 21 Apr 2014

Sorry guys, I should have been more specific.
This is for automated trading. I use a 1hr chart and need to know what the price is after 50 minutes. If the price meets my condition(s) then I would like to enter a trade immediately. Normally I wait until the end of the bar to enter the trade but I'd like to find a way to enter 10 minutes early.
I had a look at using RecalcLastBarAfter(500) but I can't see that it's going to do what I need in this scenario.
Any assistance would be greatly appreciated.
Regards
Champski
See post #4
[FAQ] Multiple time frame, Multi-Data Analysis
viewtopic.php?f=16&t=6929

champski
Posts: 71
Joined: 28 Jun 2011
Has thanked: 20 times
Been thanked: 1 time

Re: Function which runs at set intervals during a 1hr bar

Postby champski » 21 Apr 2014

Sorry guys, I should have been more specific.
This is for automated trading. I use a 1hr chart and need to know what the price is after 50 minutes. If the price meets my condition(s) then I would like to enter a trade immediately. Normally I wait until the end of the bar to enter the trade but I'd like to find a way to enter 10 minutes early.
I had a look at using RecalcLastBarAfter(500) but I can't see that it's going to do what I need in this scenario.
Any assistance would be greatly appreciated.
Regards
Champski
See post #4
[FAQ] Multiple time frame, Multi-Data Analysis
viewtopic.php?f=16&t=6929
TJ,

The only problem with this is that my system has been written for 1hr resolution. The link says you should always use the slower resolution as data2
eg. 1 min as data1, and 5 min as data2.

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

Re: Function which runs at set intervals during a 1hr bar

Postby TJ » 21 Apr 2014

Sorry guys, I should have been more specific.
This is for automated trading. I use a 1hr chart and need to know what the price is after 50 minutes. If the price meets my condition(s) then I would like to enter a trade immediately. Normally I wait until the end of the bar to enter the trade but I'd like to find a way to enter 10 minutes early.

I had a look at using RecalcLastBarAfter(500) but I can't see that it's going to do what I need in this scenario.

Any assistance would be greatly appreciated.

Regards
Champski
What you are really saying is...

You are trading a 60 min chart that ends at the 50th minute of every hour.

champski
Posts: 71
Joined: 28 Jun 2011
Has thanked: 20 times
Been thanked: 1 time

Re: Function which runs at set intervals during a 1hr bar

Postby champski » 22 Apr 2014

Sorry guys, I should have been more specific.
This is for automated trading. I use a 1hr chart and need to know what the price is after 50 minutes. If the price meets my condition(s) then I would like to enter a trade immediately. Normally I wait until the end of the bar to enter the trade but I'd like to find a way to enter 10 minutes early.

I had a look at using RecalcLastBarAfter(500) but I can't see that it's going to do what I need in this scenario.

Any assistance would be greatly appreciated.

Regards
Champski
What you are really saying is...

You are trading a 60 min chart that ends at the 50th minute of every hour.
No, I'm trading a 60 minute chart and I usually wait until the end of the bar to see if my entry conditions are met so I can then go on to enter a trade at the start of the next bar.
What I'd like to do is to enter the market a little earlier (10 minutes earlier than the end of the bar) in the event it appears "highly likely" that my usual entry conditions "would" be met. This would give me a 10 minute headstart on a trade that I would normally take anyway.

Does that make sense?

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

Re: Function which runs at set intervals during a 1hr bar

Postby JoshM » 22 Apr 2014

No, I'm trading a 60 minute chart and I usually wait until the end of the bar to see if my entry conditions are met so I can then go on to enter a trade at the start of the next bar.
What I'd like to do is to enter the market a little earlier (10 minutes earlier than the end of the bar) in the event it appears "highly likely" that my usual entry conditions "would" be met. This would give me a 10 minute headstart on a trade that I would normally take anyway.

Does that make sense?
Adding a second data series makes this needlessly complicated and resource intensive, I think. Why not do the following?

1. Calculate the time of next bar (current bar opening time + 60 minutes in your case),
2. Subtract 10 minutes from this,
3. Verify if the current tick time (IOG set to true) is greater than the value you got at step 2 but less than the value at step 1.
4. As long as step 3 evaluates to true, keep submitting the orders in that 10 minute time window (in other words, only submit orders when step 3 is true).

See the Date and time reserved words to get you started.

champski
Posts: 71
Joined: 28 Jun 2011
Has thanked: 20 times
Been thanked: 1 time

Re: Function which runs at set intervals during a 1hr bar

Postby champski » 23 Apr 2014

No, I'm trading a 60 minute chart and I usually wait until the end of the bar to see if my entry conditions are met so I can then go on to enter a trade at the start of the next bar.
What I'd like to do is to enter the market a little earlier (10 minutes earlier than the end of the bar) in the event it appears "highly likely" that my usual entry conditions "would" be met. This would give me a 10 minute headstart on a trade that I would normally take anyway.

Does that make sense?
Adding a second data series makes this needlessly complicated and resource intensive, I think. Why not do the following?

1. Calculate the time of next bar (current bar opening time + 60 minutes in your case),
2. Subtract 10 minutes from this,
3. Verify if the current tick time (IOG set to true) is greater than the value you got at step 2 but less than the value at step 1.
4. As long as step 3 evaluates to true, keep submitting the orders in that 10 minute time window (in other words, only submit orders when step 3 is true).

See the Date and time reserved words to get you started.
I like this idea but I have had a look at the date and time routines and am not sure how to code this.

Does anyone know how to add and subtract time (which will work with live and historical data?)
eg.

Code: Select all

Condition1 = Time of previous bar + 50 minutes
If currenttimeonchart = condition1 then enter a trade

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

Re: Function which runs at set intervals during a 1hr bar

Postby JoshM » 02 May 2014

I like this idea but I have had a look at the date and time routines and am not sure how to code this.

Does anyone know how to add and subtract time (which will work with live and historical data?)
eg.

Code: Select all

Condition1 = Time of previous bar + 50 minutes
If currenttimeonchart = condition1 then enter a trade
You need to convert it to DateTime first to get accurate calculations (see ELTimeToDateTime).


Return to “MultiCharts”