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

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.

                          BertrandNinjaTrader Customer Service

                          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 ninza33, Today, 12:31 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post ninza33
                              by ninza33
                               
                              Started by Bobin, 03-12-2024, 08:51 AM
                              15 responses
                              480 views
                              0 likes
                              Last Post fiddich
                              by fiddich
                               
                              Started by Skifree, Today, 11:21 AM
                              4 responses
                              13 views
                              0 likes
                              Last Post Skifree
                              by Skifree
                               
                              Started by Bogdan097, Today, 03:25 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post Bogdan097  
                              Started by cmtjoancolmenero, 04-25-2024, 03:58 PM
                              25 responses
                              127 views
                              0 likes
                              Last Post cmtjoancolmenero  
                              Working...
                              X