i have 1 min data while i want to make calculation on 3 minute bar.
at end of each 3 min bar, if condition = true, i want to buy at on next 1 min bar close price. how can i do this?
e.g.
i'm calculating my indicator using 3 min bars at ... 10:00, 10:03, 10:06 and if 10:06 give me a buy condition, i want to buy at 10:07 close.
i know i need to set [intrabarordergeneration=true], but not really sure how to use that .
thanks
how to buy next bar at close
-
- Posts: 91
- Joined: 10 Dec 2010
- Has thanked: 2 times
- Been thanked: 1 time
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: how to buy next bar at close
You cannot buy at the close price, you can only do that in back test.i have 1 min data while i want to make calculation on 3 minute bar.
at end of each 3 min bar, if condition = true, i want to buy at on next 1 min bar close price. how can i do this?
e.g.
i'm calculating my indicator using 3 min bars at ... 10:00, 10:03, 10:06 and if 10:06 give me a buy condition, i want to buy at 10:07 close.
i know i need to set [intrabarordergeneration=true], but not really sure how to use that .
thanks
In real life, when you have determined that a specific tick is the close, theoretically the close has already passed. You cannot buy at an event that has already happened. The best you can do is to buy at the tick AFTER the close, which is the open of the following bar.
ps. unless you can show me at 10:06:59.99 the price of the next tick.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: how to buy next bar at close
someone asked a similar type of question, maybe you can understand the "timing" problem in this illustration:
A trader wants to buy at the open if the OPEN is higher than the previous close,
and wants to sell at the open if the OPEN is lower than the previous close.
Well, when the OPEN has happened, you can determine whether you should buy or to sell.
But by the time you have determined the course of action, you will not be executing it at the OPEN anymore, you are trading at the tick AFTER the open.
Click "Thanks" if it makes sense.
A trader wants to buy at the open if the OPEN is higher than the previous close,
and wants to sell at the open if the OPEN is lower than the previous close.
Well, when the OPEN has happened, you can determine whether you should buy or to sell.
But by the time you have determined the course of action, you will not be executing it at the OPEN anymore, you are trading at the tick AFTER the open.
Click "Thanks" if it makes sense.
-
- Posts: 91
- Joined: 10 Dec 2010
- Has thanked: 2 times
- Been thanked: 1 time
Re: how to buy next bar at close
TJ, i'm actually talking about back test, and the codeYou cannot buy at the close price, you can only do that in back test.i have 1 min data while i want to make calculation on 3 minute bar.
at end of each 3 min bar, if condition = true, i want to buy at on next 1 min bar close price. how can i do this?
e.g.
i'm calculating my indicator using 3 min bars at ... 10:00, 10:03, 10:06 and if 10:06 give me a buy condition, i want to buy at 10:07 close.
i know i need to set [intrabarordergeneration=true], but not really sure how to use that .
thanks
In real life, when you have determined that a specific tick is the close, theoretically the close has already passed. You cannot buy at an event that has already happened. The best you can do is to buy at the tick AFTER the close, which is the open of the following bar.
ps. unless you can show me at 10:06:59.99 the price of the next tick.
Buy("long") next Bar on Close;
actually gives me a complier error.
let me know if i can correct this in backtest.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: how to buy next bar at close
If you want a solution, you will need toTJ, i'm actually talking about back test, and the codeYou cannot buy at the close price, you can only do that in back test.i have 1 min data while i want to make calculation on 3 minute bar.
at end of each 3 min bar, if condition = true, i want to buy at on next 1 min bar close price. how can i do this?
e.g.
i'm calculating my indicator using 3 min bars at ... 10:00, 10:03, 10:06 and if 10:06 give me a buy condition, i want to buy at 10:07 close.
i know i need to set [intrabarordergeneration=true], but not really sure how to use that .
thanks
In real life, when you have determined that a specific tick is the close, theoretically the close has already passed. You cannot buy at an event that has already happened. The best you can do is to buy at the tick AFTER the close, which is the open of the following bar.
ps. unless you can show me at 10:06:59.99 the price of the next tick.
Buy("long") next Bar on Close;
actually gives me a complier error.
let me know if i can correct this in backtest.
1. post the code
2. copy and paste the error message (or screenshot)
The PLE does not give an error message unless there is an error in coding.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: how to buy next bar at close
tryTJ, i'm actually talking about back test, and the code
Buy("long") next Bar on Close;
actually gives me a complier error.
let me know if i can correct this in backtest.
Buy("long") THIS Bar on Close;
-
- Posts: 91
- Joined: 10 Dec 2010
- Has thanked: 2 times
- Been thanked: 1 time
Re: how to buy next bar at close
no, this is not what i want, what i want istryTJ, i'm actually talking about back test, and the code
Buy("long") next Bar on Close;
actually gives me a complier error.
let me know if i can correct this in backtest.
Buy("long") THIS Bar on Close;
calculation based on 3 min bar, and enter position at the end of the 1 min bar after the 3 min bar.
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Re: how to buy next bar at close
Just set up a boolean variable that tells you when the conditions are met to buy the next bar t the close and when they are met, then wait 1 bar and then buy the next bar at the close. It's a pretty simple programming thing.