Custom Indicator: SMA * LastPrice

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #218686 quote
    antogargi
    Participant
    New

    Hi All, Is there anyone can help me with the code to create a custom indicator able to return the product between Simple Moving Average (dynamic setting of the period) and the last available price (e.g. close price)?

    #218690 quote
    JS
    Participant
    Veteran

    Hi @antogargi

     

    Can you tell us a bit more about what you’re looking for?

    What do you mean by the product between an SMA and the closing price?

    #218691 quote
    robertogozzi
    Moderator
    Master

    Is this one what you need?

    return average[20,0](close) * close AS "Last price multiplied by its average"
    #218699 quote
    antogargi
    Participant
    New

    Hi @Roberto, thanks a lot

    My request might be incorrect

    Following the attached screenshot:

    1. I’ve created the custom indicator (the orange indicator in the volume graph named “Last price multiplied by its average”, left-hand side)
    2. the expected result should be: 2.008,9 (SMA) * 132,23 (Price) = 265.636,847
    3. the orange indicator returns instead 18.299

    Does the code you’ve shared correspond to the point #2?

    Screenshot-2023-08-07-at-22.29.37.png Screenshot-2023-08-07-at-22.29.37.png
    #218701 quote
    JS
    Participant
    Veteran

    Hi,

     

    The value of the orange indicator is the result of:

    Average[20](Close) * Close = 18.299

     

    You want to calculate:

    Average[20](Volume) * Close = 265,636,847

     

    So, for the orange indicator you should use “Volume” for the calculation of the average and not the “Close”…

    #218702 quote
    antogargi
    Participant
    New

    Hi @Js, it works, great 🙂

    Thanks a lot!

    Antonio

    JS thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Custom Indicator: SMA * LastPrice


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
antogargi @antogargi Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by antogargi
2 years, 7 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 08/07/2023
Status: Active
Attachments: 1 files
Logo Logo
Loading...