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
Entry based on price challenge
Collapse
X
-
Entry based on price challenge
I have a strategy based on price. When price is above the open by X points it buys long. However, when it hits the profit target it automatically enters the trade again because it’s still X pints above open. I want to make it to where price has to retrace to the open price before it would allow a long entry again. Is there a way to do that on strategy builder?Tags: None
-
Hello Shiner452,
Thanks for your post and welcome to the NinjaTrader forums!
What you can do here is to create and use a bool type variable (one that is true or false) that is set to true initially.
In the entry set, add the condition that checks to see if the bool is true. On the action side, (where you place your order) add the action to set the bool to false. This will prevent further entries until the bool is reset to true. Create another set that checks that price is less equal to the open price and the action would be to set the bool to true, thus enabling the first set to place a trade again when your other entry conditions are true.Paul H.NinjaTrader Customer Service
-
So i'm doing this using the strategy builder and on the actions side there is no option for me to set the bool to true. I only get 3 main folders, 'Drawings', 'Misc', and 'Order Management'. I don't see any action options that would enable me to effect any other components.
Comment
-
Hello Shiner452,
Thanks for your reply.
Once you have created the bool variable on the Inputs and variables screen, the bool can be set in the action of a set by selecting the Misc folder and scroll to the bottom, You will find the bool (or any variable you create) listed there with the word "Set" in front of it.
Paul H.NinjaTrader Customer Service
Comment
-
Hey Paul. Thanks for your help with this. I have created the bool and the actions as you described. So I have a bool called 'AllowLong' Default value is True. The conditions are when price is greater than XXX and when AllowLong is True...the Action is EnterLong. However, nothing happens. However, when I take the bool off the conditions it enters the long no problem. But then immediately re-enters once I close the position since price is still above XXX. I don't understand why the bool being set for true and the condition of the bool being true is not allowing the order to fill.
Comment
-
Hello Shiner452,
Thanks for your reply.
Do you have another set that could be setting the bool to false?
You may want to work through debugging your script.
Here is a short example of how you might approach this: https://paul-ninjatrader.tinytake.co...NV8xMDk5MDc5Nw
Paul H.NinjaTrader Customer Service
Comment
-
Hello Shiner452,
You can consider checking Misc > First bar of session Equals Misc > True for your strategy's first condition to (re)set your bool to true. Your later logic can then set the bool to false and any logic controlled by the bool would no longer be reached as the bool would be false, until it is reset on the first bar of the next session.
We look forward to assisting.
JimNinjaTrader Customer Service
Comment
-
Hello Shiner452,
Thanks for your reply.
Yes, you can use a time-based condition, please see the example in the help guide here: https://ninjatrader.com/support/help...imeComparisons
Paul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by strategist007, Today, 07:51 PM
|
0 responses
2 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by StockTrader88, 03-06-2021, 08:58 AM
|
44 responses
3,968 views
3 likes
|
Last Post
by jhudas88
Today, 06:59 PM
|
||
Started by rbeckmann05, Today, 06:48 PM
|
0 responses
5 views
0 likes
|
Last Post
by rbeckmann05
Today, 06:48 PM
|
||
Started by rhyminkevin, Today, 04:58 PM
|
4 responses
58 views
0 likes
|
Last Post
by dp8282
Today, 06:13 PM
|
||
Started by iceman2018, Today, 05:07 PM
|
0 responses
6 views
0 likes
|
Last Post
by iceman2018
Today, 05:07 PM
|
Comment