Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
fib scrept
Collapse
X
-
Tags: None
-
Hello marcos_vitorino,
Thanks for opening the thread.
You may loop through drawing objects to find a specific Fibonacci Retracement and you can reference the PriceLevels within that Fibonacci Retracement Drawing Object.
Attached is some example code that will loop through drawing objects on a chart, find a Fibonacci Retracement and then print the index of the each price level as well as the percentage and the price at that level.
Running this code, you will see that index 3 is 50%.Code:private FibonacciRetracements myFibRet = null; protected override void OnBarUpdate() { if(State == State.Historical) return; foreach (DrawingTool draw in DrawObjects) { // Finds line objects that are attached globally to all charts of the same instrument if (draw is DrawingTools.FibonacciRetracements) { myFibRet = draw as DrawingTools.FibonacciRetracements; } } ClearOutputWindow(); if(myFibRet != null) for(int i = 0; i < myFibRet.PriceLevels.Count; i++) { Print(i + " " + myFibRet.PriceLevels[i].Value + " " + myFibRet.PriceLevels[i].GetPrice(myFibRet.StartAnchor.Price, myFibRet.EndAnchor.Price-myFibRet.StartAnchor.Price, true)); } }
You may reference our publicly available documentation on the items used below.
FibonacciRetracements Object - https://ninjatrader.com/support/help...tracements.htm
Looping through Drawing Objects - https://ninjatrader.com/support/help...rawobjects.htm
PriceLevels - https://ninjatrader.com/support/help...ricelevels.htm
Please let me know if you have any questions.
-
Fib Level on chart.
Thank you for your help...
I not find any sample on blog ..
I try you code but it no show level on Ninja script output... and no draw a fib on my chart..
Display on Ninha Scrip output.:
Disabling NinjaScript strategy 'SampleFibLevel/121472574'
Enabling NinjaScript strategy 'SampleFibLevel/121472574' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes
my code.
attach fileAttached FilesLast edited by marcos_vitorino; 11-22-2017, 02:51 PM.
Comment
-
Hello marcos_vitorino,
The code I attached works. Please see here: https://www.screencast.com/t/dJvcB2EBOIxG
It does not draw a Fibonacci Retracement, it looks for one already drawn.
If you would like to get the price levels from a Fibonacci Retracement drawn from code, I will refer you to the sample that my colleague AlanS has provided with your correspondence over email.
I'll include links to our publicly available documentation on the Fibonacci Retracements drawing tool and on the PriceLevels collection for further reference.Code:FibonacciRetracements myRetracements; protected override void OnBarUpdate() { if (CurrentBar < 10) return; myRetracements = Draw.FibonacciRetracements(this, "fibby", true, 10, High[10], 3, Low[1]); foreach(PriceLevel p in myRetracements.PriceLevels) { Print(p.GetPrice(High[10], myRetracements.EndAnchor.Price - myRetracements.StartAnchor.Price, false)); } }
PriceLevels - https://ninjatrader.com/support/help...ricelevels.htm
Draw.FibonacciRetracements() - https://ninjatrader.com/support/help...tracements.htm
Please let me know if I may be of further help.
Comment
-
Goi it , exactly what I was looking for, in my code I already have fib thank you
Last edited by marcos_vitorino; 11-23-2017, 09:36 AM.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
88 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
48 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
30 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
34 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
68 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment