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!
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
NinjaTrader
Understanding start behavior
Collapse
X
-
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.
-
Originally posted by NinjaTrader_ChelseaB View PostHello 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();
}
Leave a comment:
-
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:
-
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.
Leave a comment:
-
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:
-
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:
-
Originally posted by NinjaTrader_ChelseaB View PostHello 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?
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:
-
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:
-
Originally posted by NinjaTrader_ChelseaB View PostHello 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:
-
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:
-
Originally posted by NinjaTrader_ChelseaB View PostHello 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:
-
Originally posted by NinjaTrader_ChelseaB View PostHello 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:
-
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:
-
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 Mestor, Today, 03:15 AM
|
1 response
7 views
0 likes
|
Last Post Today, 07:41 AM | ||
Started by RaygunWizzle, Yesterday, 08:52 PM
|
1 response
8 views
0 likes
|
Last Post Today, 07:40 AM | ||
Started by Mestor, 03-10-2023, 01:50 AM
|
13 responses
313 views
0 likes
|
Last Post Today, 07:29 AM | ||
Started by Lele2k24, Yesterday, 11:24 AM
|
7 responses
25 views
0 likes
|
Last Post Today, 07:25 AM | ||
Started by martini, Yesterday, 04:45 PM
|
2 responses
15 views
0 likes
|
Last Post
by martini
Today, 07:23 AM
|
Leave a comment: