PDA

View Full Version : incorrect 'BarsInProgress' context


richa61416
08-07-2007, 04:34 PM
protectedoverridevoid Initialize()
{
SetProfitTarget("MACDLONG", CalculationMode.Ticks, 120);
SetProfitTarget("MACDSHORT", CalculationMode.Ticks, 120);
SetStopLoss("MACDLONG", CalculationMode.Ticks, 17, false);
SetStopLoss("MACDSHORT", CalculationMode.Ticks, 17, false);
//SetProfitTarget(Mprofit);
//SetStopLoss(MLoss, false);
Add(PeriodType.Minute,8);
CalculateOnBarClose = false;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{ // Long 10 Minutes


if (BarsInProgress == 0)
{
EnterLong();
}
if (BarsInProgress ==1 )
{
EnterShort();
}

return;




Why am I getting the following: Order for strategy 'MacdComplete_1_4PM' was placed in incorrect 'BarsInProgress' context. Order ignored.


I am trying to combine 2 strategies into 1. How can I Sell Short on the second time period? It does really tell me how in the example.

NinjaTrader_Ray
08-08-2007, 02:13 AM
At this time you can ONLY place orders when BarsInProgress == 0. By fall time frame you will be able to place orders on additional time frames as you have currently coded.

Learning1
09-17-2007, 12:26 PM
Is there a fall Beta release available for download? If not what is the rough planned timing of this release?

NinjaTrader_Ray
09-17-2007, 12:35 PM
No official release date however it is close. We have a few people running some alpha testing and doing final documentation.

Learning1
09-17-2007, 12:40 PM
Thanks Ray. I have been trying to sort out mysterious Cancelled Orders when BarsInProgress == 0 on a Multi-Timeframe Strategy and failure to enter orders when BarsInProgress == 2. I understood order entry when BarsInProgress == 1 would be possible in the next version (Which might fix my issue). I will be patient and perhaps clearly document the challenge I am having in a different post. Thanks for the update.

ceesvh
09-18-2007, 11:34 AM
Learning1

Do you use different timeframes of the same instrument?
When you do that you might use the following idea.
In this case the longer timeframe should be a multiple of the smallest timeframe.

Suppose you have a 1 min and a 5 min timeframe.
Make the 1 min bar timeframe 0
Suppose you want to enter on signals of a 5 min bar

Then you can count the bars and act on signals of the 5 min bar
suppose you want to go long when the close crossesabove the sma
When the barcount = 5 you have to reset the barcount to 0.
I made a simple script based on this principle and it works fine



if(BarsInProgress==0)
{
Barcount=Barcount+1;

if(Barcount==5
&& CrossAbove(Closes[1][0], HMA(BarsArray[1],5), 1)
&& Long==false)
{
EnterLong(1,"Test");
Long=true;