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

Entries per direction / ExitLong / ExitShort don't work properly real time

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

    Entries per direction / ExitLong / ExitShort don't work properly real time

    Hi!

    I have the following Problem: My strategy has entries per direction = 1. However, sometimes the strategy didn't exit the whole position or the strategy entered multiple times when trading real time (no sim account!). See attatched the real time trade performance report where you can see the problems.

    For example: The strategy entered on 19 July 2018 with 8 GER30 Short and made an Exit on 20 July 2018 with only 7 GER30 Long instead of 8 GER30 Long. I don't understand how that is possible because I have only "ExitShort()" in the code with no specification with size or anything.

    Also afterwards the positions went up to 32 GER30 short which shouldn't be possible when having entries per direction = 1.

    In the strategy analyzer everything was fine. I checked the parameteres and they are identical in both the strategy analyzer and the real time trade performance report. So these problems only occur when trading real time.

    The code of the strategy is basically as follows:


    double entryPrice = Close[0];
    int size = (int) (this.Capital / entryPrice);

    // Long
    if (IsFlat)
    {
    if (CONDITION)
    EnterLong(size, "Buy");
    }

    if (CONDITION)
    ExitLong();


    //Short
    if (IsFlat)
    {
    if (CONDITION)
    EnterShort(size, "Sell");
    }

    if (CONDITION)
    ExitShort();

    }

    bool IsFlat { get { return base.Position.MarketPosition == MarketPosition.Flat; }}
    bool IsLong { get { return base.Position.MarketPosition == MarketPosition.Long; }}


    Can anyone help me with this problem? I want the strategy to exit the whole position and not to enter multiple times in the same direction.

    Thanks!

    #2
    Hello KirkHammett,

    Thanks for your post.

    Strategy Analyzer vs. Realtime data will not be an apples to apples comparison as it would be comparing trades made with historical OHLC values vs. actual market dynamics. We should attempt to reproduce with the Playback Connection, and if the Playback Connection shows the issue, then we can start taking debugging steps. If the issue is only seen with real accounts, we should then identify how the issue can be encountered.

    Could you provide us answers to the following questions so we can be of further assistance?
    1. Do you see this issue when using the Playback Connection to reproduce this occurrence?
    2. Do you see this issue when using the Sim101 account with Live data or is this only prevalent when submitting orders to a live or paper trading account?
    3. If this is only seen when trading to a live account, who is your broker?
    Publicly available information on the Playback Connection can be found here - https://ninjatrader.com/support/help.../?playback.htm

    I look forward to your reply.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by selu72, Today, 02:01 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by WHICKED, Today, 02:02 PM
    2 responses
    12 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by f.saeidi, Today, 12:14 PM
    8 responses
    21 views
    0 likes
    Last Post f.saeidi  
    Started by Mikey_, 03-23-2024, 05:59 PM
    3 responses
    51 views
    0 likes
    Last Post Sam2515
    by Sam2515
     
    Started by Russ Moreland, Today, 12:54 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Erick  
    Working...
    X