Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Short side of strategy not behaving correctly

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

    Short side of strategy not behaving correctly

    Hi,

    I am having a problem with some code where the long exit strategy is working correctly but the short exit strategy is not.

    The problem with the short side is the trade is exited immediately after it is entered, is there anything I am missing here?

    I've just added the second exit strategy using or statement (myExecutionPrice) prior to this addition everything was working correctly.

    Here's my code;

    Code:
    // If we have a long position and the price is below offset for long (stop-loss) then immediately exit at market (code is in indicator)    
                if (Position.MarketPosition == MarketPosition.Long)
                {
                    if(this.CR(5, 4).TradePosition == 0 || lastPrice <= myExecutionPrice - (5 * TickSize))
                    {
    
                    // Checks to see if our Stop Order has been submitted already
                    //if (stopOrder != null)
                    //{
                        // Modifies stop-loss to an immediate exit 
                        stopOrder = ExitLong("long entry");
                    //}
                    }
                }
                
                // If we have a short position and the price is above offset for short (stop-loss) then immediately exit at market (code is in indicator)    
                if (Position.MarketPosition == MarketPosition.Short)
                {
                    if(this.CR(5, 4).TradePosition == 0 || lastPrice >= myExecutionPrice + (5 * TickSize))
                    {
    
                    // Checks to see if our Stop Order has been submitted already
                    //if (stopOrder != null)
                    //{
                        // Modifies stop-loss to an immediate exit 
                        stopOrder = ExitShort("short entry");
                    //}
                    }
                }
    Regards,
    suprsnipes

    #2
    suprsnipes, I would suggest to debug the order sequence you get with your changed script using the TraceOrders feature we have - http://www.ninjatrader.com/support/f...ead.php?t=3627

    In addition to that be sure to print when your short exit condition would exactly trigger -

    if(this.CR(5, 4).TradePosition == 0 || lastPrice >= myExecutionPrice + (5 * TickSize))

    As you sent then a market exit, so it must be triggering differently as you expected.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    104 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    52 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    34 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    38 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    74 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X