Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Specific Fibonacci retracement levels for various timeframes

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

    Specific Fibonacci retracement levels for various timeframes

    Hello fellow humans,
    I'm in need of assistance. I'm working on a retracement strategy which can use Fibonacci retracements as retracement levels.
    More specifically only certain price levels i.e. percentages and over different time periods.
    I'm able to work with Draw.FibonacciRetracements and the respective access to the PriceLeves collection. What I'm struggling with are mainly the timeframes.
    My current approach is to call Draw.FibonacciRetracements on each bar update, disabling (depending on the setttings) unwanted price levels, color the plotted ones as configured and then add the price value of the selected level to retrace on to the respective series. The main method looks like this:


    private void UpdateFibLevels()
    {
    FibRetracers.Add(FibRetraceLevel.Monthly, Draw.FibonacciRetracements(this, "Monthly", true, 10, Low[10], 0, High[0]));
    FibRetracers.Add(FibRetraceLevel.Weekly, Draw.FibonacciRetracements(this, "Weekly", true, 10, Low[10], 0, High[0]));
    FibRetracers.Add(FibRetraceLevel.Daily, Draw.FibonacciRetracements(this, "Daily", true, 10, Low[10], 0, High[0]));
    FibRetracers.Add(FibRetraceLevel.QuarterDay, Draw.FibonacciRetracements(this, "QuarterDay", true, 10, Low[10], 0, High[0]));
    FibRetracers.Add(FibRetraceLevel.Hourly, Draw.FibonacciRetracements(this, "Hourly", true, 10, Low[10], 0, High[0]));
    FibRetracers.Add(FibRetraceLevel.QuarterHour, Draw.FibonacciRetracements(this, "QuarterHour", true, 10, Low[10], 0, High[0]));
    FibRetracers.Add(FibRetraceLevel.FiveMin, Draw.FibonacciRetracements(this, "FiveMin", true, 10, Low[10], 0, High[0]));

    foreach (KeyValuePair<FibRetraceLevel, FibonacciRetracements> kvp in FibRetracers)
    {
    foreach (PriceLevel plvl in kvp.Value.PriceLevels)
    {
    if (plvl.Value == 61.8)
    {
    if (!ShowFib61)
    plvl.IsVisible = false;
    else
    plvl.Stroke.Brush = FibBrushes[kvp.Key];
    }
    else if (plvl.Value == 76.4)
    {
    if (!ShowFib76 && RLevel != RetraceLevel.Fibonacci)
    plvl.IsVisible = false;
    else
    plvl.Stroke.Brush = FibBrushes[kvp.Key];

    if (RLevel == RetraceLevel.Fibonacci && FibRLevel == kvp.Key)
    RSeries[0] = plvl.GetPrice(kvp.Value.StartAnchor.Price, kvp.Value.EndAnchor.Price - kvp.Value.StartAnchor.Price, false);
    }
    else
    plvl.IsVisible = false;
    }
    }
    }​

    The startBarsAgo, startY etc. params are currently placeholder. Not only am I stuck how to get the respective timeframes, I'm also not sure whether this is the right approach in the first place.
    The reason I want to use the Draw.FibonacciRetracements instead of calculating the price levels manually, is to make use of the drawn elements.

    #2
    Hello Human#102,

    Thank you for your post.

    You mention you are "stuck how to get the respective timeframes" and also you aren't sure whether this is the right approach. By timeframes, are you referring to the startBarsAgo, startY, etc? What values exactly are you stuck on getting? When are you planning to draw these retracements, or to word it differently, under what conditions do you plan to determine where and when these will be drawn? Or are you planning on detecting a manually drawn object and obtaining the data from the manually drawn object then modifying its price levels? Please clarify exactly what you are hoping to achieve as well as the behavior you currently see when testing your script and how that differs from what you are expecting it to do so I may better understand and assist you.

    I look forward to your reply.

    Comment


      #3
      Hi Emily,
      What I in general want to accomplish is to calculate fibonacci retracement levels of different timeframes/ranges to use them in code and draw them onto the chart. My idea was to use Draw.FibonacciRetracements and hide/disable the levels I'm not interested in. However, the current approach does not work since I have to wait for enough bars to be available. E.g. If I want the monthly levels, I'd have to wait for a month until enough bars are available. Is there a way I can look into past data? And is there perhaps a different approach more efficient or ideal to accomplish what I want, like a simple/straight forward way to calculate & draw specific levels?

      Comment


        #4
        Originally posted by Human#102 View Post
        Hi Emily,
        What I in general want to accomplish is to calculate fibonacci retracement levels of different timeframes/ranges to use them in code and draw them onto the chart. My idea was to use Draw.FibonacciRetracements and hide/disable the levels I'm not interested in. However, the current approach does not work since I have to wait for enough bars to be available. E.g. If I want the monthly levels, I'd have to wait for a month until enough bars are available. Is there a way I can look into past data? And is there perhaps a different approach more efficient or ideal to accomplish what I want, like a simple/straight forward way to calculate & draw specific levels?
        To work with different timeframes, you could call AddDataSeries() to add each desired timeframe programmatically for your calculations:


        Like you said, for monthly levels you would need enough bars to calculate monthly. You could use the AddDataSeries() overload that allows you to specify a barsToLoad value or you would potentially need to use a larger number of days to load in your Data Series settings to ensure enough data is added for the primary series/first series added for an instrument so that data is loaded and available for other added series for that same instrument. There is no way to "look into past data" though if you have enough data added in your data series you can look into that data that is loaded. You could also add checks to make sure there are enough bars loaded in the data series you are accessing to prevent errors:


        For more details on multi-time frame scripts:


        As for different approaches, I suggest checking out other scripts that draw Fibonacci Retracements for ideas on different methods to accomplish different goals. You may be able to implement some of the same ideas in your script or decide if those approaches do not work for you and your end goal.

        For example, the following scripts are publicly available on our NinjaTrader Ecosystem website:Here are the results from searching 'Fibonacci' on the app share:
        Here is a basic guideline of how to import NinjaScript add-ons in NinjaTrader 8:

        Note — To import NinjaScripts you will need the original .zip file.

        To Import:
        1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
        2. From the Control Center window select the menu Tools > Import > NinjaScript Add-on...
        3. Select the downloaded .zip file
        4. NinjaTrader will then confirm if the import has been successful.

        Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'

        Once installed, you may add the indicator to a chart by:
        • Right-click your chart > Indicators... > Select the Indicator from the 'Available' list on the left > Add > OK

        Here is a short video demonstration of the import process:
        Please let me know if I can be of further assistance.

        The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

        Comment


          #5
          Thank you for this great response! Resolved the issues I faced. ^^

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          635 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          364 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          106 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          567 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          571 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X