Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position size question

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

    Position size question

    Hello,
    I'm running a fairly simple strategy trading EURUSD:
    if(condition A) EnterLong();
    if(not condition A) ExitLong();
    if(condition B) EnterShort();
    if(not condition B) ExitShort();

    My understanding is if EntriesPerDirection=1 and EntryHandling=EntryHandling.AllEntries and DefaultQuantity=10000, that I always have only 10000 contracts at a certain amount of time.
    But in the chart window I see the following comments attached to the entry/exit points:

    1. "Buy 10000 @ 1.0637'6"
    2. "Sell 10000 @ 1.0632'0", "Close position 10000 @ 1.0632'0", "Sell short 10000 @ 1.0632'0"
    3. "Close position 20000 @ 1.0628'7"

    My question: why 20000 in the last trade? What do I miss here? Always expect to have only 10000 contracts in the market!

    Thanks for your help
    Frank

    #2
    Hello TraderFrank, and thank you for your question.

    One possibility is that the Internal Order Handling Rules to prevent unwanted positions did not catch your strategy's hedging quite in time. To prevent this from happening in the future, please change your code logic to the following :

    Code:
    if (condition A and not short) EnterLong();
    else if (not condition A and long) ExitLong();
    if (condition B and not long) EnterShort();
    else if (condition B and short) ExitShort();
    You can see if you are long or short with Position.MarketPosition. The values it can take are MarketPosition.Short and MarketPosition.Long.

    If your conditions already included market position checks, or if there are any other ways we can help, please let us know, and please provide a stripped-down code sample we can use to see the same thing on our end as what you are seeing on yours.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Jessica, will try that.
      However, I thought just using EnterLong() followed by a EnterShort() is closing previous long position? But what you are saying is that I can't keep it that simple - I need to check for MarketPosition and always use ExitLong/ExitShort calls.

      Thanks
      Frank

      Comment


        #4
        Correct, an EnterShort call while you are already in a long position will reverse your position, closing your long contracts and entering on the short side of the market. And you can not enter both long and short within the same bar.
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        56 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        132 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X