Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator or strategy that disconnect or turns off if loss or profit is reached?

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

    Indicator or strategy that disconnect or turns off if loss or profit is reached?

    New and not sure different between an indicator and a strategy and an add-on. I really am just looking for a direction to start in where I can put together something that will monitor my trades untli I realize a certain profit loss or a profit target and disconnect my connections/turn off strategies.

    #2
    Originally posted by MatthewLesko View Post
    New and not sure different between an indicator and a strategy and an add-on. I really am just looking for a direction to start in where I can put together something that will monitor my trades untli I realize a certain profit loss or a profit target and disconnect my connections/turn off strategies.
    If you call account.Flatten it will turn off your strategy, below is a code example.
    Code:
    foreach (Account account in Account.All.Where(acc => acc.Name != Account.Name)) {
        foreach (Position position in account.Positions) {
            Log("Flattening Account : " + account.Name,LogLevel.Information);
            Log("Instrument : " + position.Instrument.FullName,LogLevel.Information) ;
            account.Flatten(new [] {position.Instrument}); //will stop strategy as well
        }
    }

    I build useful software systems for financial markets
    Generate automated strategies in NinjaTrader : www.stratgen.io

    Comment


      #3
      Hello MatthewLesko,

      For a strategy you can just use the CloseStrategy command once your logic determines it should stop trading. You can otherwise just program your logic to not do anything once that limit is reached and the strategy would remain running so you can still view its performance. It is always suggested to program the individual scripts to perform the way you want instead of relying on platform actions like closing a position to disable the strategy.



      For indicators or addons you would have to program the script to stop doing anything, there is not a way to turn off an indicator or addon besides manually removing it from where it is applied. Addons specifically run in the background so there is not a way to turn that off unless it is programmed to have an off switch.

      There is a sample strategy that shows how to work with PnL to control its logic here: https://ninjatrader.com/support/help...nce_statis.htm

      JesseNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by gyilaoliver, Today, 08:28 AM
      5 responses
      12 views
      0 likes
      Last Post gyilaoliver  
      Started by Darkslide_Tom, 03-23-2025, 11:08 PM
      3 responses
      17 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by rtwave, 03-13-2025, 04:09 PM
      4 responses
      29 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by MiCe1999, 12-01-2024, 09:01 PM
      4 responses
      45 views
      0 likes
      Last Post Leeroy_Jenkins  
      Started by coopgrafik, Today, 07:57 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Working...
      X