Announcement

Collapse
No announcement yet.

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 -

    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 sjsj2732, Yesterday, 04:31 AM
          0 responses
          33 views
          0 likes
          Last Post sjsj2732  
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          286 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          284 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          133 views
          1 like
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          91 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Working...
          X