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

Breakeven code

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

    Breakeven code

    if (Close[0] <= Position.AveragePrice - 30 * TickSize)
    ExitShortStopMarket(Position.Quantity, Position.AveragePrice);

    does anyone know what is incorrect on the above code
    Thanks
    Last edited by DTSSTS; 01-19-2020, 01:46 PM.

    #2
    Hello DTSSTS,

    As far as syntax, I would not expect any compile errors if this is in the action block of a method.

    With logic, I could see an issue that there is no check for a position.

    Below is a link to examples of custom exit order movement.
    https://ninjatrader.com/support/foru...269#post802269
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3

      https://gyazo.com/512c4f88faff2944a8e048e8c747ce27

      looking over the SetMethods example

      is the Trailing Stop Trialing by the "Stop Loss distance" ?

      and What is a Chase Profit Target

      Thanks for the examples as well

      Comment


        #4
        Not sure it will matter, i added all the lines of script code in all areas, no compile errors , but now my strategy will not enter any trades

        I do notice on testing that my Start Date i have set to 8/01/2019 But the Actual results are only going back to 1/1/2020


        https://gyazo.com/a4e7089b9a2d369ccd487b527a023664
        Last edited by DTSSTS; 01-20-2020, 07:14 PM.

        Comment


          #5
          Hello DTSSTS,

          Yes, the Stop loss distance represents the number of ticks from entry the stop price will initially set, and also controls the distance from the current price for the trailing action.

          A chase profit target is a limit order that trails toward the current price as the price moves away.
          https://ninjatrader.com/support/help...auto_chase.htm

          Use prints to understand the behavior of your script. Below is a guide that shows what to put in the print.
          https://ninjatrader.com/support/foru...121#post791121

          I am happy to assist with analyzing the output from prints.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by daniel_weber8, Today, 01:21 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_ChristopherS  
          Started by jungsoohuh, Today, 12:07 PM
          1 response
          26 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by SharonSS, Today, 11:54 AM
          1 response
          18 views
          0 likes
          Last Post NinjaTrader_Jim  
          Started by crystalet, Today, 11:20 AM
          3 responses
          22 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by SuperDude123, Today, 09:23 AM
          1 response
          35 views
          0 likes
          Last Post NinjaTrader_JustinD  
          Working...
          X