Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy executes double number of contracts

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

    Strategy executes double number of contracts

    Hi!!

    I have the following very simple strategy of HMA crossing

    // Set 1
    if (CrossAbove(HMA1, HMA2, 1))
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 2
    if (CrossBelow(HMA1, HMA2, 1))
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    }

    When I execute it in historical mode it works without problems, but when I work in real time it always executes the double number of contracts. Any idea what the problem is?

    #2
    Hello antragel,

    Thanks for your post and welcome to the NinjaTrader forums!

    Are you showing the complete strategy or are there other exit methods used such as SetProfitTarget, or SetStopLoss()?

    Are you running the strategy with Calculate.OnBarClose, Calculate.OnPriceChange, or Calculate.OnEachTick?

    When you apply the strategy to a chart, in the strategy properties, what setting do you have under "order properties" for "Set order quantity"?

    Does the strategy always show double the contracts or only after the first few trades?

    What specific version of NinjaTrader8 are you using (Look under Help>about)?

    What data feed are you connected to for your live trades?
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello Paul,

      Thanks for your quick response.

      I started with a more complex strategy, but trying to debug the error I simplified it to the maximum until I came to the simple HMA crossover that I put in my previous code. To rule out errors in my code I even created the strategy from the wizard.

      I run the strategy with Calculate.OnBarClose.

      When I apply the strategy to a chart I set "set order quantity" to "Default quantity", and I I have tried different number of entries in "Default quantity" (1, 3, 5...), and the strategy always executes the double number of contracts (2, 6, 10...)

      My ninjatrader version is 8.0.15.1 64-bits

      I´m doing all the test in a simulated account with CQG.

      One strange thing is that if I use the same strategy with SMA instead of HMA there is no problem.

      Comment


        #4
        Hello antragel,

        Thanks for your reply.

        "One strange thing is that if I use the same strategy with SMA instead of HMA there is no problem.", that does seem strange on the surface.

        I recommend that you update to the latest version of NinjaTrader8 which is 8.0.18.0 as there have been a number of changes to the platform and specifically to the Strategy Builder (although I am not aware of a specific double order issue).

        To update:
        • First, copy your license key from NinjaTrader under Help> License Key then exit NinjaTrader
        • Click on the link: http://ninjatrader.com/PlatformDirect
        • Enter your license key and press Submit
        • Select 'NinjaTrader 8'
        • Select 'Download'
        • Critical: Before running the installer, ensure NinjaTrader is closed.
        Once updated, please create a new (do not use an old copy) simplified strategy and test for the issue again.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cls71, Today, 04:45 AM
        0 responses
        1 view
        0 likes
        Last Post cls71
        by cls71
         
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        213 views
        1 like
        Last Post PaulMohn  
        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
        4 responses
        544 views
        0 likes
        Last Post PaulMohn  
        Started by GLFX005, Today, 03:23 AM
        0 responses
        3 views
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        12 views
        0 likes
        Last Post XXtrader  
        Working...
        X