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.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by f.saeidi, Today, 12:14 PM
    7 responses
    16 views
    0 likes
    Last Post f.saeidi  
    Started by Russ Moreland, Today, 12:54 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by philmg, Today, 12:55 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by TradeForge, 04-19-2024, 02:09 AM
    2 responses
    32 views
    0 likes
    Last Post TradeForge  
    Started by aprilfool, 12-03-2022, 03:01 PM
    3 responses
    329 views
    0 likes
    Last Post NinjaTrader_Adrian  
    Working...
    X