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

Manual exit instead of stoploss

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

    Manual exit instead of stoploss

    Hello,
    As part of my strategy I want to use a manual exit instead of a stoploss so I can tag my exit. My thought was to use this:
    //Stoploss
    if (Close[0] == Position.AvgPrice - 35 * TickSize)
    {
    ExitLong("Stoploss", "Long");
    }
    This works eventually, but the market actually moves past (sometimes very far past) the 35 ticks then as it comes back comes back the Exit may get filled. Sometimes price passes though that -35 spot many times.
    Oh I got it! Close[0] has to equal that spot. Maybe I just have to say < instead of ==?
    Sweet that did it!
    I'll post this anyway. Maybe it will help someone else.
    Thanks

    #2
    Follow up on last post.
    The problem with that idea is the stoploss is going to be more than 35 ticks because the bar has to close. I tried GetCurrentAsk() instead of Close[0], but that doesn't change anything.
    Any suggestions on how to get the 35 tick stoploss without using SetStopLoss()?
    Thanks

    Comment


      #3
      You can use ExitLongStop(), and specify the price you want the order submitted at. Anytime you access Position.AvgPrce, you should check that you are in a position or else this returns zero.

      if (Position.MarketPosition == MarketPosition.Long)
      ExitLongStop(Position.AvgPrice - 35 * TickSize);
      Ryan M.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by CaptainAmericaXX View Post
        Follow up on last post.
        The problem with that idea is the stoploss is going to be more than 35 ticks because the bar has to close. I tried GetCurrentAsk() instead of Close[0], but that doesn't change anything.
        Any suggestions on how to get the 35 tick stoploss without using SetStopLoss()?
        Thanks
        Not unless you set CalculateOnBarClose to false. Remember the load that that puts on your resources.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CortexZenUSA, Today, 12:53 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by CortexZenUSA, Today, 12:46 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by usazencortex, Today, 12:43 AM
        0 responses
        5 views
        0 likes
        Last Post usazencortex  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        168 responses
        2,266 views
        0 likes
        Last Post sidlercom80  
        Started by Barry Milan, Yesterday, 10:35 PM
        3 responses
        13 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X