Page 1 of 1

Function which runs at set intervals during a 1hr bar

Posted: Apr 17 2014
by champski
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

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

Posted: Apr 17 2014
by Smoky
Take a look about "RecalcLastBarAfter(600);" ;)

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

Posted: Apr 17 2014
by TJ
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.

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

Posted: Apr 21 2014
by champski
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

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

Posted: Apr 21 2014
by TJ
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

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

Posted: Apr 21 2014
by champski
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.

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

Posted: Apr 21 2014
by TJ
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.

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

Posted: Apr 22 2014
by champski
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?

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

Posted: Apr 22 2014
by JoshM
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.

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

Posted: Apr 23 2014
by champski
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

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

Posted: May 02 2014
by JoshM
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).