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 laketrader, 03-10-2025, 07:20 AM
      7 responses
      67 views
      0 likes
      Last Post laketrader  
      Started by juletjak, Today, 07:37 PM
      0 responses
      2 views
      0 likes
      Last Post juletjak  
      Started by stafe, 03-10-2025, 04:46 PM
      5 responses
      59 views
      0 likes
      Last Post MiCe1999  
      Started by VFI26, 03-21-2025, 11:21 AM
      2 responses
      28 views
      0 likes
      Last Post MiCe1999  
      Started by algospoke, 03-12-2025, 07:41 PM
      2 responses
      34 views
      0 likes
      Last Post algospoke  
      Working...
      X