IOGMode vs MarketNextBar

Questions about MultiCharts .NET and user contributed studies.
lewisthegood
Posts: 21
Joined: 08 Mar 2021
Been thanked: 1 time

IOGMode vs MarketNextBar

Postby lewisthegood » 07 Apr 2021

I have IOGMode enable and using MarketNextBar to create long and short order as shown below. However, when I applied it to the chart, an error messgae is pop-ip "The Enabled Intra-bar Order Generation setting is incompatible with Open Next Bar type strategies."

From my understanding, there is no Open Next Bar type strategies below, please advise why there is an error message pop-up!

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

namespace PowerLanguage.Strategy {
[SameAsSymbol(true)]
[CalcAtOpenNextBarAttribute(true)]
[IOGMode(IOGMode.Enabled)]
public class HSI_Usignal : SignalObject {
public HSI_Usignal(object _ctx):base(_ctx){length = 9;}

private IOrderMarket buy_order,sell_order;

private ISeries<Double> m_price;

private LinearRegValue m_linearregvalue1;

private VariableSeries<Double> m_linreg;

int orderSize = 1;

private ISeries<Double> price{
get { return m_price; }
}

[Input]
public int length { get; set; }

protected override void Create() {
buy_order = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "buy", EOrderAction.Buy));
sell_order = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "Exit", EOrderAction.Sell,OrderExit.FromAll));

m_linearregvalue1 = new LinearRegValue(this);
m_linreg = new VariableSeries<Double>(this);
}

protected override void StartCalc() {
m_price = Bars.Close;
m_linearregvalue1.price = price;
m_linearregvalue1.length = length;
m_linearregvalue1.tgtbar = 0;
}

protected override void CalcBar(){
// strategy logic

m_linreg.Value = m_linearregvalue1[0];

if ((PublicFunctions.DoubleGreater(price[0], m_linreg.Value) &&
PublicFunctions.DoubleGreater(m_linreg.Value, m_linreg[1]))&&
PublicFunctions.DoubleLessEquals(m_linreg[1], m_linreg[2]) &&
(StrategyInfo.MarketPosition == 0) &&
(Bars.Status == EBarState.Close)){
//Alerts.Alert("Indicator turning up");
buy_order.Send();
}


else{
if ((PublicFunctions.DoubleLess(price[0], m_linreg.Value) &&
PublicFunctions.DoubleLess(m_linreg.Value, m_linreg[1]))&&
PublicFunctions.DoubleGreaterEquals(m_linreg[1], m_linreg[2]) &&
(StrategyInfo.MarketPosition > 0) &&
(Bars.Status == EBarState.Close)){

sell_order.Send();

}

}

}
}
}

User avatar
Tammy MultiCharts
Posts: 200
Joined: 06 Aug 2020
Has thanked: 6 times
Been thanked: 65 times

Re: IOGMode vs MarketNextBar

Postby Tammy MultiCharts » 08 Apr 2021

Hello lewisthegood,

We have reviewed your code and found out that you are using [CalcAtOpenNextBarAttribute(true)].
This attribute enables Open Next Bar mode, and is not compatible with Intra-Bar Order Generation.
To have your signal work do not use [CalcAtOpenNextBarAttribute(true)] or disable IOG.

lewisthegood
Posts: 21
Joined: 08 Mar 2021
Been thanked: 1 time

Re: IOGMode vs MarketNextBar

Postby lewisthegood » 11 Apr 2021

im sure im not using [CalcAtOpenNextBarAttribute(true)], and the error message still pop-up

User avatar
Tammy MultiCharts
Posts: 200
Joined: 06 Aug 2020
Has thanked: 6 times
Been thanked: 65 times

Re: IOGMode vs MarketNextBar

Postby Tammy MultiCharts » 13 Apr 2021

Hi lewisthegood,

Our development team has reviewed the script you shared via email.

The error "The Enabled Intra-bar Order Generation setting is incompatible with Open Next Bar type strategies" keeps popping up because MultiCharts remembered the (true) value set for CalcAtOpenNextBarAttribute during the latest compilation.

Please try to uncomment [CalcAtOpenNextBarAttribute(true)] > set it to False > compile the code > comment [CalcAtOpenNextBarAttribute(false)] out once again. The error should not appear after that.


Return to “MultiCharts .NET”