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
disabling strategy after closed trade
Collapse
X
-
Hello sra18376,
Thanks for your post.
You can disable the strategy with the Disable() method, please see: https://ninjatrader.com/support/help...7/?disable.htm
You can "skip" historical trades by adding: if (Historical) return; at the top of OnBarUpdate(), this will prevent code below that line from processing until connected to live data.
Reference: https://ninjatrader.com/support/help...historical.htm
-
disabling strategy after closed trade
I am building a strategy and would like for it to automatically 'disable' after a trade is closed.
essentially, i would like to have it set up where i pick a stock, start the strategy on it (starting the strategy immediately opens a long or short), and then when the parameters are met to close the trade, the trade is closed and the strategy stops.
I have achieved this thus far by having a bool flip on when i exit a long or short that prevents me from automatically entering another trade.
However when testing applying the strategy on a chart, it never stays enabled because the strategy starts on past candles on the chart instead of the current one and closes the trade before the current candle starts. this causes the bool to flip on before my current trade is able to even play out.
Is there a better way to achieve what i am trying to do? Or, is there a way to have the strategy not be applied to any of the prior data in a chart?Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by AttiM, 02-14-2024, 05:20 PM
|
12 responses
213 views
0 likes
|
Last Post
by DrakeiJosh
Today, 11:17 AM
|
||
Started by cre8able, 02-11-2023, 05:43 PM
|
3 responses
237 views
0 likes
|
Last Post
by rhubear
Today, 10:46 AM
|
||
Started by frslvr, 04-11-2024, 07:26 AM
|
8 responses
117 views
1 like
|
Last Post Today, 10:30 AM | ||
Started by stafe, 04-15-2024, 08:34 PM
|
10 responses
47 views
0 likes
|
Last Post
by stafe
Today, 10:29 AM
|
||
Started by rocketman7, Today, 09:41 AM
|
3 responses
12 views
0 likes
|
Last Post Today, 10:07 AM |
Leave a comment: