type of orders

Questions about MultiCharts .NET and user contributed studies.
tesiag
Posts: 6
Joined: 11 Jan 2014
Has thanked: 1 time

type of orders

Postby tesiag » 11 Jan 2014

Hi,
how can I emulate in backtesting the following real-time operativity?

when the price in the current bar gets higher of the previous bar High I would open a long position at the previous bar's High price.

Unfortunately almost all types of orders in MC seem to open positions at the next bar; one only type allows opening position at the current bar, but it only opens position at the Close price.

Any suggestions?
Thank you
Andrea

P.S.: Hope I've been clear enough with my question. In case ask me for clarifications

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

Re: type of orders

Postby JoshM » 12 Jan 2014

(....)
when the price in the current bar gets higher of the previous bar High I would open a long position at the previous bar's High price.

Unfortunately almost all types of orders in MC seem to open positions at the next bar; one only type allows opening position at the current bar, but it only opens position at the Close price.

Any suggestions?
(...)
Buy stop limit? (page 38 of the programming manual).

So, something like this (untested):

Code: Select all

public class MyBuyStop : SignalObject
{
private IOrderStopLimit buyStopOrder;

protected override void Create()
{
buyStopOrder = OrderCreator.StopLimit(new SOrderParameters(
Contracts.Default, "BuyStopLMT", EOrderAction.Buy));
}

protected override void CalcBar()
{
if (myCondition == true)
{
// Send buy order one tick above previous bar high
buyStopOrder.Send(
Bars.High[1] + (Bars.Info.MinMove / Bars.Info.PriceScale), // Stop price
Bars.High[1]); // Limit price
}
}
}

tesiag
Posts: 6
Joined: 11 Jan 2014
Has thanked: 1 time

Re: type of orders

Postby tesiag » 12 Jan 2014

thank you very much Josh for your reply.

the logic of algorithm is ok and works with the different types of order.

The problem I was mentioning is the need by Multicharts to wait for the opening of the next bar while I want my order to be executed immediately at the current bar (just when the market price reaches the stop and limit price).

If the next bar does not crosses my stop/limit price my order would not be executed in backtesting (while in real operativity it would likely be).

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

Re: type of orders

Postby JoshM » 13 Jan 2014

The problem I was mentioning is the need by Multicharts to wait for the opening of the next bar while I want my order to be executed immediately at the current bar (just when the market price reaches the stop and limit price).
You can use intra-bar order generation (IOG) for that, if I understand you correctly. With IOG MultiCharts will not wait till the next bar.

Also see this wiki page.

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

Re: type of orders

Postby Henry MultiСharts » 13 Jan 2014

Hello Andrea,

You need to use Bar Magnifier in order for "next bar" order commands to be executed intra bar in backtesting. For more information please check Bar Magnifier, How signals are calculated.

tesiag
Posts: 6
Joined: 11 Jan 2014
Has thanked: 1 time

Re: type of orders

Postby tesiag » 13 Jan 2014

thanks Josh and Henry.
It works now.

It didn't work if I only used the setting as shown in the attached picture (the "backtesting" tab in the "Strategy Properties" window).

Then I discovered another setting window for intra-bar order generation enabling in the "Properties" tab of the "Format Signal" window). Once set IOG enabling in this panel, the backtest worked as expected!!

I've read IOG and intra-bar in the manual as well as in the wiki pages. I've got some confusion yet about the differences among all possible settings in intra-bar and bar-magnifier as compared with "next bar orders" or "current bar orders" etc. etc.

Maybe I need to read again all sections related to these features, but also some further explanation with practical examples could be really helpful for the novice.


In any case, many thanks again for your help!!
Attachments
settings.jpg
(61.55 KiB) Downloaded 570 times

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

Re: type of orders

Postby Henry MultiСharts » 14 Jan 2014

I've read IOG and intra-bar in the manual as well as in the wiki pages. I've got some confusion yet about the differences among all possible settings in intra-bar and bar-magnifier as compared with "next bar orders" or "current bar orders" etc. etc.
Andrea,

The signal calculation modes are described in the following article: How signals are calculated.

As for the orders: when IOG is On - next bar order is generated on the current tick and sent on the next tick.
When is IOG Off - next bar order is generated on the close of the current bar and sent on the opening tick of the next bar.

This Bar on Close order is sent on the close of the signal generation bar (disregard IOG settings). Only market orders can be sent This bar.


Return to “MultiCharts .NET”