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
Strategy Builder Example
Collapse
X
-
Strategy Builder Example
I am learning about strategy builder and NinjaScript and doing a simple RSI overbought and oversold strategy. Does anyone have any examples I can learn from? I am just looking for an example that has if else if statements on when certain indicators meets a condition with a StopLoss(), TraillingStop(), and ProfitTarget() order executionTags: None
-
Hello w0lverine,
Thanks for your post.
In the strategy builder you would create a "set" for overbought and a "set" for "oversold". the reason you would do this is that the "action" as a result would likely be different for each.
So for example in set one, if the RSI was overbought, the action could be to sell short, in set two if the RSI is oversold, the action could be to buy long.
The stop and target would be created in the "Stops and Targets" window of the strategy builder. The simplest option to use is to place a fixed stop and a fixed target using the mode of "ticks" and specifying a set amount of ticks. Please note that you cannot use both a trailing stop and a fixed stop on the same order if so, only the fixed stop will be used.
To clarify on the Stop and Target, by using the mode of Ticks and a fixed amount, what happens when an entry is filled is that the strategy will automatically create the stop and target the ticks away from the entry according to the entry direction, so in the case of a short order entry and using a 10 tick stop and 20 tick profit, the strategy will automatically use the filled entry price and subtract 10 ticks for the stop target and will add 20 ticks to the entry price for the profit target. If a long entry, then the stop is placed 10 ticks below the entry and the target 20 tick above the entry.
If you haven't already you may want to attend the free live training on the strategy builder where all of this is explained. The live training occurs every other Thursday (alternates weeks with Ninjascript editor training): https://ninjatrader.com/PlatformTraining
Here is a link to a previous recording: https://www.youtube.com/watch?v=HCyt...We0Nf&index=11Paul H.NinjaTrader Customer Service
-
NinjaTrader_PaulH Thanks for the descriptive answer. I see my mistake now. And I thought I read somewhere that we can't combine a trailing stop with the stoploss function. Is there a reason why? I mean could I set the trailing stop for 10 ticks and it will trail with every tick "acting as my stop loss"?
Comment
-
Hello w0lverine,
Thanks for your reply.
If you are looking for examples of how to set up an indicator to compare to a numeric value, please see the section "How to make indicator to value comparisons" in the strategy builder's condition builder examples here: https://ninjatrader.com/support/help...on_builder.htm
Regarding the StopLoss and SetTrailStop, in the help guide section for the SetTrailStop() are these two notes:
The SetTrailStop() method can NOT be used concurrently with the SetStopLoss() or SetParabolicStop() method for the same position, if any of methods are called for the same position (fromEntrySignal) the SetStopLoss()will always take precedence. You can however, use all three methods in the same strategy if they reference different signal names.
Trail stop orders are modified based on the strategies 'Calculate' settings. In the case of 'Calculate' on bar close, when the bar closes the trail stop order modification will occur using the closing price of the bar as the reference price to apply the trail offset. Subsequently if the open price of the next bar is significantly higher or lower then the current close price then there is a possibility that the calculated trail stop price is now an invalid stop price. This is a risk with modifying any stop order closer to the current market price since any modification above/below the current price would be rejected.
A fixed stop is used as it is a more conservative approach.
"I mean could I set the trailing stop for 10 ticks and it will trail with every tick "acting as my stop loss"?" This is exactly what the trailing stop does, for every tick increase in profit that the current price is, the trailing stop will move to maintain no less than 10 ticks behind the highest profit level achieved, it will not go backwards. You can certainly test this on the sim101 account.
You may want to further increase your knowledge of strategies by reviewing the "Managed approach" help guide section. Even though you are using the strategy builder, the strategy builder follows the managed approach: https://ninjatrader.com/support/help...d_approach.htm "The Managed approach in NinjaScript is designed to offer the greatest ease of use for beginner to intermediate programmers. The order methods are wrapped in a convenience layer that allows you to focus on your system's trading rules, leaving the underlying mechanics of order management and the relationships between entry orders, exit orders, and positions to NinjaTrader. This approach is best suited for simple to moderate order complexity, and can be further broken down into a Basic/Common Managed approach and a more Advanced Managed approach..."Paul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by r68cervera, Today, 05:29 AM
|
0 responses
2 views
0 likes
|
Last Post
by r68cervera
Today, 05:29 AM
|
||
Started by geddyisodin, Today, 05:20 AM
|
0 responses
3 views
0 likes
|
Last Post
by geddyisodin
Today, 05:20 AM
|
||
Started by JonesJoker, 04-22-2024, 12:23 PM
|
6 responses
33 views
0 likes
|
Last Post
by JonesJoker
Today, 05:14 AM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
12 responses
3,239 views
0 likes
|
Last Post
by Leafcutter
Today, 05:08 AM
|
||
Hi
by AveryFlynn
Started by AveryFlynn, Today, 04:57 AM
|
0 responses
6 views
0 likes
|
Last Post
by AveryFlynn
Today, 04:57 AM
|
Comment