EL SYNTAX: open next bar limit  [SOLVED]

Questions about MultiCharts and user contributed studies.
hilbert
Posts: 224
Joined: 17 Aug 2011
Has thanked: 76 times
Been thanked: 64 times

EL SYNTAX: open next bar limit

Postby hilbert » 18 Oct 2013

Based on discussion in another thread, I did some testing and concluded that open next bar limit does not work in powerlanguage. However, if

Code: Select all

buy next bar at open next bar limit;
is used, the study still compiles. So, it must mean something. Please clarify below:

1) What does this syntax mean in powerlanguage. I did some experiments but I am not sure what kind of orders are being resulted using following syntax?

Code: Select all

buy next bar at open next bar limit;
2) if I want to buy at open of next bar using a "limit" order, how do I do it?

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: EL SYNTAX: open next bar limit

Postby MAtricks » 18 Oct 2013

Currently:
Buy next bar open limit = Buy next bar open[1] limit

What we want to do and what we tell MC to do:
Code:
Buy next bar open limit ;
Which means:
Buy at the next open when this bar has closed

What MC does instead:

Image

Which is what I'm trying to fix :)
Attachments
sdfsdf.png
(26.17 KiB) Downloaded 1239 times

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: EL SYNTAX: open next bar limit

Postby MAtricks » 18 Oct 2013

Unless of course we have IOG turned on... and at that point, this works correctly, but comes with the cost a much more delicate process and a revamp of code.

hilbert
Posts: 224
Joined: 17 Aug 2011
Has thanked: 76 times
Been thanked: 64 times

Re: EL SYNTAX: open next bar limit

Postby hilbert » 18 Oct 2013

Currently:
Buy next bar open limit = Buy next bar open[1] limit

What we want to do and what we tell MC to do:
Code:
Buy next bar open limit ;
Which means:
Buy at the next open when this bar has closed
Hello,
I would like to know the meaning of this:

Code: Select all

buy next bar at open next bar limit;
you are telling me the meaning of this:

Code: Select all

buy next bar at open limit;
Please note that Both are different.

Separately, I understand your viewpoint but I beg to differ. When one uses any keyword like open,high, low, close etc. in a strategy, it is pretty clear that one is talking about the current bar. So, when you use a code like:

Code: Select all

buy next bar at open limit;
its clear to me that you are buying on the next bar using a limit order at the open price of current bar. There is no confusion here and it is the same as in easy language.

The place where power language differs with easy language is that following code:

Code: Select all

buy next bar at open next bar limit;
works in easy language but does not work in power language.

I would like to know from the MC team what this code means in power language:

Code: Select all

buy next bar at open next bar limit;

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: EL SYNTAX: open next bar limit  [SOLVED]

Postby Henry MultiСharts » 22 Oct 2013

Separately, I understand your viewpoint but I beg to differ. When one uses any keyword like open,high, low, close etc. in a strategy, it is pretty clear that one is talking about the current bar. So, when you use a code like:

Code: Select all

buy next bar at open limit;
its clear to me that you are buying on the next bar using a limit order at the open price of current bar. There is no confusion here and it is the same as in easy language.
That is correct.
The place where power language differs with easy language is that following code:

Code: Select all

buy next bar at open next bar limit;
works in easy language but does not work in power language.

I would like to know from the MC team what this code means in power language:

Code: Select all

buy next bar at open next bar limit;
Easy Language and Power Language are the same here as well.
Calculation per bar can be executed in one of the two modes:
1. Calculation upon Close of each bar and filling of the generated orders collection on the next bar. This is the default mode.

2. Calculation upon Open of each bar in the context of the previous bar and filling of the generated orders collection on this bar. This mode is enabled by using "open next bar" or "time next bar" command in the code.

Open and Time values for the next bar become available through the following functions: open next bar and time next bar.

But the calculation is still executed in the context of the current bar close (for example, Close[0] – will still return Close of the current bar, despite the calculation being executed at the Open of the next bar).

I have double checked that on MultiCharts 8.8 beta 2.

hilbert
Posts: 224
Joined: 17 Aug 2011
Has thanked: 76 times
Been thanked: 64 times

Re: EL SYNTAX: open next bar limit

Postby hilbert » 22 Oct 2013

Calculation per bar can be executed in one of the two modes:
1. Calculation upon Close of each bar and filling of the generated orders collection on the next bar. This is the default mode.

2. Calculation upon Open of each bar in the context of the previous bar and filling of the generated orders collection on this bar. This mode is enabled by using "open next bar" or "time next bar" command in the code.

Open and Time values for the next bar become available through the following functions: open next bar and time next bar.

But the calculation is still executed in the context of the current bar close (for example, Close[0] – will still return Close of the current bar, despite the calculation being executed at the Open of the next bar).

I have double checked that on MultiCharts 8.8 beta 2.
Thanks Henry!

I ran a simple test to better understand the difference between the two versions.
Mode 1: (Standard mode)

Code: Select all

inputs: range(5);
condition1 = T = 935;
condition2 = C-O>range;
if condition1 and condition2 then buy next bar at open limit;
Above code results into trades happening at 940 bar with a limit order at the open price of 935 bar
Mode 2: Open next bar mode

Code: Select all

inputs: range(5);
condition1 = T = 935;
condition2 = C-O>range;
if condition1 and condition2 then buy next bar at open next bar limit;
Above code results into trades that happen at the opening of 935 bar using open price of 935 bar. All calculations - other than time - get done on one bar before 935 bar. So, if I am using RTH hours for ES, all the calculations happen on 1615 bar of previous day.

So, if I want to buy using open price of 940 bar, I need to use Mode 2, however I need to use T = 940 in the above code. Then limit orders will be generated at open price of 940 bar but the calculations will be done on 935 bar. I have verified this. Thanks.

Cheers,

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: EL SYNTAX: open next bar limit

Postby Henry MultiСharts » 24 Oct 2013

You can also get the time of the next bar with the "time next bar" command in the code.


Return to “MultiCharts”