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

Exiting Multiple Contracts

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

    Exiting Multiple Contracts

    I am trying to get a strategy to exit in multiple ways. I want to trade 3 contracts, exit two at a profit of 3 tics, and exit the third using a trailstop of 5 tics. I identify two orders Cont1=2, Cont2=1. I enter the orders when I my entry condition is satisfied and the entries are working fine. I have a stop loss of 5 tics, and the stop loss is working fine. The problem is I never get a trail stop exit. The strategy continues to hold the third contract until the end of day exit, or until a reverse entry condition occurs. Since there is no way to identify in the strategy wizard a long position after the profit exit has occured, I tried using the Position.Quantity == 1 (or -1) as the qualifier for a long or short condition after the profit target had been hit. The logic for the trailing stop is "exit the long if price gets to the close price of last bar plus my trail stop factor (-5 tics). I have the opposite condition for a short with a separate trl factor that is positive. Any idea why this shouldn't work. It seems to be logically correct, (but then they always do don't they)?
    Thanks
    Daven



    // Condition set 3
    if (Position.Quantity == 1)
    {
    ExitLongStop(Close[(int) (Close[1])] + LTrlStop * TickSize, "LTrlExit", "X2Long");
    }

    // Condition set 4
    if (Position.Quantity == -1)
    {
    ExitShortStop(Close[1] + ShtTrlStop * TickSize, "STrlExit", "X2Short");
    Last edited by daven; 04-28-2008, 04:15 PM. Reason: Typo

    #2
    Try using Position.MarketPosition instead.

    Code:
    if (Position.MarketPosition == MarketPosition.Long)
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by claxxical, 05-30-2017, 12:30 PM
    38 responses
    4,479 views
    0 likes
    Last Post alancurry  
    Started by mintos, 04-02-2024, 08:22 PM
    5 responses
    34 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Felix Reichert, 04-26-2024, 02:12 PM
    10 responses
    70 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by PaulMohn, 04-24-2024, 03:49 AM
    4 responses
    37 views
    0 likes
    Last Post PaulMohn  
    Started by lightsun47, Today, 11:37 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Working...
    X