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.
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.JimNinjaTrader Customer Service
-
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.
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.JimNinjaTrader Customer Service
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 pechtri, 06-22-2023, 02:31 AM
|
10 responses
124 views
0 likes
|
Last Post Today, 12:03 AM | ||
Started by judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
59 views
0 likes
|
Last Post
by DynamicTest
Yesterday, 08:25 PM
|
||
Started by ScottWalsh, Yesterday, 06:52 PM
|
4 responses
36 views
0 likes
|
Last Post
by ScottWalsh
Yesterday, 07:40 PM
|
||
Started by olisav57, Yesterday, 07:39 PM
|
0 responses
7 views
0 likes
|
Last Post
by olisav57
Yesterday, 07:39 PM
|
||
Started by trilliantrader, Yesterday, 03:01 PM
|
2 responses
22 views
0 likes
|
Last Post
by helpwanted
Yesterday, 07:25 PM
|
Comment