Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Arrow For Trading

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

    Arrow For Trading

    I have an indicator, where I made an arrow where I want to buy... that functions fine.

    Can i call that from a strategy to trigger a buy?

    Example:
    DrawArrowUp("MyBuyArrow", true, 0, High[0] + TickSize, Color.Blue);

    So i want the strategy to look for MyBuyArrow and buy.

    #2
    Hello shawnkm,

    Thank you for writing in.

    You would either need to duplicate the logic to draw the arrow in your indicator to your strategy or utilize a public BoolSeries that the strategy can access to check if a condition was true in your indicator.

    More information about BoolSeries can be found in this help guide link: http://ninjatrader.com/support/helpG...ries_class.htm

    I have attached a simple example demonstrating this to my post.

    Please, let us know if we may be of further assistance.
    Attached Files
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Zachary,

      Thanks for the example... that makes since. Something is off though as I run your strategy and it is not trigger buys. I just edited your strategy to enter long:

      if (tf.TF[0])
      {
      Print("Strategy: " + CurrentBar);
      EnterLong(DefaultQuantity, "");
      }

      Its not generating buys for some reason?

      Thanks again for all of your help!
      Shawn

      Comment


        #4
        Hello Shawn,

        Can you please verify that the Print() is indeed printing out?

        Are there any messages in the Log tab of the Control Center?
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          The print for the indicator is working, the print for the strategy is not. There are no errors.

          Comment


            #6
            Hello Shawn,

            Please open a new chart, ensure that you are connected to live data (or the simulated data feed), and only enable the strategy I have provided as the indicator is called from it. Do not add the indicator to the chart.

            Does this behavior still occur?
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              I was testing on Market Replay. I did change over to simulated and it didnt give any buy signals in a 10 minute time frame (renko charts set to 1 brick). Now, there is nothing in the output window other than this:

              **NT** Disabling NinjaScript strategy 'TFStrat/9c40bcf6e3b744e8a0dec5b218e4b755'
              **NT** Enabling NinjaScript strategy 'TFStrat/9c40bcf6e3b744e8a0dec5b218e4b755' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True CalculateOnBarClose=True MaxRestarts=4 in 5 minutes
              Error on calling 'OnBarUpdate' method for indicator 'TFIndicator' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.


              So it still didnt give strategy prints, now it took away indicator prints. If that code will not work on market replay, what would be similar code for testing with market replay?

              Thanks again.

              Comment


                #8
                Hello shawnkm,

                It looks like this error is occurring because there isn't a CurrentBar check in the indicator.

                Before all of the indicator logic within the OnBarUpdate() method, please add this line of code:
                Code:
                if (CurrentBar < 1) return;
                More about why this error commonly occurs can be found here: http://ninjatrader.com/support/forum...ead.php?t=3170
                Zachary G.NinjaTrader Customer Service

                Comment


                  #9
                  Awesome... got it working... thanks a bunch!

                  Now what is an easy way to make the entry bar the same as the signal bar rather than a one bar delay?

                  I have already read and implemented:

                  You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


                  But that doesnt seem to work with renko bars using Market Replay.

                  Comment


                    #10
                    Hello shawnkm,

                    As you are running Market Replay, you would want to change the CalculateOnBarClose property in your strategy from true to false.

                    With this set to true, all calculations are done when a bar closes. However, with this set to false, calculations are done on every tick.

                    So, if a signal occurs intrabar, then the strategy will be able to act upon it immediately rather than at the close of a bar.

                    For more information about CalculateOnBarClose, please take a look at this help guide link: https://ninjatrader.com/support/help...onbarclose.htm
                    Zachary G.NinjaTrader Customer Service

                    Comment


                      #11
                      Before I tried to implement the multi data series, I already tried changing Calculate on Close but that does not stop the delay.

                      Any other suggestions?

                      Comment


                        #12
                        Hello Shawn,

                        Once you have made the change in code, please ensure that you have compiled the code and have removed it and re-added it to your chart. Any changes to the Initialize() method would warrant removing the strategy entirely and re-adding it.

                        Also, please note that setting this property to false will not be of any affect in historical bars. Can you please clarify if you are attempting to fill intrabar on live data or historical data?

                        If you wish to fill intrabar on historical data, you would need to utilize intrabar granularity and submit bars to the secondary, more granular, bar: http://ninjatrader.com/support/forum...ead.php?t=6652
                        Zachary G.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by cls71, Today, 04:45 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post cls71
                        by cls71
                         
                        Started by mjairg, 07-20-2023, 11:57 PM
                        3 responses
                        213 views
                        1 like
                        Last Post PaulMohn  
                        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                        4 responses
                        544 views
                        0 likes
                        Last Post PaulMohn  
                        Started by GLFX005, Today, 03:23 AM
                        0 responses
                        3 views
                        0 likes
                        Last Post GLFX005
                        by GLFX005
                         
                        Started by XXtrader, Yesterday, 11:30 PM
                        2 responses
                        12 views
                        0 likes
                        Last Post XXtrader  
                        Working...
                        X