Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Secondary Quasi-Emergency Exit/Stop in Code

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

    Secondary Quasi-Emergency Exit/Stop in Code

    Hi there:

    I am using a strategy that performs well in backtesting and real time with both "Calculate on Bar Close" both True and False. I like the False because it flows and as soon as there is a indication of a reversal then it acts. Also, if there is a flash crash or some news event that is in the opposite of my position then it exits or reverses immediately, but I don't really like the amount of trades it takes on some markets.

    I like the True because it leaves me in longer to allow the trade to develop without getting me out, but exits and reversals are slow to react in certain market conditions (i.e. have to wait for a bar to close to calculate). If a flash crash happens or some huge news event that is in the opposite of my position then it will not (of course) exit or reverse quick enough to protect profits already in place (if applicable). The worse case is the my stop will be taken out, but I would like to still enhance this so that if a flash crash happens when trading with True then it will exit or reverse as needed. I like the True, also, because it trades less (probably about 1/3rd to 1/4th less per market).

    So, my question is: What filter, function, commands can I use as options to be able to use Calculate on Bar Close True (as a base) but also use some method to be able to detect if price is making substantial opposite direction moves (during the current bar) so that I can have it act on that to either exit or reverse during the current bar. I am wanting this to be a type of quasi-emergency detection that will protect any profits that may have been built up before my stop is HIT but yet want to keep the integrity of the Calc on True in place (no trails or anything like that etc). This would help protect profits but would also increase further opportunity for profitability in general and actually turn events like that into profitable trades.

    Several thoughts from NT support and others on the forum are welcome (I am sure this will help others too)!!!



    Greg
    Last edited by birdog; 01-08-2013, 10:54 AM.

    #2
    Hello Greg,
    Thanks for your note.

    You can use the FirstTickOfBar property to separate the logic to calculate once and calculate tick by tick.

    Please refer to this sample code which further demonstrates it.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Would that be the same as setting it a False though? I will read the link in the meantime...smile. Greg

      Comment


        #4
        Originally posted by birdog View Post
        Hi there:

        I am using a strategy that performs well in backtesting and real time with both "Calculate on Bar Close" both True and False. I like the False because it flows and as soon as there is a indication of a reversal then it acts. Also, if there is a flash crash or some news event that is in the opposite of my position then it exits or reverses immediately, but I don't really like the amount of trades it takes on some markets.

        I like the True because it leaves me in longer to allow the trade to develop without getting me out, but exits and reversals are slow to react in certain market conditions (i.e. have to wait for a bar to close to calculate). If a flash crash happens or some huge news event that is in the opposite of my position then it will not (of course) exit or reverse quick enough to protect profits already in place (if applicable). The worse case is the my stop will be taken out, but I would like to still enhance this so that if a flash crash happens when trading with True then it will exit or reverse as needed. I like the True, also, because it trades less (probably about 1/3rd to 1/4th less per market).

        So, my question is: What filter, function, commands can I use as options to be able to use Calculate on Bar Close True (as a base) but also use some method to be able to detect if price is making substantial opposite direction moves (during the current bar) so that I can have it act on that to either exit or reverse during the current bar. I am wanting this to be a type of quasi-emergency detection that will protect any profits that may have been built up before my stop is HIT but yet want to keep the integrity of the Calc on True in place (no trails or anything like that etc). This would help protect profits but would also increase further opportunity for profitability in general and actually turn events like that into profitable trades.

        Several thoughts from NT support and others on the forum are welcome (I am sure this will help others too)!!!



        Greg
        Use the OnMarketData() event handler to handle the other emergency code. Look in the NT Help.

        Comment


          #5
          Hello Greg,
          Yes, it will be CalculateOnBarClose (COBC) == false and with the FirstTickOfBar property, you have the option to simulate COBC = true.
          JoydeepNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          651 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          577 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X