Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

resetting to null

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

    resetting to null

    Hello

    In my strategy, there are 5 ways that a long trade can be exited. Three of them have their own IOrder order variables
    • IOrder LongBStop
    • IOrder LongAdjustedStop
    • IOrder TrailingStopLong


    The other two ways are
    • Close below SMA
    • Close below Custom Indicator


    For the last two, I simply use this code:

    Code:
    				if (LongEntryA != null
    					&& LongEntryB != null
    					&& (Close[0] < SMA(sMAPeriod)[0]
    					|| Close[0] < CustomIndicator[xyz]))
    				{
    					ExitLong("LongEntryA");
    					ExitLong("LongEntryB");
    				}
    I do not know how to check to see if the trade has closed in one of these two ways in order to reset the orders back to null. I also need to know this in order to reset LongBStop, LongAdjustedStop, & TrailingStopLong back to null.

    Could you please let me know how to check for that in order to reset to null?

    Thank you very much for your help!

    #2
    Originally posted by jg123 View Post
    Hello

    In my strategy, there are 5 ways that a long trade can be exited. Three of them have their own IOrder order variables
    • IOrder LongBStop
    • IOrder LongAdjustedStop
    • IOrder TrailingStopLong


    The other two ways are
    • Close below SMA
    • Close below Custom Indicator


    For the last two, I simply use this code:

    Code:
                    if (LongEntryA != null
                        && LongEntryB != null
                        && (Close[0] < SMA(sMAPeriod)[0]
                        || Close[0] < CustomIndicator[xyz]))
                    {
                        ExitLong("LongEntryA");
                        ExitLong("LongEntryB");
                    }
    I do not know how to check to see if the trade has closed in one of these two ways in order to reset the orders back to null. I also need to know this in order to reset LongBStop, LongAdjustedStop, & TrailingStopLong back to null.

    Could you please let me know how to check for that in order to reset to null?

    Thank you very much for your help!
    No need to check. Those are market orders, and so are more or less guaranteed to execute, even if at atrocious slippage. Just assume that the order will execute and do as you will, right after it, in the same block.
    Last edited by koganam; 08-09-2014, 04:06 PM. Reason: Corrected punctuation.

    Comment


      #3
      Thanks koganam. You always give really good information.

      There is something that I am still not understanding though. I will give you a small scenario to help things out.

      LongEntryA & LongEntryB both get triggered and I am now long 2 positions. LongEntryA hits its profit target which is then what triggers LongAdjustedStop and it is now an order sitting there waiting to be executed and filled. While waiting for the price to get to that level, the candle closes below the SMA which then triggers a sell market order. Therefore, I am out of the trade because of the market order and not because of the LongAdjustedStop order.

      At this point, in my extremely limited understanding, I would need to reset LongAdjustedStop back to null. I would need to do this because as soon as it has an order associated with it, it is no longer null. But, do I understand you correctly, that I actually do not need to reset LongAdjustedStop back to null because the trade was closed out using a market order?

      Thank you, and everybody else for your help.

      Comment


        #4
        Originally posted by jg123 View Post
        Thanks koganam. You always give really good information.

        There is something that I am still not understanding though. I will give you a small scenario to help things out.

        LongEntryA & LongEntryB both get triggered and I am now long 2 positions. LongEntryA hits its profit target which is then what triggers LongAdjustedStop and it is now an order sitting there waiting to be executed and filled. While waiting for the price to get to that level, the candle closes below the SMA which then triggers a sell market order. Therefore, I am out of the trade because of the market order and not because of the LongAdjustedStop order.

        At this point, in my extremely limited understanding, I would need to reset LongAdjustedStop back to null. I would need to do this because as soon as it has an order associated with it, it is no longer null. But, do I understand you correctly, that I actually do not need to reset LongAdjustedStop back to null because the trade was closed out using a market order?

        Thank you, and everybody else for your help.
        To the contrary, just set the relevant order to null, as the position has been closed by the market order. Think of the big picture. Why are you setting the order to null? Because the position with which it is associated no longer exists, right?

        Comment


          #5
          Okay, so in this scenario, which order do you consider to be "the relevant order"?

          Comment


            #6
            jg123,

            The relevant order would be the LongAdjustedStop order that you have set and waiting.
            Cal H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            647 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            368 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            571 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X