Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Understanding start behavior

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

  • NinjaTrader_Jesse
    replied
    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, 03:29 PM.

    Leave a comment:


  • Aporshnev
    replied
    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:	45
Size:	104.1 KB
ID:	1085790

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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!

    Leave a comment:


  • veronimolly
    replied
    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, 12:00 AM.

    Leave a comment:


  • Aporshnev
    replied
    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...

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello trader14,

    I may still not be understanding.

    It still sounds like you want to disable and re-enable a strategy and have it resume the position (the strategy would start green not yellow).

    Can you clarify further if this is not what you are wanting to do?


    Yes, a strategy with wait until flat that starts with a historical position will ALWAYS wait until flat before it turns green.
    Your strategy logic is what is creating the historical position.

    When you mention: "The only alternative is to use "immediately submit" but that doesn't work either because it violates my strategy rules but not waiting for a bar to fully close."
    I do not understand your meaning by 'not waiting for a bar to fully close'.
    You can wait for a bar to fully close. You can do something before a bar fully closes. You can do either. What is the issue?

    Leave a comment:


  • trader14
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello trader14,

    I'm not clear on how Exit on session close is involved.

    The strategy is calculating a historical position with historical data every time it is enabled.

    This includes historical data from the new session.

    It sounds like you are wanting to disable a strategy and re-enable a strategy and have the position be resumed as described in the forum post I have linked. Is this not what you are wanting to do?
    You guys still aren't getting it, this is simple, even Bionian in this post list understands lol. I'll explain again. Obviously, I have to initially start your strategy at some point using a particular start behavior, "wait until flat" for example. Once it starts, my strategy will function normally assuming you NEVER need to restart it again (this is not realistic obviously). Assuming the strategy is running normally as it should without being restarted, it exits all positions just before close, then remains GREEN during the 1 hour close because the strategy is flat and the account is flat. It's then ready to trade upon the open, wait for the first bar to complete, and then make a trade.

    However, if I attempt to restart my strategy DURING THE 1 HOUR BREAK using "wait until flat" as I want to do to reboot/refresh my PC, I initially I expected the strategy to turn GREEN during the 1 hour close. I wrongly expected it to know that it should be in a flat state (as the strategy dictates all positions are exited just before market close) and be ready to trade at the open. However, I now know this isn't the case. When the my strategy is restarted during the close using the "wait until flat" start behavior, it ALWAYS enters a virtual position (turns and stays yellow) and does not realize that it really should be flat according to the strategy rules. This is a problem because now, my strategy won't trade the way it normally should had I been leaving it running as the above paragraph mentions. The only alternative is to use "immediately submit" but that doesn't work either because it violates my strategy rules but not waiting for a bar to fully close.

    So, Ninjatrader doesn't have a start behavior that works my strategy. I can't reboot my PC during the close because neither "wait until flat" or "immediately submit" will allow my strategy to trade the way it should. The only alternative for me, is to start the strategy once and leave it running forever.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello trader14,

    I'm not clear on how Exit on session close is involved.

    The strategy is calculating a historical position with historical data every time it is enabled.

    This includes historical data from the new session.

    It sounds like you are wanting to disable a strategy and re-enable a strategy and have the position be resumed as described in the forum post I have linked. Is this not what you are wanting to do?

    Leave a comment:


  • trader14
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello trader14,

    If you restart a strategy after the market is open, then even if it was flat when the market opened that is not going to prevent new orders from being placed after the market is open.

    Are you trying to prevent all new orders after the market is open?

    Resuming a strategy would require Immediately Submit. This is outlined in the forum post I have linked.
    No, not at all, you're not hearing me. My strategy exits on session close each day and also utilizes on bar close as part of the strategy. I initially liked the idea of rebooting my PC during the 1 hr break to keep things clean but I noticed that rebooting messes with the strategy behavior and there isn't a start behavior to solve the problem. "Wait until flat" doesn't work because even though the position was exited just prior to close, when I enable the strategy during the close in preparation for the open, it puts on a virtual position. It shouldn't do this, it should be flat, because the market is closed but apparently the strategy isn't aware of this. Using "immediately submit synchronize position" isn't necessarily any better as it will place the order upon the open even though the bar hasn't completed yet. Again, my strategy needs a full bar to complete to know what to do. So, basically, I can't every turn my computer off, ever. There's gotta be a better solution for this.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello trader14,

    If you restart a strategy after the market is open, then even if it was flat when the market opened that is not going to prevent new orders from being placed after the market is open.

    Are you trying to prevent all new orders after the market is open?

    Resuming a strategy would require Immediately Submit. This is outlined in the forum post I have linked.

    Leave a comment:


  • trader14
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello trader14,

    Are you only enabling the strategy before the market opens?

    If not, the historical position may not be flat if there is data process.

    See below about resuming a strategy.
    http://ninjatrader.com/support/forum...332#post499332
    My goal was to restart my computer during the 1 hr break each day. The problem however, is that when I do this, I have to restart the strategy. When I restart the strategy using the "wait until flat" behavior, the strategy remains yellow and never turns green, even when the market opens back up. (It doesn't realize it SHOULD be flat during the close, as my strategy is set to exit all positions upon close, then reenter upon the open.) Is "immediately submit, synchronize account" the appropriate start behavior to use then? Is there a way for the strategy to realize it should be in a flat state during market close while using the "wait until flat" start behavior? Thanks for the help on this!

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello trader14,

    Are you only enabling the strategy before the market opens?

    If not, the historical position may not be flat if there is data process.

    See below about resuming a strategy.
    http://ninjatrader.com/support/forum...332#post499332

    Leave a comment:


  • trader14
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello Bionian,

    Yes, at the top of OnBarUpdate(), this would cause any historical position to be exited on the last historical bar.

    Are you finding that the strategy still has a virtual historical position (showing yellow on the Strategies tab of the Control Center) once real-time data is being received when you are testing?
    Just to chime in here, this sounds like what my strategy is doing. After my reboot during market close, when I reactivate the strategy using the "wait until flat" the strategy never turns green when the market opens, it remains yellow because it still has a virtual position. Would changing the start behavior to "immediately submit, synchronize account" be the correct setting? My strategy exits all positions at market close, then are supposed to reenter upon market open but if I'm rebooting my computer during market close, I think the "wait until flat" is the wrong setting.

    Leave a comment:


  • Bionian
    replied
    Yes Chelsea.

    Since I have had an opportunity to test the strategy today, it appears that it is doing just want I wanted. I it is exiting any open positions, but still showing historical trades, so I can continue to monitor the effectiveness of the strategy. This will help me learn to program. I saved a copy of the strategy which is still available in Chart Builder, so I can continue to modify it. Then I can compare the two, before and after then copy and paste the new code into the strategy you see here.

    Thanks for you help, as always. Hopefully before long I will be able to code them myself.

    Rick

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Bionian,

    Yes, at the top of OnBarUpdate(), this would cause any historical position to be exited on the last historical bar.

    Are you finding that the strategy still has a virtual historical position (showing yellow on the Strategies tab of the Control Center) once real-time data is being received when you are testing?

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by soon123, Yesterday, 11:12 PM
1 response
7 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by Unsuitable, Yesterday, 06:30 PM
1 response
8 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by Tuxstuff215, Today, 06:32 AM
0 responses
10 views
0 likes
Last Post Tuxstuff215  
Started by sandman, Today, 04:58 AM
0 responses
7 views
0 likes
Last Post sandman
by sandman
 
Started by Island_Boy_Trading, Today, 04:15 AM
1 response
10 views
0 likes
Last Post NinjaTrader_Marco  
Working...
X