Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLongLimit... and keep updating that order!

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

    EnterLongLimit... and keep updating that order!

    Hi Ninja Team,

    This one has me scratching my head. I want to EnterLongLimit at the EMA, and have my Limit order update if the EMA rises.

    PHP Code:
    if (goLong)
        {
        EnterLongLimit(EMA(8)[0], "Long 1a");
         {
         if (Position.MarketPosition == MarketPosition.Flat && EMA(8)[0] > EMA(8)[1])  EnterLongLimit(EMA(8)[0], "Long 1a"); 
         }
     
        } 
    
    That code doesn't look right... and isn't working. Is there a simple way to do this without going the IOrders route? What I don't want is to cancel/replace on every bar, but instead only cancel/replace the limit entry to the new EMA level if the EMA is rising.

    Thanks!

    #2
    MXASJ, per default orders expire at the next OnBarUpdate(), however you can also send liveUntilCancelled and then just update / resubmit if needed (your limit price changing and still not in position) -

    EnterLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice,string signalName)

    Comment


      #3
      Thanks Bertrand!

      What's doing my head in is this:

      PHP Code:
      if (goLong)
      {
      EnterLongLimit(0, true, posSize, EMA(8)[0], "Long 1a");
      
      } 
      
      Should work (testing it now), but the EnterLongLimit price will not be resubmitted until goLong == true again, even if the EMA has risen in the mean time. Its like I need seperate logic where:

      if a working limit order is in place and the current EMA(8) is greater than that limit order price, new limit order price = EMA(8)[0].

      That's where I'm wading out of my depth and am open to any and all suggestions. The logic of "if a working order is in place" is where I'm stumbling.

      Thanks.

      Comment


        #4
        I'm not sure how you've setup your GoLong condition, but couldn't perhaps use two conditions, one for the initial setup, and one to adjust then if the EMA value changes - if you submit the limit order again (old one working) it would just amend / change the already working order.

        Comment


          #5
          Danke Bertrand,

          I understand and have already been playing with a new "beLong" as well as the existing "goLong" condition.

          One last question though... if my EMA/limit is at, say 1.2575 and on the next bar it is still at 1.2575, will it cancel/replace at the same price (sending me to the back of the queue) or will it be smart enough to know the price has not changed and not cancel/replace?

          I've tried looking at the logs to check the behavior if the bar-to-bar EMA/Limit price remains unchanged but its hard work. Many thanks for your time.

          Comment


            #6
            You're welcome, it should not replace this order then, as there's already an identical one working I believe - best is to enable TraceOrders to look under the 'hood' and debug your individual order behaviour -

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            111 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            60 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            38 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            43 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            79 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X