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

Backtest - Managed Approach: ExitShortLimit not triggered - get Exit on Close instead

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

    Backtest - Managed Approach: ExitShortLimit not triggered - get Exit on Close instead

    My strategy opens a position with:

    EnterShortLimit(GetCurrentAsk(), "SHORT");

    I then have this code to set the exit point:

    protected override void OnPositionUpdate(Position position, double averagePrice, int quantity, MarketPosition marketPosition) {
    //Log("=== TYPE ===:" + position.MarketPosition, NinjaTrader.Cbi.LogLevel.Warning);
    if (marketPosition == MarketPosition.Short) {
    Log("ExitShortLimit:" + EMA(barsEMA)[0], NinjaTrader.Cbi.LogLevel.Warning);
    ExitShortLimit(EMA(barsEMA)[0], "SHORT");
    } else if (marketPosition == MarketPosition.Long) {
    Log("ExitLongLimit:" + EMA(barsEMA)[0], NinjaTrader.Cbi.LogLevel.Warning);
    ExitLongLimit(EMA(barsEMA)[0], "LONG");
    }
    }

    In the backtest I see the orders correctly, but it did not trigger. I eventually closed the position with "Exit on Session Close" a few days later. See pic attached.

    Why did the ExitShortLimit(EMA(barsEMA)[0], "SHORT"); not happen?

    Thanks.
    Attached Files

    #2
    Hello jamesmjones00123,

    Thanks for writing in to our Support Forums.

    I see that the order was placed, but I cannot confirm that the market conditions were true to have the the order filled.

    Please verify that the market price has crossed the EMA limit price. Please provide me a screenshot where the order should have triggered.

    To send a screenshot with Windows 7 or newer we recommend using Window's Snipping Tool.

    Click here for instructions

    Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

    Click here for detailed instruction


    There are times where the price can be hit, but it will not fill a limit order. In these circumstances you will be better served to use market orders instead of limit orders. For example, does your strategy exit at that price when using ExitShort()?

    Our Brokerage Support team has further information on order types listed on their website: http://www.ninjatraderbrokerage.com/...er_limit_order

    I look forward to assisting you further.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by PaulMohn, Today, 03:49 AM
    0 responses
    7 views
    0 likes
    Last Post PaulMohn  
    Started by inanazsocial, Today, 01:15 AM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by rocketman7, Today, 02:12 AM
    0 responses
    10 views
    0 likes
    Last Post rocketman7  
    Started by dustydbayer, Today, 01:59 AM
    0 responses
    4 views
    0 likes
    Last Post dustydbayer  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    5 responses
    23 views
    0 likes
    Last Post trilliantrader  
    Working...
    X