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

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 AttiM, 02-14-2024, 05:20 PM
      11 responses
      184 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by fernandobr, Today, 09:11 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by timmbbo, Today, 08:59 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by KennyK, 05-29-2017, 02:02 AM
      2 responses
      1,281 views
      0 likes
      Last Post marcus2300  
      Started by itrader46, Today, 09:04 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Working...
      X