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

Opening position in intrabar

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

    Opening position in intrabar

    I would like my strategy to open a position when the price exceeds a standard deviation line in the chart. However, the position is not taken until the start of the next bar(for example 5-minute candlestick). Sometimes in fast markets, this can mean a huge difference in entry price compared to the price of the standard deviation line.

    How do I tell my strategy to take trades *exactly* when the line is crossed, instead of waiting until the start of the next candle bar?


    Thank you

    #2
    Hello GoodBro,

    Thank you for your post.

    If you would like your strategy to calculate more frequently than on bar close, you would need to change the Calculate setting to OnPriceChange or OnEachTick. OnEachTick means the strategy would calculate on every single tick. OnPriceChange means it would calculate once for each price change.

    See the help guide link below for more information about Calculate.

    Calculate - https://ninjatrader.com/support/help.../calculate.htm

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your repply.
      This is done but still it doesn't work.
      See in attachement an example with the bollinger bands.
      Since I don't want to wait the bar close to take a position I set BID has to cross below the lower band. It has no effect when I try the strategy in playback or in live condition on Sim101.
      Attached Files
      Last edited by GoodBro; 02-04-2021, 03:27 PM.

      Comment


        #4
        Hello GoodBro,

        Thank you for your note.

        If the expected trade(s) are not appearing, this would indicate that the condition to place the order is not evaluating as true or the order is being ignored for other reasons.

        To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

        In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar.
        Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

        Also, you could enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

        Below is a link to a forum post that demonstrates using prints to understand behavior and including a link to a video recorded using the Strategy Builder.
        https://ninjatrader.com/support/foru...121#post791121

        Please let me know if I may further assist
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Hello Brando,
          Thanks for the advices.
          I switched TraceOrders to true and added prints so we are now able to monitor what is going on through the Output window.

          I noticed that orders are not submitted when the conditions are true.

          I tried to only change the "Cross Below/Above" conditions to "Less/Greater". It works pretty good even though this is not what I am looking for. I want only one order to be sumbitted at the cross moment.

          I feel like cross below/above can't work with Bid/Ask price data on Calculate.OnPriceChange/Calculate.OnEachTick.
          Attached Files
          Last edited by GoodBro; 02-05-2021, 10:03 AM.

          Comment


            #6
            Hello GoodBro,

            Thank you for that information.

            CrossAbove/CrossBelow requires the use of a series object. The Bid/Ask options in the Strategy Builder use GetCurrentBid/GetCurrentAsk which are not a series object. That means that the Bid/Ask cannot be used for CrossAbove/CrossBelow conditions in the Strategy Builder.

            If you would like to have your orders submit the moment that the Bid/Ask is above or below the Bollinger bands, you would need to check if the Bid/Ask is less than or greater than the Bollinger Band and use a Calculate mode of OnEachTick or OnPriceChange. A bool could be used to have a single entry order placed. For example, you could create a bool (initially set to false) that is flipped to true when your order entry condition returns true. Then, you could check if the bool is true followed by calling EnterLong/EnterShort and flipping the bool back to false. This would mean that one entry order would be placed since the bool would need to be true to place the order.

            See the help guide documentation below for more information.
            CrossAbove - https://ninjatrader.com/support/help...crossabove.htm
            CrossBelow - https://ninjatrader.com/support/help...crossbelow.htm
            GetCurrentBid - https://ninjatrader.com/support/help...currentbid.htm
            GetCurrentAsk - https://ninjatrader.com/support/help...currentask.htm

            Let us know if we may assist further.
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,404 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by Shai Samuel, 07-02-2022, 02:46 PM
            4 responses
            95 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by DJ888, Yesterday, 10:57 PM
            0 responses
            8 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by MacDad, 02-25-2024, 11:48 PM
            7 responses
            159 views
            0 likes
            Last Post loganjarosz123  
            Started by Belfortbucks, Yesterday, 09:29 PM
            0 responses
            8 views
            0 likes
            Last Post Belfortbucks  
            Working...
            X