• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Do Something after a stop loss/after exiting ?

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

    How to Do Something after a stop loss/after exiting ?

    I am building a trend trading strategy. As everyone knows, there would be some 'false trends' recognised by a strategy whenever it is not a strategy perfect for recognising trend. I would like to spot those false trends by counting the times I hit my stop loss in a trend. For example, how should I code if I want to call a trend false after my stop loss has been hit 3 times? I have thought of the following
    if (stoploss something)
    {
    a++;
    }
    and when a = 3, I call this trend a false one. But I just do not know what to type in the bracket.
    Also, I would like to stop entering the market after having 3 profiting trades in a single trend. What should I type in the bracket?
    Thank you!

    #2
    Hello alantse123,

    Thank you for the post.

    Your logic would likely work for the purpose you described, but I am unsure what you mean by what to type into the bracket, Can you clarify what you mean by bracket in contrast to the syntax you provided? Is this the stoploss something condition you are speaking about?

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

    Comment


      #3
      Sorry for the unclear meaning. What I mean is
      if (EventA)
      {
      a++;
      }
      EventA is "When my stop loss is hit./When I exit by a stop loss but not a profit target".
      How should I code for the above event?
      I want the action "a++" to be taken right after the an exit order is executed, does that mean I should put it inside OnOrderUpdate? If yes, what should the code look like?
      Last edited by alantse123; 12-18-2018, 08:18 PM.

      Comment


        #4
        Hello alantse123,

        Thank you for the reply.

        If you are looking for an order fill, you should use OnExecutionUpdate for that purpose as this override deals directly with the scripts executions.
        https://ninjatrader.com/support/help...ub=onexecution

        You have provided the syntax a++ which is valid syntax, you would just need to put that where you want it to be executed. If an order execution is where you would like that to happen, you could put the a++ inside of OnExecutionUpdate within a condition checking for the order you want. We have some examples showing how OnExecution can be used in the help guide link I provided above.

        If you are using the Set methods for the stoploss, you will need to look in the control center orders tab at the orders name and use that in place of the name provided in the sample "myEntryOrder". Upon finding the stop order you could execute the a++ inside of that condition.

        As I am unsure of the scope where you have defined the "a" variable, I would suggest using the help guide sample to implement the OnExecutionUpdate override in your script. At that point, if you are having difficulty with a portion of using this override in contrast to what you have coded, I would suggest uploading what you coded so I can see specifically what you wrote. This would help me to provide more detailed answers surrounding your questions.

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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Gerik, Today, 04:09 AM
        1 response
        4 views
        0 likes
        Last Post Gorkhaan  
        Started by TrendFollowingCapital, Today, 05:09 AM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by Jakub, Yesterday, 11:52 AM
        1 response
        16 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Started by dltharpe, Yesterday, 09:17 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Started by Johnny Santiago, 10-11-2019, 08:21 AM
        8 responses
        116 views
        0 likes
        Last Post cshrum
        by cshrum
         
        Working...
        X