Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple but impossible to do it ... Buying and selling

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

    Simple but impossible to do it ... Buying and selling

    Hello, I am trying to do the following but cannot understand the logic of NT to do it.

    Buy at limit yday high (on stop at market if market opens higher than yday high)
    Sell at limit yday low (on stop at market if market opens lower than yday low)
    if both orders are filled then do nothing on the close (as one stops the other)
    if only one order is filled then exit on close.

    Daily strategy based on minute (adddataseries(minute, 1))

    can anyone help me ?

    Thanks

    #2
    Hello guilhem,

    Thank you for your note.

    With the Managed Approach you wouldn't be able to do something like this as it would run afoul of order handling rules. Specifically, with the Managed Approach, if he strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and you try to submit an order that is used to open a position in the opposite direction, the second order will be ignored.

    You would need to use the Unmanaged approach to submit the orders as that approach is not subject to NinjaTrader's internal order handling rules.



    It should be noted that the Unmanaged approach should be used by very experienced programmers as you would need to handle overfills, order rejections, and connection loss scenarios in your code as NinjaTrader will not manage those scenarios for you using this approach.

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Great thanks ... I tought so but was not sure.
      Is there a place where i can find how the main loop works ? when the OnBarUpDate and the others are being called ?

      Thanks for you reply as always

      Comment


        #4
        Hello guilhem,

        Thank you for your reply.

        Primarily NinjaScript methods are event driven, so for example, OnMarketData() would be fired when a tick comes in. When OnBarUpdate() is triggered is dependent on your Calculate setting:



        So, if you're using OnEachTick, OnBarUpdate() would be triggered every time a new tick comes in. With OnPriceChange it would be triggered whenever there's a change in the Last price, and OnBarClose it would be triggered once per bar, when the current bar closes.

        Other methods would be called in an event driven manner as well. So, for example, OnOrderUpdate() is called when an order status changes, whether to submitted, accepted, filled, etc.

        OnExecutionUpdate() would be called when an order is filled, partially filled, rejected, etc.

        Further information regarding these methods may be found in our help guide here: https://ninjatrader.com/support/help...8/strategy.htm

        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Brilliant, I think i understand better the way it works.
          Thanks very much

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          50 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          126 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          69 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X