How to buy x ticks away from open price

Questions about MultiCharts and user contributed studies.
rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

How to buy x ticks away from open price

Postby rkhan » 24 Nov 2014

Hi guys,

I need to know how to buy say 8 ticks from the open?

The problem is that if i use a 1min chart, the calculation seems to happen after the chart is closed.
So i cann't simply say Open + 8 ticks

Because it only seems to know the open after the bar has closed.

So what i want to do is at the open of the SP500 day market, i want to buy open price (ie when market opens) + 8 ticks above or below

Any help or suggestions would be appreciated

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: How to buy x ticks away from open price

Postby Andrew MultiCharts » 24 Nov 2014

Hello rkhan,

You need to use IOG to recalculate code on openining tick of next bar and use its value + 8 ticks to generate the order and send it on the second tick of the new bar. If the graph is not updating fast enough, you may need to use RecalcLastBarAfter(1).

rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

Re: How to buy x ticks away from open price

Postby rkhan » 29 Nov 2014

Dear Sir,

How is this possible?

All i want to do is buy 8 ticks above the opening price of the day.

But you see, to use a limit or stop order, i must use the code NEXT
if i use this, then i can only use CLOSE, but i dont want to buy on close.

Now, how will i know if it is the NEXT bar will be the opening bar?

So i cannot use NEXT, because i dont know if the next bar is the opening bar.

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

Re: How to buy x ticks away from open price

Postby JoshM » 29 Nov 2014

All i want to do is buy 8 ticks above the opening price of the day.

But you see, to use a limit or stop order, i must use the code NEXT
if i use this, then i can only use CLOSE, but i dont want to buy on close.

Now, how will i know if it is the NEXT bar will be the opening bar?

So i cannot use NEXT, because i dont know if the next bar is the opening bar.
When intra-bar order generation (IOG) is turned on, "next bars" means "next tick" because IOG will force the script to be re-evaluated on every price update, and not only on every bar.

Have you tried something like the following (purely an example):

Code: Select all

[IntrabarOrderGeneration = true];

Variables:
IntraBarPersist openPrice(0);

// Check for opening price of the day,
// on the first bar of the day
if (Date <> Date[1]) then begin

openPrice = Open + 2; // + 8 ES mini ticks

end;

// Submit the orders on all other bars
if (MarketPosition(0) = 0) and (openPrice <> 0) then begin

Buy 1 contracts next bar at openPrice limit;

end;


Return to “MultiCharts”