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
Retracement
Collapse
X
-
Retracement
Hi, I am trying to create this strategy, where price has the same slope (positive/negative) as KAMA over some bars (set by user), but all of a sudden price goes on the opposite direction and comes close to KAMA by some ticks (set by user), and then again goes in the previous direction. I want to enter long when the price retraces and goes above the highest price before breaking the trend. I can't figure out what do to do. Some suggestions would be very helpful.
Tags: None
-
Hello fawzanalim,
Thank you for your post.
The IsRising method would report true if the CurrentBar is greater than the Last bar. To make a range of bars which you check if they are rising, you would need to make a price condition. The reverse would be the IsFalling method, which would report true if the CurrentBar is less than the previous bar.
For example, checking if the Close 0 Bars Ago is greater than Close 1 BarsAgo would replicate the IsRising. In the same condition, you could add more of those price conditions like Close 1 BarsAgo is greater than Close 2 bars ago and so on. This would create a range of Rising statements.
The same would apply with Indicators, you would need to create a new condition for each 1 bar span of time you want to compare.
So you'd want to set up logic that would check if the last X number of bars have been rising followed by one falling for both the KAMA and the data series, save the high of the last rising bar (which would be the one previous to when it starts falling), then monitor for it to start rising again and when it reaches/exceeds that high you saved to a variable, then enter.
I look forward to being of further assistance.Kate W.NinjaTrader Customer Service
-
Thanks for the reply.
I understood the logic. But what if there's a falling bar between two rising bars and the trend is upwards. Like in the first picture, First white line.
Comment
-
Hello fawzanalim,
Thank you for your reply.
You would have to decide yourself how you would want to handle that within your logic. For example, you could loop through the last X number of bars and if enough of them in your view are going up, then call that a rising action. For example, create a loop that loops through the last 10 bars and checks whether they are up or down bars and depending on what they are, adds that to a count. Then, say, if there's x number of up bars counted, say, 7 or more and the last bar is an up bar, that's rising. This could get fairly complex and could not be done in something like the Strategy . We cannot design your logic for you, so I would recommend if you're struggling that you look into enlisting the assistance of a third party NinjaScript Consultant to assist you.
If you are interested in services in having the code written for you, I can have a representative of our EcoSystem reach out with more information on NinjaScript consultants who will be happy to do so.
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by yertle, Yesterday, 08:38 AM
|
7 responses
28 views
0 likes
|
Last Post
by yertle
Today, 12:15 AM
|
||
Started by bmartz, 03-12-2024, 06:12 AM
|
2 responses
21 views
0 likes
|
Last Post
by bmartz
Today, 12:11 AM
|
||
Started by funk10101, Today, 12:02 AM
|
0 responses
5 views
0 likes
|
Last Post
by funk10101
Today, 12:02 AM
|
||
Started by gravdigaz6, Yesterday, 11:40 PM
|
1 response
9 views
0 likes
|
Last Post Yesterday, 11:49 PM | ||
Started by MarianApalaghiei, Yesterday, 10:49 PM
|
3 responses
11 views
0 likes
|
Last Post Yesterday, 11:33 PM |
Comment