Indicateur avec 2 moyennes mobiles

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #243064 quote
    etrading
    Participant
    New

    Bonjour,
    J’ai essayé de créer un indicateur basé sur deux moyennes mobiles, qui est, je l’avoue, très, très rudimentaire.

    // MM M9-25
    return Average[9](close) as “M9”,Average[25](close) as “M25”

    Je n’ai pas trouvé le code permettant de spécifier le type de moyenne mobile à savoir : simple, exponentiel ou pondéré et surtout où l’insérer.

    Je souhaite également qu’une croix/cercle apparaisse sur l’indicateur, lorsque les moyennes mobiles se croisent.
    Idéalement, une croix/cercle bleue devra apparaître sous le croisement haussier de la MM9 avec la MM25 ou une croix/cercle noire au-dessus du croisement baissier de la MM9 avec la MM25.

    Merci par avance pour votre aide.

    Au plaisir de vous lire
    etrading

    #243066 quote
    JS
    Participant
    Senior

    The syntax for calculating an average is: Average[N,M](Price)

    • N = number of periods over which the average is calculated
    • M = type of average:
      • 0 = Simple Moving Average (SMA)
      • 1 = Exponential Moving Average (EMA)
      • 2 = Weighted Moving Average (WMA)
      • 3 = Wilder’s Smoothing
      • 4 = Triangular
      • 5 = End Point
      • 6 = Time Series
      • 7 = Hull
      • 8 = ZeroLag

    In your example: M9 = Average[9,0](Close) M25 = Average[25,0](Close)

    If M9 crosses over M25 then

        DrawArrowUp(BarIndex, Low) Coloured(0,0,255)

    EndIf

    If M9 crosses under M25 then

        DrawArrowDown(BarIndex, High) Coloured(255,0,0)

    EndIf

    I am using “arrows” with custom colors here, but you can always adjust this to your preferences…

    Iván González and robertogozzi thanked this post
    #243067 quote
    JS
    Participant
    Senior

    As an addition: When you want to display the averages on your chart, you can use the following as the last line in your code: Return M9 as “M9” Coloured(“Red”), M25 as “M25” Coloured(“Green”)

    #243115 quote
    etrading
    Participant
    New
    Excellent ! This is exactly what I was looking for. Many thanks for your time JS !   Have a nice day DD
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Indicateur avec 2 moyennes mobiles


General Trading: Market Analysis & Manual Trading

New Reply
Author
author-avatar
etrading @etrading Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by etrading
1 year ago.

Topic Details
Forum: General Trading: Market Analysis & Manual Trading
Language: English
Started: 01/24/2025
Status: Active
Attachments: No files
Logo Logo
Loading...