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)?
JSParticipant
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?
Is this one what you need?
return average[20,0](close) * close AS "Last price multiplied by its average"
Hi @Roberto, thanks a lot
My request might be incorrect
Following the attached screenshot:
- I’ve created the custom indicator (the orange indicator in the volume graph named “Last price multiplied by its average”, left-hand side)
- the expected result should be: 2.008,9 (SMA) * 132,23 (Price) = 265.636,847
- the orange indicator returns instead 18.299
Does the code you’ve shared correspond to the point #2?
JSParticipant
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”…
Hi @Js, it works, great 🙂
Thanks a lot!
Antonio