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

    #31
    Hello MarianoMA,

    Thank you for your response.

    When backtesting the strategy what period type and interval are you selecting in the Strategy Analyzer?

    Comment


      #32
      thank you very much Patrick H.

      All results of the photos were in Simulated Data Feed, for LineBreakWicked, base period value 75 tick, line breaks 3
      Last edited by MarianoMA; 09-17-2014, 03:10 PM.

      Comment


        #33
        Hello MarianoMA,

        Thank you for your response.

        Have you backtested the strategy in the Strategy Analyzer? Do you see the same item in the Strategy Analyzer?

        Comment


          #34
          thank you very much Patrick H.

          yes, the same error

          Comment


            #35
            Thank you Patrick H.

            At least twice not satisfy exit conditions theoretically.

            Look at the actual volume candlestick charts this afternoon, and backtesting
            Attached Files

            Comment


              #36
              Patrick H. thank you very much for your patience with my case.

              In short, you should run a BarsArray [2] exit? having
              Initialize ()
              {
              Add // .... BarsInProgress index = 1
              Add (...);
              Add // .... BarsInProgress index = 2
              Add (...);
              etc.
              }
              OnBarUpdate ()
              {
              if (BarsInProgress! = 0)
              return;
              .........
              .........
              if (== Position.MarketPosition MarketPosition.Long)
              {
              // Unique exit condition
              if (..... (BarsArray [2], ... <...))
              {
              ExitLong ("", "");
              }
              .....

              Comment


                #37
                Hello MarianoMA,

                Thank you for your response.

                I would not set the exit conditions under else if, try just using if:
                Code:
                            // Condition set 3
                            if (Position.MarketPosition == MarketPosition.Long
                                       && WMA(BarsArray[2],PerWMA)[0] < WMA(BarsArray[2],PerWMA)[1])
                                          {
                                           ExitLong("", "");
                                          }
                
                            // Condition set 4
                            if (Position.MarketPosition == MarketPosition.Short
                                        && WMA(BarsArray[2],PerWMA)[0] > WMA(BarsArray[2],PerWMA)[1])
                                          {
                                           ExitShort("", "");
                                          }

                Comment


                  #38
                  Thank you very much,

                  I solved the issue for "normal" candles, but for LineBreak candles not resolved.
                  Even without changes, practically copy / paste

                  I attached a file with the changes.
                  Attached Files

                  Comment


                    #39
                    Thank you very much,

                    This is what writes the output window

                    19/09/2014 16:24:08 Entered internal PlaceOrder() method at 19/09/2014 16:24:08: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='1CBW' FromEntrySignal=''
                    19/09/2014 16:29:54 Entered internal SetStopTarget() method: Type=Target FromEntrySignal='' Mode=Ticks Value=11 Currency=0 Simulated=False
                    19/09/2014 16:29:54 Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=11 Currency=0 Simulated=False
                    19/09/2014 16:29:54 Entered internal SetStopTarget() method: Type=Target FromEntrySignal='' Mode=Ticks Value=11 Currency=0 Simulated=False
                    19/09/2014 16:29:54 Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=11 Currency=0 Simulated=False
                    19/09/2014 16:29:54 Entered internal SetStopTarget() method: Type=Target FromEntrySignal='' Mode=Ticks Value=11 Currency=0 Simulated=False
                    19/09/2014 16:29:54 Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=11 Currency=0 Simulated=False
                    AlertLevel: 40
                    AlertLevel: 40
                    AlertLevel: 40
                    AlertLevel: 40
                    AlertLevel: 40
                    AlertLevel: 40
                    AlertLevel: 40
                    19/09/2014 16:29:56 Entered internal SetStopTarget() method: Type=Target FromEntrySignal='Long 1a' Mode=Ticks Value=4 Currency=0 Simulated=False
                    19/09/2014 16:29:56 Entered internal SetStopTarget() method: Type=Target FromEntrySignal='Long 1b' Mode=Ticks Value=8 Currency=0 Simulated=False
                    19/09/2014 16:29:56 Entered internal SetStopTarget() method: Type=Target FromEntrySignal='Short 1a' Mode=Ticks Value=4 Currency=0 Simulated=False
                    19/09/2014 16:29:56 Entered internal SetStopTarget() method: Type=Target FromEntrySignal='Short 1b' Mode=Ticks Value=8 Currency=0 Simulated=False
                    19/09/2014 16:30:01 CancelAllOrders: BarsInProgress=0
                    19/09/2014 16:30:01 CancelAllOrders: BarsInProgress=1
                    19/09/2014 16:30:01 CancelAllOrders: BarsInProgress=2
                    **NT** Disabling NinjaScript strategy 'AAbarsArrayLB3salVol/cfca761918784532ba2510511cff6355'

                    Comment


                      #40
                      Hello MarionMA,

                      Thank you for your response.

                      Please provide a screenshot of the LineBreak after implementing the if conditions rather than else if.

                      Comment


                        #41
                        Hello, Thank you Patrick H.

                        Graphic Attachment to LineBreak

                        Still does not satisfy the exit conditions
                        Attached Files

                        Comment


                          #42
                          Hello MarianoMA,

                          Thank you for your response.

                          What are the timestamps of the bars in between the entry and exit on the LineBreak chart?

                          In addition, I would recommend always setting the BarsArray[int barsInProgress] inside each of the indicators you call. For example: RSI(BarsArray[2], 14, 3)

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by WHICKED, Today, 12:56 PM
                          0 responses
                          4 views
                          0 likes
                          Last Post WHICKED
                          by WHICKED
                           
                          Started by Spiderbird, Today, 12:15 PM
                          2 responses
                          10 views
                          0 likes
                          Last Post Spiderbird  
                          Started by WHICKED, Today, 12:45 PM
                          0 responses
                          7 views
                          0 likes
                          Last Post WHICKED
                          by WHICKED
                           
                          Started by FrazMann, Today, 11:21 AM
                          2 responses
                          6 views
                          0 likes
                          Last Post NinjaTrader_ChristopherJ  
                          Started by rjbtrade1, 11-30-2023, 04:38 PM
                          2 responses
                          80 views
                          0 likes
                          Last Post DavidHP
                          by DavidHP
                           
                          Working...
                          X