• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Auto exit position

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

    Auto exit position

    Hello,

    I want to automatically exit the position when I have a fixed dollar loss or a fixed tick loss.
    Appreciate any code snippets that can be posted.

    thank you.
    Russ

    #2
    Hello Russ,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    The following code exits a long position when at or over 200 dollars in profit:
    Code:
    			if(Position.MarketPosition == MarketPosition.Long && Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) >= 200)
    			{
    				ExitLong();
    			}
    For information on GetProfitLoss() please visit the following link: http://www.ninjatrader.com/support/h...profitloss.htm
    Patrick H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Leeroy_Jenkins, Today, 07:45 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by 1001111, 02-22-2020, 09:10 AM
    5 responses
    33 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by teafortwo, Today, 12:51 AM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by marcus2300, Today, 04:20 AM
    2 responses
    19 views
    0 likes
    Last Post marcus2300  
    Started by johnnymustard, Yesterday, 11:45 PM
    1 response
    48 views
    0 likes
    Last Post NinjaTrader_Marco  
    Working...
    X