How do I use OrderCreator.MarketThisBar?  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
maisatomai
Posts: 83
Joined: 18 Mar 2013
Has thanked: 11 times

How do I use OrderCreator.MarketThisBar?

Postby maisatomai » 25 Apr 2013

If I change the below code OrderCreator.MarketNextBar, it will work all right. But if it is using OrderCreator.MarketThisBar, it did not create any position. The code is to buy on last day of the month.

Code: Select all

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;
using System.Windows.Forms;

namespace PowerLanguage.Strategy {
[CalcAtOpenNextBar(true)]
public class fung_buyusingquarterlystockreport : SignalObject {
public fung_buyusingquarterlystockreport(object _ctx):base(_ctx){}
private IOrderMarket le_order;

protected override void Create() {
// create variable objects, function objects, order objects etc.
le_order = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default,EOrderAction.Buy));
}
protected override void StartCalc() {
// assign inputs

}
protected override void CalcBar(){
// strategy logic
GenerateExitOnClose();
DateTime i=Bars.Time[-1];
if (i.Month!=Bars.Time[0].Month)
le_order.Send();
}
}
}

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

Re: How do I use OrderCreator.MarketThisBar?

Postby Henry MultiСharts » 26 Apr 2013

Hello maisatomai,

OrderCreator.MarketThisBar is not supported if [CalcAtOpenNextBar(true)]. You can use MarketNextBar order in this mode.

maisatomai
Posts: 83
Joined: 18 Mar 2013
Has thanked: 11 times

Re: How do I use OrderCreator.MarketThisBar?

Postby maisatomai » 28 Apr 2013

Hello maisatomai,

OrderCreator.MarketThisBar is not supported if [CalcAtOpenNextBar(true)]. You can use CalcAtOpenNextBar in this mode.
Thanks Henry.

Is this a typo? "You can use CalcAtOpenNextBar in this mode". Do you mean to say "You can't use CalcAtOpenNextBar in this mode"

How do I get around this problem? I want to look at the next bar and if next bar is equal to 1/1/13 (for example), I will buy at this bar (which is 31/12/12).

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

Re: How do I use OrderCreator.MarketThisBar?  [SOLVED]

Postby Henry MultiСharts » 29 Apr 2013

Hello maisatomai,

Sorry for the typo. You can use MarketNextBar order if you are in CalcAtOpenNextBar mode.
How do I get around this problem? I want to look at the next bar and if next bar is equal to 1/1/13 (for example), I will buy at this bar (which is 31/12/12).
MarketThisBar order works only in regular calculation mode (upon bar close).

maisatomai
Posts: 83
Joined: 18 Mar 2013
Has thanked: 11 times

Re: How do I use OrderCreator.MarketThisBar?

Postby maisatomai » 30 Apr 2013

Hello maisatomai,

Sorry for the typo. You can use MarketNextBar order if you are in CalcAtOpenNextBar mode.
How do I get around this problem? I want to look at the next bar and if next bar is equal to 1/1/13 (for example), I will buy at this bar (which is 31/12/12).
MarketThisBar order works only in regular calculation mode (upon bar close).
Is it a typo again? "You can use MarketNextBar order if you are in CalcAtOpenNextBar mode"?

I now very confused.

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

Re: How do I use OrderCreator.MarketThisBar?

Postby Henry MultiСharts » 30 Apr 2013

Is it a typo again? "You can use MarketNextBar order if you are in CalcAtOpenNextBar mode"?

I now very confused.
No, there is no typo.
There are two signal calculation modes in MultiCharts: on bar close and on bar open.
On bar close calc mode you can send both MarketThisBar and MarketNextBar orders.
On bar open calc mode you can send only MarketNextBar order.


Return to “MultiCharts .NET”