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

Entering on break of bar

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

    Entering on break of bar

    I've been trying to create a strategy whereby a trade is entered on the break of a previous bar. I have been using CrossBelow and CrossAbove but these don't provide accurate entries.

    For example, I want to:

    Identify a price level to enter trade based on previous bar high/low.

    As soon as price goes below/above this identified price, I want to be able to enter an order immediately on the next following bar which crosses that price boundary.

    I have tried using GetCurrentAsk() < MyPriceLevel for example, but this still doesn't work even though I've set Calculate.OnPriceChange within OnStateChange() so that OnBarUpdate is called on each price change.

    Example I've tried:

    protected override void OnBarUpdate()
    {

    if(GetCurrentAsk() < SomePriceLevel)
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), @"TheBigShort");
    }

    }

    Can someone please suggest a method which will work or why this won't work.

    Thanks
    Gerard

    #2
    Hello Gerard,

    So I can best answer your question I will need some clarity.

    On the current bar, Close[0], you would like to set the value of SomePriceLevel, based off the high/low of the previous bar, and if the current bar goes above this price, wait until the next bar and execute long? Or would you like to enter on the current bar, Close[0] as soon as it breaches SomePriceLevel?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hi there,

      Thanks for your reply.

      I hope this clarifies:

      Example: Bar 'X' closes. Record High of Bar 'X'. As soon as any next following bar as it is forming in real time, say Bar 'Z' equals or goes above the recorded high of Bar 'X' then enter trade immediately. Do not wait for bar 'Z' to close before entering the trade.

      I hope this is clear?

      Thanks
      Gerard

      Comment


        #4
        Hello globaljobber,

        I put together and attached a strategy which will buy the moment the previous bars high is taken out.

        You should run the strategy with Calculate set to On Each Tick. Also you'll want to enable tick replay for historical trades to plot correctly, see note one at the following link explaining this point.


        Please let us know if you need further assistance.
        Attached Files
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Thanks Alan,

          I'll take a look over the weekend, appreciated.

          Regards
          Gerard

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GwFutures1988, Today, 02:48 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by ScottWalsh, 04-16-2024, 04:29 PM
          6 responses
          30 views
          0 likes
          Last Post ScottWalsh  
          Started by frankthearm, Today, 09:08 AM
          10 responses
          36 views
          0 likes
          Last Post frankthearm  
          Started by mmenigma, Today, 02:22 PM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by NRITV, Today, 01:15 PM
          2 responses
          9 views
          0 likes
          Last Post NRITV
          by NRITV
           
          Working...
          X