Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

incorrect 'BarsInProgress' context

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    incorrect 'BarsInProgress' context

    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.
    Last edited by richa61416; 08-07-2007, 05:01 PM.

    #2
    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.
    RayNinjaTrader Customer Service

    Comment


      #3
      Beta Release?

      Is there a fall Beta release available for download? If not what is the rough planned timing of this release?

      Comment


        #4
        No official release date however it is close. We have a few people running some alpha testing and doing final documentation.
        RayNinjaTrader Customer Service

        Comment


          #5
          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.

          Comment


            #6
            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;

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by thanajo, 05-04-2021, 02:11 AM
            4 responses
            470 views
            0 likes
            Last Post tradingnasdaqprueba  
            Started by aa731, Today, 02:54 AM
            0 responses
            4 views
            0 likes
            Last Post aa731
            by aa731
             
            Started by Christopher_R, Today, 12:29 AM
            0 responses
            10 views
            0 likes
            Last Post Christopher_R  
            Started by sidlercom80, 10-28-2023, 08:49 AM
            166 responses
            2,237 views
            0 likes
            Last Post sidlercom80  
            Started by thread, Yesterday, 11:58 PM
            0 responses
            6 views
            0 likes
            Last Post thread
            by thread
             
            Working...
            X