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

Using ExitLongStopMarket

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

    Using ExitLongStopMarket

    Hi,

    In my strategy code, I use EnterLongStopMarket if my conditions are perfectly met. It works just fine placing the order and waiting for the price till it reaches it, then fills the order. However, sometimes the price goes down and doesn't reach to the level I hope for. So, in this case, I'd like to tell it that after you place the order and then the price goes down to a certain level, ExitLongStopMarket(). Here's the logic I'm using and it's not giving me any errors while compiling, but my orders are still not cancelled even the price goes down to the level where I'd to exit:

    If (my condition is met)
    {
    EnterLongStopMarket();
    }

    // the above part is done elegantly
    // now here's the part where I'm confused and where I'd tell it that after you place the order (as in above) and the price goes down to a certain
    // level, ExitLongStopMarket()

    If (High[0] <= (EMA1[0] + (40 * TickSize))) // that's the price level when is reached, I'd like to exit or cancel any pending orders
    {
    ExitLongStopMarket();
    }

    Appreciate your kind support

    #2
    Hello Abdullah_KSA,

    Thank you for the post.

    I wanted to clarify here, the EnterLongStopMarket has filled and you are in a position. Now you want to wait for the condition you provided to become true and then ExitLongStopMarket. Have I understood that correct?

    I am not sure I see the question surrounding the ExitLongStopMarket, are you asking how to form the condition or were you seeing that the supplied code didn't work?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Is it possible that your condition has an error or it is just a typo?
      If (High[0] <= (EMA1[0] + (40 * TickSize)))

      EMA1[0] = EMA[10] ???

      Comment


        #4
        Originally posted by NinjaTrader_Jesse View Post
        Hello Abdullah_KSA,

        Thank you for the post.

        I wanted to clarify here, the EnterLongStopMarket has filled and you are in a position. Now you want to wait for the condition you provided to become true and then ExitLongStopMarket. Have I understood that correct?

        I am not sure I see the question surrounding the ExitLongStopMarket, are you asking how to form the condition or were you seeing that the supplied code didn't work?

        I look forward to being of further assistance.

        When the EnterLongStopMarket is filled, it only places a pending order 10 ticks above the high price. So the order is not necessarily executed. It depends on how the price goes. If it goes up, then my placed order will be completely executed/filled. If it goes down, here's where I need the help. If it reaches the level I specified, I'd like to either cancel the order to exit it.

        I'm using the ExitLongStopMarket as a way to exit my unexecuted pending orders (if the price goes down). However, I'm not quite sure if my logic is correct since I'm using ExitLongStopMarket after the action of my initial IF statement. Is this correct? Should I include it inside the action part? The code compiles with no problems, but still doesn't cancel the pending orders when price goes down.. I hope now it is clear .. English is not my 1st language .. sorry

        Comment


          #5
          Originally posted by trendisyourfriend View Post
          Is it possible that your condition has an error or it is just a typo?
          If (High[0] <= (EMA1[0] + (40 * TickSize)))

          EMA1[0] = EMA[10] ???

          Umm .. to be honest, I'm not the expert here .. I can barely do the basics
          Anyways, prior to using EMA1, I defined EMA1 by saying.. EMA1 = EMA(Close, 120);
          I cut it out earlier, not to make it so lengthy
          I found it in the help section, and it should work ok

          Comment


            #6
            Hello Abdullah_KSA,

            If the order has not filled yet and you want to cancel it you would need to use Cancel Order. The exit methods are for exiting a position you currently hold.



            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,602 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            8 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            12 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X