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!
See more
See less

Partner 728x90

Collapse

Fibonacci retracement calculation

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

    Fibonacci retracement calculation

    Hello,

    I would like to add a Fibonacci calculation to my indicator. The idea is to determine where is actually close price in the chart regarding its fibo position.

    For exemple, the low 0% will be the lowest price of the bar in the trend. 100% will be the close price from one of my calculation.

    I need a method and the formulas to calculate the % value of the last close price that just came out ( i suppose that's CurrentBar the first bar at the right side of the chart)

    Probably, the difference between 100% - 0%
    Close[0]/ (100 - 0)


    I dont want to draw the fibo retracement in the chart, i only want to get the position in % of the last traded bar.




    First i need the fibo formulas and second i saw a few codes in the tutorial and i wonder if they could be useful.

    Returns R3 value
    FibonacciPivots(
    PivotRange
    pivotRangeType
    ,
    HLCCalculationMode
    priorDayHLC
    ,
    double
    userDefinedClose
    ,
    double
    userDefinedHigh
    ,
    double
    userDefinedLow,
    int
    width
    ).R3[
    int
    barsAgo
    ]
    FibonacciPivots(
    ISeries
    <
    double
    >
    input
    ,
    PivotRange
    pivotRangeType
    ,
    HLCCalculationMode
    priorDayHLC
    ,
    double
    userDefinedClose
    ,
    double
    userDefinedHigh
    ,
    double
    userDefinedLow,
    int
    width
    ).R3[
    int
    barsAgo
    ]

    What is R3? is it 2.62? I would like to find a code i could do some reverse calculation.

    According to pivots R3 is
    r3 = pp + 2 * (currentHigh - currentLow);
    But i dont think that its correct because i get a 1 pts difference between pivots and fibo retracement at 2.62.

    ty

    #2
    Hello frankduc,

    Thanks for your post.

    Please note that the formatting of the post is not clear on what you are trying to show.

    The pivots would be calculated on the first bar of the session, based on data from the prior day and would not change through the current day.

    The FibonacciPivots indicator pivot point, PP is calculated as pp = (currentHigh + currentLow + currentClose) / 3;

    The FibonacciPivots indicator, R3 is calculated as r3 = pp + (currentHigh - currentLow) * 1.000;

    If the pivots are being calculated from Daily bars then that calculation may include the contracts settlement price in place of the contracts close price if you are looking at futures instruments

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I gave the fibo pivots as an exemple, i thought it was the same formula for both fibo pivots and fibo retracement?

      What i want is the formulas for fibo retracement. Suppose 2880 is the last price. The low will be my lowest low on my index. The high will be the highest high and the close will be my return calculation. Lets call it X. Assuming its the same formulas as pivots but i dont think it is.
      Where is 2880, is it 2.2%, 2.62%, etc? That's my goal.

      Am i wrong?
      Last edited by frankduc; 06-10-2019, 12:51 PM.

      Comment


        #4
        Hello frankduc,

        Thanks for your reply and clarification.

        To determine a fib price value, from a fib sequence, you would take the High and subtract the low for the range. You then multiply the range times the ratio of interest (or reciprocal if drawing the other way) then add that result to the Low for the end value.

        Examples: High = 7453.50, Low = 7257.50

        50 % = (High - Low) *.0.500 + Low = (7453.5 - 7257.5) * 0.500 + 7257.5 = 7355.0 (50%)
        61.6% = (High - Low) *.0.618 + Low = (7453.5 - 7257.5) * 0.618 + 7257.5 = 7378.628 (61.8%)


        I think what you are looking for is to determine what % the current price is to the Fibs High to Low. You would do relatively the same thing(using the above high, low and 61.8% value):

        Close% = (Close - low) / (High - Low) = ((7453.5 - 7257.2) / (7378.628 - 7257.2)) * 100 = 61.8%
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          I thought that was the answer too.
          When i try 2893.51- 2886.71 = 6.8
          2890.94 - 2886.71 = 4.23
          6.8/ 4.23 = 1.6075
          But the fibo retracement line on the chart return exactly 1.61 = 2893.51 I am missing 0.0025?

          Comment


            #6
            Hello frankduc ,

            Thanks for your reply.

            Try 4.23 / 6.8 = 0.6221
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I'm not looking to find % between 0 and 100% i am only interested in 100% above. Still 1/0.6221 = 1.6074
              Maybe NT round the numbers?

              Comment


                #8
                Hello frankduc,

                Thanks for your reply.

                I do not know where the rounding error would be.
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by elderan, Today, 08:03 PM
                0 responses
                2 views
                0 likes
                Last Post elderan
                by elderan
                 
                Started by algospoke, Today, 06:40 PM
                0 responses
                10 views
                0 likes
                Last Post algospoke  
                Started by maybeimnotrader, Today, 05:46 PM
                0 responses
                9 views
                0 likes
                Last Post maybeimnotrader  
                Started by quantismo, Today, 05:13 PM
                0 responses
                7 views
                0 likes
                Last Post quantismo  
                Started by AttiM, 02-14-2024, 05:20 PM
                8 responses
                169 views
                0 likes
                Last Post jeronymite  
                Working...
                X