Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

fib scrept

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    fib scrept

    Hi,
    someone have a part of script or a sample file to show how user fib number..
    I try put limit order on 50% fib...

    Click image for larger version

Name:	Capture.png
Views:	1
Size:	119.9 KB
ID:	908775
    Last edited by marcos_vitorino; 12-26-2017, 08:17 PM.

    #2
    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));
    		}
    }
    Running this code, you will see that index 3 is 50%.

    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

    Comment


      #3
      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 file
      Attached Files
      Last edited by marcos_vitorino; 11-22-2017, 02:51 PM.

      Comment


        #4
        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));
        
            }
        
        }
        I'll include links to our publicly available documentation on the Fibonacci Retracements drawing tool and on the PriceLevels collection for further reference.

        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


          #5
          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 wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          26 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, 02-22-2024, 01:11 AM
          5 responses
          32 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, Yesterday, 09:53 PM
          2 responses
          49 views
          0 likes
          Last Post wzgy0920  
          Started by Kensonprib, 04-28-2021, 10:11 AM
          5 responses
          192 views
          0 likes
          Last Post Hasadafa  
          Started by GussJ, 03-04-2020, 03:11 PM
          11 responses
          3,235 views
          0 likes
          Last Post xiinteractive  
          Working...
          X