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

Same entry code, different entry orders?

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

    Same entry code, different entry orders?

    Hello. Excuse my English.
    If the price is higher than the maximum of the black bar with the triangle I want to make a purchase and if the price is lower than the minimum of the black bar with the triangle I want to make a sale.
    The problem is that if I place a purchase order first and then a sale order, the purchase is always executed first. On the contrary.
    This is that with the same condition the strategy does not allow two orders. Execute first the one that appears first in the strategy.
    This has a solution? thank you.
    Attached Files

    #2
    Hi julifro, thanks for your post.

    You can place limit orders with EnterShortLimit() or EnterLongLimit().You can also use SetStopLoss and SetProfitTarget for automatic OCO protective orders.

    Assuming the right-most bar in your image is the most current:

    If the price is higher than the maximum of the black bar
    Would be written as "if(Close[0] > High[1])"

    price is lower than the minimum of the black bar
    Would be written as "if(Close[0] < Low[1])"

    All the best wishes!
    Last edited by NinjaTrader_ChrisL; 05-21-2019, 10:55 AM.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      The bar[0] would be the black bar with a triangle on top. The pseudocode would be

      if High[0] < High[1] & Low[0] > Low[1]
      EnterLongLimit
      EnterShortLimit

      EnterLongLimit is always run first.
      If I put

      EnterShortLimit
      EnterLongLimit

      Always run EnterShortLimit

      In the attached image I want you to first open a long command by breaking the maximum of the black bar and a short command by breaking the minimum of the black bar.

      Thank you.

      Comment


        #4
        Hi julifro, thanks for your post.

        I apologize, I did not mention that you can not have entry orders on both sides of the market at the same time with the managed approach. You would need to write your strategy in the unmanaged approach style to bracket the market like this. To keep using the managed approach, you would need to set one at any given time, canceling the order if you need a limit order in the other direction.

        There is a feature request to add the ability to bracket with the managed approach, I will add a vote to feature ID #SFT-3558.

        All the best wishes!
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rocketman7, Today, 02:12 AM
        5 responses
        23 views
        0 likes
        Last Post rocketman7  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        7 responses
        28 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by samish18, 04-17-2024, 08:57 AM
        17 responses
        66 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by briansaul, Today, 05:31 AM
        1 response
        15 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by PaulMohn, Today, 03:49 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X