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
Draw fib retracement using swing indicator
Collapse
X
-
Draw fib retracement using swing indicator
I have this bit of code that outputs swing highs and lows. Everything works fine when strength is set to 10 and 20. If I set the strength to 50, I get this error and the strategy shuts down. Testing is currently being done on live data.
3 PhotosTags: None
-
Hi Kate,
Thanks for your reply. in the attached photo, the value can be seen where it says "occurred x bars ago"1 Photo
Comment
-
Hello jableshank,
Thank you for your reply.
To clarify, we want to try printing that LowBarsAgo value before that "The low at" print so we know what it is before using it as the bars ago to retrieve the low from. If that's coming out to a negative number, since SwingLowBar returns a value of -1 if a swing point is not found within the look back period, and you try to use that to get the Low of a bar in the future that doesn't exist yet, you're going to get an error. If you print that value do you see it printing -1 just before the error occurs?
Thanks in advance; I look forward to assisting you further.Kate W.NinjaTrader Customer Service
Comment
-
Print(Swing(50).SwingLowBar(0, 1, 1000)); is returning -1. However Print(Swing(20).SwingLowBar(0, 1, 1000)); returns 41. I'm not too sure why that is as I can set the Swing indicator strength to 50 on the chart and it clearly shows the highs and lows.
Comment
-
Hello jableshank,
Thank you for your reply.
The greater the Strength value the longer it looks back to find a swing low/high, but the swings also last longer the higher the strength. If you add a Swing set to 50 to a chart, you'll see these really long swing plots - it's simply more unlikely that both a swing high or low will be found in that period. I would suggest printing something else if no swing is found, perhaps just a message saying "no swing low found" or something to that effect. But you'll have to check what those BarsAgo values are before printing them or every time no swing low or swing high is found you'll get this error.
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 bill2023, Yesterday, 08:21 AM
|
2 responses
14 views
0 likes
|
Last Post
by bill2023
Today, 01:04 AM
|
||
Started by ynoldsany, Today, 01:00 AM
|
0 responses
2 views
0 likes
|
Last Post
by ynoldsany
Today, 01:00 AM
|
||
Started by Carolscogginsi, Yesterday, 10:45 PM
|
0 responses
7 views
0 likes
|
Last Post Yesterday, 10:45 PM | ||
Started by RaddiFX, Yesterday, 10:15 AM
|
2 responses
15 views
0 likes
|
Last Post
by RaddiFX
Yesterday, 09:33 PM
|
||
Started by patrickmlee007, Yesterday, 09:33 AM
|
2 responses
19 views
0 likes
|
Last Post Yesterday, 08:56 PM |
Comment