How Can We Help?

Plotting Trading Signals

You are here:
< All Topics

VAI Script allows you to plot trading signals on your chart with a number of customizable options.

plot(variable_name,series_type,series_color,pane_name)

For plotting lines with shaded area:
plotrange(variable_name1,variable_name2,series_color,pane_name)

Series Types
Buy – draws series point values (if condition is true) as a triangle market below the LOW price
Sell – draws series point values (if condition is true) as an inverted triangle market above the HIGH price
line – draws series values in line chart
spline – draws series values in spline chart
bar – draws series values in bar chart

Series_color
Red, Blue, Green, Orange, Violet, etc. Putting in “any” will let the chart decide on what color to apply according to the current theme.

Pane_name
Main – Draw the series values in the main page where the candle stick prices are plotted. Any other names will create an additional pane and group all series on the same name pane below the main pane.

Please note that Buy/Sell signals can be also plotted in other panes by extending the pane syntax with the variable.

Example:
plot(MacdSignal,buy,green,macdpane:MacdSignal).

It means Buy labels will be plotted in the MACD pane and attaching the Buy/Sell signals to MacdSignal values.

Sample Script

//Buy when MACD Line crossed up, otherwise sell

//set variables
set macd_line = MACD(13, 26, 9, EXPONENTIAL)
set macd_signal =  MACDSIGNAL(13, 26, 9, EXPONENTIAL)
set hist = macd_line – macd_signal

//Buy condition
Set Buy=  CROSSOVER(macd_line , macd_signal)

//Sell Condition
Set Sell = CROSSOVER(macd_signal, macd_line)

//Plot MACD
plot(macd_line, line, any, macd)
plot(macd_signal, line, any, macd)
plot(hist, bar, any, macd)

//Plot Buy and sell signals
Plot(Buy, Buy, Green, main)
Plot(Sell, Sell, Red, main)

//In the event of multiple succeeding buy signals, use this plot function if you want to only plot the signals per pair.
Plotbuysell (buy, sell, green, red, main)

Table of Contents