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

How to know a Pending Fill

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

    #16
    Hi Chelsea,

    Thanks for your reply and points and request.

    From my test of your script, please see post #10 video from timestamps 1min12seconds to 1min34seconds:

    I see the Target order being adjusted downward as the GC Price moves some ticks down.
    Then when GC Price moves up some ticks back up, the Target order does not move back up.
    That's what I wanted to mean by locking the Stop movement. As the Target order is only allowed to move in one direction— not 'retrace' the terrain it's already made.

    From 11min08seconds to 11min14seconds,

    Similar action is noticed with the Stop loss.
    An order is filled at 1818.3 with Stop loss initially placed at 1815.3 (11min11seconds).
    Then a surge in GC price from 1818.3 to 1818.5 occurs and the Stop immediately moves up to 1816.9 (11min14seconds).
    Then on GC movement couple ticks back down form the surge to 1818.4, between 11min14seconds and 11min16seconds, you see the Stop loss remains at 1816.9.
    Then again GC moves back down to 1818.2 (11min36seconds). But as you can see The Stop Loss remains locked at 1816.9.


    Then later at 12min48seconds GC Price is at 1818.7, and the stop Loss is still at 1816.9.

    Then at 15min40seconds GC surges back up to 1819.1. But the Stop remains at 1816.9 (contrary to what I need— for it to move back up again as the GC Price does so).

    Then at 18min31seconds and at 24min02seconds GC gets below the entry price and the Target starts again moving down.

    Somehow your script does lock the StopLoss and Target to only go in one direction (I don't understand how it does so).
    The Stop loss movement can only go up (for long trades).
    The Target movement can only go down (for long trades).

    That's what I want to achieve for the 1st part of what I need.

    1st part of what I need:
    How does your script make the stop only move up and never down? Even when the price retraces after a surge up?
    How does it locks the StopLoss to the fixed 1816.9? while the Target still moves down after Entry Price is breached down the subsequent times (at 18min31seconds and at 24min02seconds).

    2nd part of what I need:
    How to make the Stop Loss continue its move forward upon new GC Price surge up (at 15min40seconds the Stop Should move up again, not remain at 1816.9)?

    Please let me know if that still is not clear enough. I'll improve further if need be.

    Comment


      #17
      Hello Cormick,

      The order movement is controlled by when and at what price the currentSlPrice and currentPtPrice are set. This is controlled with logic. Only choose prices that are toward the market price.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Originally posted by NinjaTrader_ChelseaB View Post
        Hello Cormick,

        You can decide not to set a new trigger price once the order is moved once, if you do not want to continue trailing and just want a single breakeven movement.
        You could also decide to use a bool. Once the movement occurs, set the bool to true. In the condition that triggers the movement require the bool to be false.
        You could use an integer as a counter if you want a specific number of movements. Increment the counter on each movement, and in the condition that triggers the movement require the counter int to be less than, a number for how many movements you want.
        Hi Chelsea,

        I'm considering your bool suggestion within a 3 moves example.


        I've found best example of many from Jesse's post here:



        Other examples:


        I'll test it tomorrow.

        Thanks again!

        Comment


          #19
          Hi Chelsea,

          I've managed to get the Stop Loss to lock at each step.

          With Jesse's example: And with the further help of this example (thatThingHappened)
          But now it only executes the Stop Loss movement on the first trade—
          when I enter a 2nd or more trades the StopLoss get initially set but doesn't do the 3 'locked' steps moves anymore.

          Jesse mentioned a reset mechanism:
          Click image for larger version

Name:	vmplayer_t29no71wHJ.png
Views:	90
Size:	89.8 KB
ID:	1166561

          I tried to set the bools I used in my code back to false at the end of the if statement (from the if() else if() statement in onBarUpdate).
          But that did not let the Stop Loss to work again on 2nd and subsequent trades.

          My reset code:

          OnBarUpdate()

          // Stop Loss movement logic

          if(st1SlMoveHappened == true
          && nd2SlMoveHappened == true
          && rd3SlMoveHappened == true)
          {
          st1SlMoveHappened = false;
          nd2SlMoveHappened = false;
          rd3SlMoveHappened = false;
          }
          //Short side
          else if (Short Side)
          {
          // same code as previous for the short side
          }


          Why isn't it working as per Jesse's example?

          What do I need to do next for the code to reset (move the Stop Loss for new trades, not just the 1st trade)?
          Attached Files

          Comment


            #20
            Hello Cormick,

            The condition looks fine to me, to set these to false when they are true.

            Add prints to understand what is happening. Include a print of Time[0] with each print, and a include a letter label so we know which print is printing (like a, b, c, etc).

            Below is a link to a forum post that demonstrates using prints to understand behavior.


            Add a print above the condition to ensure that condition is being reached.
            Add a print within the action block of the condition to ensure the condition evaluated as true.
            Print st1SlMoveHappened, st1SlMoveHappened, and rd3SlMoveHappened one line above the next condition that compares these values.
            Enable TraceOrders to ensure the order is not being ignored.

            By stepping through each step with a print we can see where the condition is setting the values and check the values after they are set, then just before they are used to see if they got changed somewhere.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by techgetgame, Today, 11:42 PM
            0 responses
            6 views
            0 likes
            Last Post techgetgame  
            Started by sephichapdson, Today, 11:36 PM
            0 responses
            1 view
            0 likes
            Last Post sephichapdson  
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,612 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            9 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            19 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Working...
            X