Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

The BarsArray [1], do not work when CalculateOnBarClose = false;

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

    The BarsArray [1], do not work when CalculateOnBarClose = false;

    Hello everyone:
    This is my first post to the forum.
    I am developing a strategy for candles LineBreak when CalculateOnBarClose = true; does well, I attached example:

    protected override void Initialize ()
    {
    AddLineBreak ("6E 09-14" PeriodType.Tick, 150, 5, MarketDataType.Last);
    ....
    CalculateOnBarClose = true;
    }
    ....
    if (CurrentBars [0] <= BarsRequired || CurrentBars [1] <= BarsRequired)
    return;
    if (BarsInProgress ==0 )
    ....
    * if (== Position.MarketPosition MarketPosition.Flat)
    {
    if (.....
    && Close [1] <BollingerMedioAriel ((BarsArray [1]), 2, PerBollSal) .InfAriel [0])
    {
    EnterLong ("1LA");
    }
    But CalculateOnBarClose = false; does not work, does not enter
    The BarsArray [1], do not work When CalculateOnBarClose = false;

    protected override void Initialize ()
    {
    AddLineBreak ("6E 09-14" PeriodType.Tick, 150, 5, MarketDataType.Last);
    ....
    CalculateOnBarClose = false;
    }
    ....
    if (CurrentBars [0] <= BarsRequired || CurrentBars [1] <= BarsRequired)
    return;
    if (BarsInProgress ==0 )
    ....
    if (== Position.MarketPosition MarketPosition.Flat)
    {
    if (.....
    && Close [1] <BollingerMedioAriel ((BarsArray [1]), 2, PerBollSal) .InfAriel [1])
    {
    EnterLongLimit (Close [1], "1LA");
    }
    Sorry for my English.
    * Thank you
    Last edited by MarianoMA; 08-22-2014, 10:58 AM.

    #2
    Hi MarianoMA,

    Thanks for your post.

    "But CalculateOnBarClose = false; does not work, does not enter
    The BarsArray [1], do not work When CalculateOnBarClose = false; "

    This is the issue correct?

    Does Print(BollingerMedioAriel((BarsArray [1]), 2, PerBollSal).InfAriel[0]); print anything to the output window?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks, now I look

      Comment


        #4
        Do not write anything, in the Output window

        Comment


          #5
          I tried to enter with Simulated Data Feed does not enter when CalculateOnBarClose = false; and entry is limited EnterLongLimit or EnterLongStopLimit,
          just go, when CalculateOnBarClose = true; and market entry EnterLong () then conditions BarsArray [1] is fulfilled perfect met.

          Comment


            #6
            Now type in the Output window the actual values ​​of
            Print (BollingerMedioAriel ((BarsArray [1]), 2, PerBollSal) .InfAriel [0]);

            Comment


              #7
              Hello,

              Thank you for your reply.

              Are you getting any errors when compiling or in the Log tab of the Control Center?

              This should print something even if it is not the correct value.

              Try the following print:
              Print(Time[0]+" - "+BollingerMedioAriel((BarsArray [1]), 2, PerBollSal).InfAriel[0]);

              This will at least print the time.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                * Thank you
                The strategy compiles fine, no syntax errors.
                This printed in the Output window:
                22/08/2014 21:00:03-1,32169168064881
                22/08/2014 21:00:04-1,32169168064881
                22/08/2014 21:00:05-1,32169168064881
                22/08/2014 21:00:05-1,32169168064881

                ..........
                many lines
                .........


                22/08/2014 21:00:40-1,32170009103809
                22/08/2014 21:00:40-1,32170009103809
                22/08/2014 21:00:41-1,32170009103809

                Comment


                  #9
                  Hi MarianoMA,

                  Thats great.

                  This output shows that the indicator is calculating using he secondary data series.

                  Are you wanting to call this indicator while the primary data series is processing?

                  If so, you may want to make sure that the code will only processes for BarsInProgress 0.

                  For example:

                  if (BarsInProgress != 0)
                  return;
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Thank you,
                    I also tested this recommendation and does not fit, the error will be limited entry?
                    EnterLongLimit(Close[1],"1LA");

                    Comment


                      #11
                      Hello MarianoMA,

                      EnterLongLimit will place a limit order at the specified price.

                      http://www.ninjatrader.com/support/h...rlonglimit.htm

                      I'm not quite sure what you mean by 'does not fit'. Can you clarify this for me?
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Thank you,
                        I changed the entry to:
                        EnterLongLimit (GetCurrentBid (), "1LA");
                        All things being equal,
                        After resetting paints, in the real chart does not enter.
                        Attached Files
                        Last edited by MarianoMA; 08-22-2014, 04:28 PM.

                        Comment


                          #13
                          MarianoMA, one thing you would need to keep in mind is that GetCurrentBid() would be replaced by the Close bar value in backtesting, so likely has a different value compared to realtime, this is turn will influence if the order could be filled or not. To see if it expired just to early to reach a potential fill I would highly suggest running with the TraceOrders enabled for more detailed analysis.

                          Comment


                            #14
                            Thank you for your reply.
                            Now I try again, thanks for your recommendation.

                            Comment


                              #15
                              Hi,
                              I put it on simulated data feed
                              I write these results
                              25/08/2014 14:21:55-1,32228036118234
                              25/08/2014 14:21:56 Entered internal PlaceOrder() method at 25/08/2014 14:21:56: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=1 LimitPrice=1,3226 StopPrice=0 SignalName='11C' FromEntrySignal=''
                              25/08/2014 14:21:56 Cancelled expired order: BarsInProgress=1: Order='73eca64be2ed4c708b257f4e5da354a7/Sim101' Name='11C' State=PendingSubmit Instrument='6E 09-14' Action=SellShort Limit price=1,3226 Stop price=0 Quantity=1 Strategy='AAgLimCl1LB5salLimGetLB3Time' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='73eca64be2ed4c708b257f4e5da354a7' Gtd='01/12/2099 0:00:00'
                              25/08/2014 14:21:56-1,32228036118234
                              25/08/2014 14:21:56 Entered internal PlaceOrder() method at 25/08/2014 14:21:56: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=1 LimitPrice=1,3226 StopPrice=0 SignalName='11C' FromEntrySignal=''
                              25/08/2014 14:21:56 Ignored PlaceOrder() method at 25/08/2014 14:21:56: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=1,3226 StopPrice=0 SignalName='11C' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'

                              how to fix ,
                              Thank you.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              648 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              369 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              572 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              573 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X