Media Candele Giornaliere (Daily Candle Average)

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #193328 quote
    byT77
    Participant
    New

    Buongiorno,

    Chiedo cortesemente un piccolo aiuto.

    Vorrei identificare il valore di una media eseguita sulle candele giornaliere, rispettando i giorni della settimana.

    Semplifico con un piccolo esempio:

    Supponiamo che la Candela di Oggi corrisponda al giorno della settimana “1=Lunedì” e che io voglia la media solo dei giorni “1” per “x” tempo. Escludendo la candela corrente.

    N = Average[21](giorno=1)

    Naturalmente con la condizione “IF” per calcolare di giorno in giorno in automatico.

    In attesa di un cortese riscontro, ringrazio anticipatamente.

    Good morning,

    I kindly ask for a little help.

    I would like to identify the value of an average performed on daily candles, respecting the days of the week.

    Let me simplify with a small example:

    Let’s suppose that Today’s Candle corresponds to the day of the week “1 = Monday” and that I want the average of days “1” only for “x” time. Excluding the current candle.

    N = Average [21] (day = 1)

    Of course with the “IF” condition to calculate day by day automatically.

    Waiting for a kind reply, thank you in advance.

    #193456 quote
    JS
    Participant
    Senior

    Normally you can use:

    If CurrentDayOfWeek = 1 then

    Y = Close

    EndIf

    But when I use CurrentDayOf Week = 1 nothing happens

    CurrentDayOfWeek = 2 returns Monday

    CurrentDayOfWeek = 3 returns Tuesday

    ???
    #193605 quote
    byT77
    Participant
    New
    Thank you so much. Have a nice day
    #193903 quote
    robertogozzi
    Moderator
    Master
    Maybe this is what you were looking for (only a simple average can be calculated):
    ONCE Periods = 20
    FOR i = 1 TO 5             //5 days (Monday to Friday)
       $MyTotal[i]   = 0
       $MyAverage[i] = 0
       $MyTally[i]   = 0
    NEXT
    ALLscanned = 0
    IF BarIndex > (Periods * 5) THEN
       FOR j = 1 TO BarIndex[1]
          FOR i = 1 TO 5
             IF i = OpenDayOfWeek[j] THEN
                IF $MyTally[i] < Periods THEN
                   $MyTally[i]   = $MyTally[i] + 1
                   $MyTotal[i]   = $MyTotal[i] + close[j]
                   $MyAverage[i] = $MyTotal[i] / $MyTally[i]
                   IF $MyTally[i] = Periods THEN
                      ALLscanned = ALLscanned + 1
                   ENDIF
                ENDIF
                break
             ENDIF
          NEXT
          IF ALLscanned = 5 THEN
             break
          ENDIF
       NEXT
    ENDIF
    x1 = $MyAverage[1]
    x2 = $MyAverage[2]
    x3 = $MyAverage[3]
    x4 = $MyAverage[4]
    x5 = $MyAverage[5]
    RETURN x1 AS "Mon",x2 AS "Tue",x3 AS "Wed",x4 AS "Thu",x5 AS "Fri"
    #193907 quote
    byT77
    Participant
    New
    Perfect! Thank you so much. 🙂
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Media Candele Giornaliere (Daily Candle Average)


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
byT77 @byt77 Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by byT77
3 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/17/2022
Status: Active
Attachments: 3 files
Logo Logo
Loading...