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

EnterShort/EnterLong clarification

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

    EnterShort/EnterLong clarification

    Hi,

    I am a newbie and have been playing around with a couple of strategies that I have been developing myself.

    I am basically looking for a trigger then wanting to go into a trade using EnterShort(0, quantity, "MyShort") or EnterLong(0, quantity, "MyLong").

    I call these functions once when the conditions are met from within "OnBarUpdate"

    This works fine most of the time but sometimes I get a "Close position" appear on my chart. At this point my strategy becomes say "$-200 Realised" and the trade seems to carry on. i.e. the 'Unrealised' again starts accumulating.

    Eventually when the trade reaches the Profit target the trade ends. By that time I could have already lost $600 if I had three of these 'close positions' come up.

    I have set the profit and stops in my Initialize routine as follows...
    SetProfitTarget("", CalculationMode.Ticks, profit);
    SetStopLoss(
    "", CalculationMode.Ticks, stop, false);

    I am sorry to be asking such a stupid question but looking for an answer in the help files on this just confuses me more as it seems to be very complicated to just place a simple order.

    If you could just point me in the right direction I will really appreciate it.

    Thanks

    #2
    TrevorE, it seems you're not correctly synched up in your account vs strategy positions thus impacting the realtime trading of your strategy, here is good background info on this topic -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks

      Thanks for your quick response Bertand. I restarted the strategy (in between trades) and it all seems fine now.

      If I was willing to forfeit the trade in progress when the strategy starts up would 'flatten everything' sort the problem out instead of having to manually create an order to synchronise them?

      Comment


        #4
        TrevorE,

        No, Flatten Everything would also stop your strategy.

        If you do not want the trade you can go to Tools>Options>Strategies>NinjaScript and select Wait Until Flat. Using that will disregard any preexisting strategy positions and not make any real trades till the strategy crosses a flat state.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks Josh, you guys ROCK!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by arvidvanstaey, Today, 02:19 PM
          4 responses
          11 views
          0 likes
          Last Post arvidvanstaey  
          Started by samish18, 04-17-2024, 08:57 AM
          16 responses
          61 views
          0 likes
          Last Post samish18  
          Started by jordanq2, Today, 03:10 PM
          2 responses
          9 views
          0 likes
          Last Post jordanq2  
          Started by traderqz, Today, 12:06 AM
          10 responses
          18 views
          0 likes
          Last Post traderqz  
          Started by algospoke, 04-17-2024, 06:40 PM
          5 responses
          48 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X