Notifications
Clear all

AOTS Stacked Bar

Mike
 Mike
(@vanguardai)
Co-Founder Admin

Using multiple moving averages to assess a trend is a simple but powerful way to make sure you don't trade against a trend. However for some people like me, who wants the benefit of trend confirmation but don't necessarily use all the moving average levels for daily trading, I'd want to keep my charts simple and clean and we can do that with VAI. We can manipulate the way data to be displayed this way:

Green = uptrend and everything is aligned
Red = downtrend and everything is aligned
Gray = nothing is aligned

I simply dragged down the indicator window to make it as low key as possible.

Feel free to add more moving averages or to change them up into EMA or ALMA. Code is below.

//AOTS Stackedbar

//Set variables
//You can change the periods and averages used
Set SMA1 = sma(close,20)
Set SMA2 = sma(close,50)
Set SMA3 = sma(close,100)

//Set conditions
Set uptrend = sma1 > sma2 and sma1 > sma3 and sma2 > sma3
Set downtrend = sma3 > sma2 and sma3 > sma1 and sma2 > sma1
set notrend = uptrend = false and downtrend = false

set notrend = if(notrend,1,0)
Set uptrend = if(uptrend,1,0)
set downtrend = if(downtrend,1,0)
plot(notrend,stackedbar,gray,signal)
plot(uptrend,stackedbar,green,signal)
plot(downtrend,stackedbar,red,signal)

1628936488-aots-stackedbar.png
Quote
Topic starter Posted : 14/08/2021 6:21 pm
Share: