I am attempting to test a strategy that uses the indicators based on the daily bars, and then place trades on a 15 minute chart at 9:30am.
I have set up the primary chart as the 15 minute chart and the secondary chart as the daily chart. I am able to generate the signals from the daily data without any issues. If a signal is generated on the data from the daily bar, I want to place the trade if the intraday bar is 9:30am.
The problem is how can I check to see if the time of this bar is 9:30, and if so then place the trade? I attempted to do timeNextBar(), to see if the next bar is 9:30, and if so, place a market order for the next bar, but as I understand it, I also need to have [CalcAtOpenNextBarAttribute(true)] defined for my strategy, however when i do this I get an error saying:
Open next bar type strategies calculation is not permitted on multiple DataStreams.
Is there another way to try to accomplish what I would like to do here?
Open next bar type strategies calculation is not permitted [SOLVED]
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Open next bar type strategies calculation is not permitt
Another approach would be to use IOG (Intra-bar Order Generation). That way, the script can be evaluated intra-bar (as opposed to end-of-bar) and then orders can be triggered during the opening of the bar. That would also mean that `CalcAtOpenNextBarAttribute` is not needed anymore.
An rough example as a starting point:
An rough example as a starting point:
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;
using PowerLanguage.TradeManager;
namespace PowerLanguage.Strategy
{
[IOGMode(IOGMode.Enabled)]
public class Snippet_Strategy : SignalObject
{
public Snippet_Strategy(object _ctx) : base(_ctx) { }
private IOrderMarket enterLong;
protected override void Create()
{
enterLong = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.UserSpecified, EOrderAction.Buy));
}
protected override void CalcBar()
{
TimeSpan startTime = new TimeSpan(9, 30, 0);
if (Bars.Time[0].TimeOfDay >= startTime &&
Bars.Time[0].TimeOfDay < startTime.Add(new TimeSpan(0, 5, 0)))
{
// This code is executed in the first 5 minutes of the day
// (i.e., 9:30 - 9:35 a.m.
enterLong.Send(1);
}
}
}
}
Open Next Bar type strategies not permitted on multiple data
I am getting the following error with my trading strategy.
"Open Next Bar type strategies calculation is not permitted on multiple DataStreams"
A little background info.
I am attempting to use 2 instrument streams. The first is intraday data to place the trades, and the second data stream is EOD data that will be used to generate the actual signals.
I'm attempting to buy/short on the intraday data stream, if the bar's start time is 9:30 am EST. The obvious solution would be to check if the current bar is 9:29am, and buy the next bar. However for different commodities, there is not always a bar at 9:29am. So I modified my strategy to say if the NEXT bar is 9:30am, then submit a buy order. In order to do this I needed to annotate my strategy with:
[CalcAtOpenNextBarAttribute(true)]
The problem however, is that with the strategy using both the Intraday and EOD data, the error above is being thrown.
Is there another way to accomplish what I'm trying to do?
Thanks,
-Rob
"Open Next Bar type strategies calculation is not permitted on multiple DataStreams"
A little background info.
I am attempting to use 2 instrument streams. The first is intraday data to place the trades, and the second data stream is EOD data that will be used to generate the actual signals.
I'm attempting to buy/short on the intraday data stream, if the bar's start time is 9:30 am EST. The obvious solution would be to check if the current bar is 9:29am, and buy the next bar. However for different commodities, there is not always a bar at 9:29am. So I modified my strategy to say if the NEXT bar is 9:30am, then submit a buy order. In order to do this I needed to annotate my strategy with:
[CalcAtOpenNextBarAttribute(true)]
The problem however, is that with the strategy using both the Intraday and EOD data, the error above is being thrown.
Is there another way to accomplish what I'm trying to do?
Thanks,
-Rob
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Open next bar type strategies calculation is not permitt
Hello Rob,
[CalcAtOpenNextBarAttribute(true)] does not provide access to the future data. Please use the solution provided by JoshM in the post#2 above.
[CalcAtOpenNextBarAttribute(true)] does not provide access to the future data. Please use the solution provided by JoshM in the post#2 above.
Re: Open next bar type strategies calculation is not permitt
So I guess I spoke too soon on this. The IOG solution works if I am just using 1 chart in Multicharts, but if I want to run my backtest with multiple instruments in the portfolio tester, IOG is not supported. Is there another way of accomplishing this that is supported by the portfolio backtester?
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Open next bar type strategies calculation is not permitt [SOLVED]
Hello Rob,
You can use tick based resolutions in Portfolio Trader for accurate testing.
The most accurate testing is with 1 tick resolution.
You can use tick based resolutions in Portfolio Trader for accurate testing.
The most accurate testing is with 1 tick resolution.