I have found a LongShort button strategy on User-app-share which gives me the code I need. I found CloseStrategy("My Strategy"); in User Guide but what I don't find is the code to enable the strategy so I can use it to enable my strategy. Can someone let me know what command I would use for that?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Adding a button to Enable and Disable specific strategy
Collapse
X
-
Adding a button to Enable and Disable specific strategy
Hi, I would like to create buttons on my chart to enable and disable my strategy.
I have found a LongShort button strategy on User-app-share which gives me the code I need. I found CloseStrategy("My Strategy"); in User Guide but what I don't find is the code to enable the strategy so I can use it to enable my strategy. Can someone let me know what command I would use for that?Tags: None
-
Well that is a problem with the no Enable. But I like you idea, so I could have a variable called Enable and toggle it on and off with the buttons and part of the condition for going long or short would incorporate that variable. Does that sound like a way to do it?
Comment
-
Its been awhile since I wrote this. But my question now relates to the long and short button script. It is set to work Calculate.OnEachTick, if I have OnBarClose it does not work, I have another strategy that needs the OnBarClose vs on tick . What I tried is add data series tick, put the longEnable = true enclosed in If (BarsInProgress ==1) the onclick method added to the button clciked section if barsinprogress and in the onbarupdate added if barsinprogress to if butttonclicked. Is there something else needed to get this to work. Or is it just not possible unless its OnEachClick
Comment
-
So actually the problem was If BarsInProgress != 0 return, removing that and all you need is the AddDataSeries tick. and none of the other if Barsinprogress ==1. But in the strategy that I was working on I cant get my button to work . I want the button to be a momentary button when presses does one thing and returns to its original state to GoLong , it enables and or statement in my onbar update to trade either enableLong == true or all my other conditions it never executes. I guess Ill work on it some more.
Comment
-
I like the idea of using a bool to disable a strategy thru conditions, I need help as how to change that bool from true to false when Profit Target order is executed and or when Profit Target level is reach while being in position. have to be careful not to disable prior to exit
Any Suggestions apprecaited
Comment
-
Hello DTSSTS,
You can use OnExecutionUpdate to see when an order is filled/filling.
OnExecutionUpdate - https://ninjatrader.com/support/help...tionupdate.htm
You could check execution.Name to see if it matches "Profit target" or the signal name for your own profit target order. You could also check in OnExecututionUpdate if Position.MarketPosition == MarketPosition.Flat.
For example, checking the following in OnExecutionUpdate would let you know then the profit target fills and the strategy is flat.
Code:if (exectuon.Name == "Profit target" && Position.MarketPosition == MarketPosition.Flat) { }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
54 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
130 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
72 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
44 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|

Comment