Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Understanding start behavior

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

    #16
    I apologize for the intrusion.
    Is there a function to close a historical position manually without unlocking the script? I need historical order traces, but most of the time when I enable the strategy it has historical position which should be closed only by the end of session. Thus the strategy will not work during the day at all... Can I kind of "clean-up" or "make it flat" manually at any time of the session?
    P.S. I can not submit+synchronize account because there are limit orders in my strategy that shall be fired either above or below market which will cause the error and disable the strategy automatically. So it is a dead end...

    Comment


      #17
      The strategy is quite simple just find the historical points every time whenever it is enabled.

      Thanks.
      https://watchseriesonline.live/ https://internetspeed.onl/
      Last edited by veronimolly; 04-07-2020, 01:00 AM.

      Comment


        #18
        Hello Aporshnev,

        Unfortunately, this would not be possible without unlocking the script first.

        The order must be submitted from the strategy itself to affect the strategy position. This could be with a button added to the chart by the strategy or with internal strategy logic. Both approaches are advanced and neither are possible in the Strategy Builder.


        veronimolly,

        Welcome to the NinjaTrader forums!
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello Bionian,

          The strategy will process historical data before real-time data.
          Historical orders will appear on the chart.
          https://ninjatrader.com/support/foru...442#post782442

          With Wait until flat, if the strategy calculates a historical position open, it will wait until a virtual order closes the historical position before placing any real-time orders.
          Once the strategy has become flat or crossed through flat, the strategy name will become green indicating the strategy is now sending real-time orders.
          https://ninjatrader.com/support/foru...541#post811541

          To prevent a strategy from processing any historical data use:
          if (State == State.Historical)
          return;

          To exit a position on the last historical bar use:
          if (State == State.Historical && CurrentBar == Count - 2)
          {
          if (Position.MarketPosition == MarketPosition.Long)
          ExitLong();
          if (Position.MarketPosition == MarketPosition.Short)
          ExitShort();
          }
          It would be great to have an additional marker in the menu "Close Historical Position on Next Bar" or "Do not process historical Data". This will make a lot of lives much easier on your side as well as on our side. I believe we can collect a lot of voices for this add-on in future releases - would you kindly initiate a ticket for developers?

          Click image for larger version

Name:	HistoricalDataCloseHistoricalPosition.jpg
Views:	43
Size:	104.1 KB
ID:	1085790

          Comment


            #20
            Hello Aporshnev,

            I will put in a feature request for both of these items however the option for not processing historical data is already something you can program into the builder. I don't see that we provided the steps for this so I just wanted to post it here for the time being.

            To prevent historical orders you could add the following condition to any set which should only work in realtime:

            Left: Misc -> Current State
            Center: Equals
            Right: Misc -> State -> Realtime

            I realize this is extra code that is added for the purpose and the checkbox would be easier so I will also request that. You may be able to use a UserInput with this to create your own checkbox as another step.


            I look forward to being of further assistance.
            Last edited by NinjaTrader_Jesse; 01-31-2020, 04:29 PM.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by tobiaste, Today, 03:11 AM
            0 responses
            5 views
            0 likes
            Last Post tobiaste  
            Started by s.kinra, Today, 02:59 AM
            0 responses
            9 views
            0 likes
            Last Post s.kinra
            by s.kinra
             
            Started by JimB17, 01-10-2020, 10:27 AM
            15 responses
            340 views
            0 likes
            Last Post cls71
            by cls71
             
            Started by aaajv, Today, 01:15 AM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by aaajv, Today, 01:13 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_Jason  
            Working...
            X