NEXT BAR OPEN at NEXT BAR LIMIT with Multiple Data Streams

Questions about MultiCharts and user contributed studies.
Adrian Uncle
Posts: 66
Joined: 26 Nov 2015
Has thanked: 7 times
Been thanked: 3 times

NEXT BAR OPEN at NEXT BAR LIMIT with Multiple Data Streams

Postby Adrian Uncle » 06 May 2016

Hi there,

I have the following two lines of code that runs on the 15M chart.

Code: Select all


if MarketPosition (0) =-1 then BUYTOCOVER ("close sell") NEXT BAR OPEN at NEXT BAR LIMIT ;
BUY ("enter buy") MinList (NumContracts, max_contract) CONTRACT NEXT BAR OPEN at NEXT BAR+BuyLimit_Offset LIMIT ;
How can I rewrite these codes so that I can attach the strategy to the 1M chart while referencing the 15M chart's NEXT BAR OPEN at NEXT BAR LIMIT?

I would like to avoid the error of " Open Next Bar type strategies calculation is not permitted on multiple datastreams."

Thanks

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

Re: NEXT BAR OPEN at NEXT BAR LIMIT with Multiple Data Strea

Postby TJ » 06 May 2016

Hi there,

I have the following two lines of code that runs on the 15M chart.

Code: Select all


if MarketPosition (0) =-1 then BUYTOCOVER ("close sell") NEXT BAR OPEN at NEXT BAR LIMIT ;
BUY ("enter buy") MinList (NumContracts, max_contract) CONTRACT NEXT BAR OPEN at NEXT BAR+BuyLimit_Offset LIMIT ;
How can I rewrite these codes so that I can attach the strategy to the 1M chart while referencing the 15M chart's NEXT BAR OPEN at NEXT BAR LIMIT?

I would like to avoid the error of " Open Next Bar type strategies calculation is not permitted on multiple datastreams."

Thanks

MultiCharts calculates the signal at the end of the bar (EOB),
it then springs into action at the opening of next bar.

At EOB, you do not know the opening value of the next bar,
that is why the calculation is not permitted.

This is the mechanical reality of a sequential process.

If you want to use the value of the opening in your calculation,
you have to WAIT until the OPEN has taken place.
ie. make your calculation after the first tick of the next bar.

Adrian Uncle
Posts: 66
Joined: 26 Nov 2015
Has thanked: 7 times
Been thanked: 3 times

Re: NEXT BAR OPEN at NEXT BAR LIMIT with Multiple Data Strea

Postby Adrian Uncle » 06 May 2016

TJ,

Thanks for your reply.

NEXT BAR OPEN at NEXT BAR LIMIT ; - Why does this code work on single data stream but not multiple data stream?

It seems that I have to change it to - BUY NEXT BAR MARKET?

Is there a solution around this?

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

Re: NEXT BAR OPEN at NEXT BAR LIMIT with Multiple Data Strea

Postby TJ » 06 May 2016

TJ,

Thanks for your reply.

NEXT BAR OPEN at NEXT BAR LIMIT ; - Why does this code work on single data stream but not multiple data stream?

It seems that I have to change it to - BUY NEXT BAR MARKET?

Is there a solution around this?
NEXT BAR OPEN

has the same effect as

NEXT BAR MARKET

"NEXT BAR OPEN" is not a good logic; it is accepted because it is an EasyLanguage legacy.


However you code is not a simple "NEXT BAR OPEN".
You have added calculations based on a number that has not happened yet.

If you want the OPEN value in your calculation,
you have to WAIT until that number has appeared before doing the calculation.

Adrian Uncle
Posts: 66
Joined: 26 Nov 2015
Has thanked: 7 times
Been thanked: 3 times

Re: NEXT BAR OPEN at NEXT BAR LIMIT with Multiple Data Strea

Postby Adrian Uncle » 06 May 2016

TJ,

If you want the OPEN value in your calculation,
you have to WAIT until that number has appeared before doing the calculation.
TJ,

Can you provide me a sample code to deal with the wait?

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

Re: NEXT BAR OPEN at NEXT BAR LIMIT with Multiple Data Strea

Postby TJ » 06 May 2016

TJ,

If you want the OPEN value in your calculation,
you have to WAIT until that number has appeared before doing the calculation.
TJ,

Can you provide me a sample code to deal with the wait?

There is only one way to do it --

If you want to incorporate the OPEN value in your calculation,
You have to start your logic calculation AFTER the OPEN.


Return to “MultiCharts”