Cannot generate intra-bar order  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
joenetic
Posts: 21
Joined: 13 Jun 2013

Cannot generate intra-bar order

Postby joenetic » 07 Apr 2016

I am using IB as data source and broker, I am using MultiChars.Net and C# to debug my code, I want to try intr-bar order, I found the intra-bar order code has been executed in C# debug mode, but there has no order generated in IB, anyone know why?

I have enable the intar-bar order generation in Signal's format properties.

Here is my test code:

Code: Select all

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

namespace PowerLanguage.Strategy {
public class RealTimeTest : SignalObject {
public RealTimeTest(object _ctx):base(_ctx){}

private int order_status, count1, count2;

private IOrderMarket buy_order;
private IOrderMarket close_long_order;

protected override void Create() {
// create variable objects, function objects, order objects etc.
buy_order = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default, EOrderAction.Buy));
close_long_order = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default, EOrderAction.SellShort));
}
protected override void StartCalc() {
// assign inputs
order_status = 0;
count1 = 0;
count2 = 0;
}
protected override void CalcBar(){
// strategy logic
if (order_status == 1)
{

//close_long_order.Send();
buy_order.Send(); // this order always no respond in IB

order_status = 0;

}

if (Bars.Status == EBarState.Close)
{



//buy_order.Send();

close_long_order.Send(); //this order can be generated in IB
order_status = 1;

}



}
}
}

joenetic
Posts: 21
Joined: 13 Jun 2013

Re: Cannot generate intra-bar order

Postby joenetic » 07 Apr 2016

Anyone know why I cannot generate intra-bar order?

Can MultiCharts answer this question? Thank you!

User avatar
ABC
Posts: 626
Joined: 16 Dec 2006
Has thanked: 119 times
Been thanked: 355 times
Contact:

Re: Cannot generate intra-bar order  [SOLVED]

Postby ABC » 08 Apr 2016

joenetic,

according to this link " MarketThisBar command cannot be used in IntraBar Order Generation and BarMagnified modes. The orders will be sent on the bar close only.".

This is likely what is causing the problems for you. You should use MarketNextBar instead.

Regards,
ABC

joenetic
Posts: 21
Joined: 13 Jun 2013

Re: Cannot generate intra-bar order

Postby joenetic » 08 Apr 2016

Thank you ABC!! After changed to MarketNextBar,intra-bar order generation is OK now, thanks again!


Return to “MultiCharts .NET”