Next bar at ...

Questions about MultiCharts and user contributed studies.
DJhighway
Posts: 3
Joined: 10 Mar 2015

Next bar at ...

Postby DJhighway » 10 Mar 2015

I am having a problem with trade Prices and Dates using Daily bars, the solution for which is probably very simple but which I am not understanding correctly.

The following code is meant to trade the next Daily bar on the Close but is instead sometimes trading at the Open of the following day and sometimes at the Close. In both cases the Trade Date is reported as being the day before the price actually occurred as an Open or Close; so the backtest shows an incorrect date for the trade and is trading at a different point than intended. This occurs for buys and sells though the code below is for a sell:

Code: Select all

if Condition1 then sell short next bar at close limit
What am I missing? Thanks in advance.

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

Re: Next bar at ...

Postby TJ » 10 Mar 2015

I am having a problem with trade Prices and Dates using Daily bars, the solution for which is probably very simple but which I am not understanding correctly.
The following code is meant to trade the next Daily bar on the Close but is instead sometimes trading at the Open of the following day and sometimes at the Close. In both cases the Trade Date is reported as being the day before the price actually occurred as an Open or Close; so the backtest shows an incorrect date for the trade and is trading at a different point than intended. This occurs for buys and sells though the code below is for a sell:

Code: Select all

if Condition1 then sell short next bar at close limit
What am I missing? Thanks in advance.
"close" is a price value, NOT the event.

Your code is telling MultiCharts to sellshort next bar at THIS bar's close price.

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

Re: Next bar at ...

Postby TJ » 10 Mar 2015

ps. You cannot do any trade at the "Close event".

When the "close event" arrives, the trading stops.

You have to submit the order ahead of time; you have to decide the price, and how much time you are giving yourself.

EasyLanguage has no provision for MOC order.

DJhighway
Posts: 3
Joined: 10 Mar 2015

Re: Next bar at ...

Postby DJhighway » 10 Mar 2015

Thank you for your explanation. Why does my code result in trade dates that are incorrect? Am I also not getting filled on some trades if the next bar never sees the Close price of the previous bar?

How do I tell MultiCharts to trade the Close of the following Daily bar? Or if I actually do want to trade the Open of the following daily bar how do I do that? At this stage of what I'm doing I simply want to assume a fill at the Close (and perhaps the Open in some cases) regardless of the order type supported.

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

Re: Next bar at ...

Postby TJ » 10 Mar 2015

::
How do I tell MultiCharts to trade the Close of the following Daily bar?
::
see my post above.

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

Re: Next bar at ...

Postby TJ » 10 Mar 2015

Thank you for your explanation. Why does my code result in trade dates that are incorrect? Am I also not getting filled on some trades if the next bar never sees the Close price of the previous bar?

How do I tell MultiCharts to trade the Close of the following Daily bar? Or if I actually do want to trade the Open of the following daily bar how do I do that? At this stage of what I'm doing I simply want to assume a fill at the Close (and perhaps the Open in some cases) regardless of the order type supported.
You can start here:
[FAQ] EasyLanguage / PowerLanguage
viewtopic.php?f=16&t=6929

[FAQ] Autotrade / Backtest / Optimization
viewtopic.php?f=16&t=10811



Don't rush... take time to study the ebooks in detail.

DJhighway
Posts: 3
Joined: 10 Mar 2015

Re: Next bar at ...

Postby DJhighway » 10 Mar 2015

With the following code I am able to get backtest results at the Close of a daily bar:

Code: Select all

then buy this bar on close
yet when I try to do effectively the same thing with the "next bar" it doesn't work. MOC order types don't seem relevant here as I'm not sending an order to a broker, but just testing a hypothesis only.

I'm also still trying to understand why any of this results in a trade date different from the date on which the price occurred; and why sometimes I get the Open price and sometimes the Close.

Thanks again in advance.

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

Re: Next bar at ...

Postby TJ » 10 Mar 2015

With the following code I am able to get backtest results at the Close of a daily bar:

Code: Select all

then buy this bar on close
yet when I try to do effectively the same thing with the "next bar" it doesn't work. MOC order types don't seem relevant here as I'm not sending an order to a broker, but just testing a hypothesis only.
I'm also still trying to understand why any of this results in a trade date different from the date on which the price occurred; and why sometimes I get the Open price and sometimes the Close.
Thanks again in advance.
Don't rush... take time to study.


See post #7
viewtopic.php?f=16&t=10811


Return to “MultiCharts”