fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Draw line object block to represent calculation on screen

    Questions & Answers
    3
    6
    157
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      Gilles last edited by

      I would like to draw a line using the charts and objects blocks to represent the following calculation on the screen:

        local i;
          local ii = Period;
          local LastPeriod;
      
          if period == source:size()-1 
          then
              LastPeriod = true;
          else
              LastPeriod = false;
          end
      
          while ii > 0 do
      
              if not(LastPeriod) 
              then
                  ii = 0;
              else
                  ii = ii-1; 
              end
      
              local Sum = 0;
              local SumW = (Period+2)*(Period+1)/2;
      
              for i=0,Period,1 do
      
                  Sum = Sum + (Period-i+1) * source[period-i];
      
                  if Redraw 
                  then
                      if i <= source:size()-1 - period and i > 0 
                      then
                          Sum = Sum + (Period-i+1) * source[period+i];
                          SumW = SumW + (Period-i+1);
                      end
                  end 
              end
      
              Line[period] = Sum / SumW;
      

      How can I do this ?
      Can you help me?

      Thank you 🙂 !

      1 Reply Last reply Reply Quote 0
      • G
        Gilles last edited by

        Hi, i just need to know if an example exists to do it. Thank you for your answer.

        1 Reply Last reply Reply Quote 0
        • l'andorrà
          l'andorrà last edited by

          I wish I were a programmer, but I'm not. If you can explain what you need without that code, I will glad to help you. 🙂

          (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

          (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

          (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

          G 1 Reply Last reply Reply Quote 0
          • G
            Gilles @l'andorrà last edited by

            @l-andorrà Yes, of course, I'll explain how it works to get the expected result.

            Example with a period of 10 (configurable).
            The idea here is to apply a weighting coefficient to each encountered price as we go back in time. Then we'll manipulate this data to get our result.

            In this example, we go back to progressively gather all the prices to multiply them by a weighting coefficient until we reach the closing price 10 periods ago.

            Objective = we're trying to determine the price of the current period.

            Step 1
            Determine each weighted price to add them up at the end.

            closing price of period-1 = 14973.54 * 1 = 14973.54
            closing price of period-2 = 14934.54 * 2 = 29869.08
            closing price of period-3 = 14919.04 * 3 = 44757.12
            closing price of period-4 = 14919.03 * 4 = 59676.12
            closing price of period-5 = 14933.02 * 5 = 74665.1
            closing price of period-6 = 14935.03 * 6 = 89610.18
            closing price of period-7 = 14958.52 * 7 = 104709.64
            closing price of period-8 = 14,975.04 * 8 = 119800.32
            closing price of period-9 = 14,974.52 * 9 = 134770.68
            closing price of period-10 = 14,974.03 * 10 = 149740.3

            Sum of weighted prices = 822572.08

            Step 2
            Add up all the weighting coefficients as follows:
            (1+2+3+4+5+6+7+8+9+10) = 55

            Step 3 = result = value of the price for the current period
            822572.08 / 55 = 14955.85

            That's it, so if you could help me model this with the blocks, that would be great.
            Thank you 🙂 !

            1 Reply Last reply Reply Quote 0
            • l'andorrà
              l'andorrà last edited by

              You can do that with a loop by using several blocks. However, I don't fully understand the math implied. Why are those close prices multiplied by those higher factors? Isn't it distorting the average value? I'm not good at math, though. 🙂

              (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

              (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

              (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

              1 Reply Last reply Reply Quote 0
              • A
                Alan.paredes2 last edited by

                explica la lógica amigo para entender, que representa ese calculo

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post

                Online Users

                F
                A
                H
                A
                S
                M

                19
                Online

                146.7k
                Users

                22.4k
                Topics

                122.6k
                Posts

                Powered by NodeBB Forums | Contributors