Creating custom scr...
 
Notifications
Clear all

Creating custom script

13 Posts
2 Users
0 Likes
2,271 Views
pjm
 pjm
(@pjm)
Posts: 13
Active Member User
Topic starter
 

Hello to all.

I'm reading on the Knowledge-Base and trying to copy-paste this TStop script (shown below) to observe how it will show in my chart, but it returns undefine variable error. Hoping anyone can help about resolving this error.

//Buy when RSI crosses 30 and sell if RSI crosses below 70. Cut loss of 5% from the close of the buy signal.
Set RSI = RSI(close,14)
Set Buy = crossover(RSI,30)
Set Sell = crossover(70,RSI)
Set cutloss = stop(close, -0.05, buy, sell)
Set cut = cutloss < -0.05 //This allows us to display the cut loss signal to differentiate it from a normal sell signal.

plot(cut,buy,yellow,main) //the cut or take profit signal will automatically be displayed as the same as your sell condition if you don’t explicitly plot the cut function.
plotbuysell(buy,sell,green,red,main)
plot(rsi,line,cyan,rsi)
plot(70,line,red,rsi)
plot(30,line,green,rsi)

1643530609-vanguard-undefine-variable-error.png

pjm

 
Posted : 30/01/2022 4:16 pm
Mike
 Mike
(@vanguardai)
Posts: 70
Co-Founder Admin
 

Hi Pjm, tried running your script and it worked fine. I think you are using the old version of VAI, please redownload the new version 1.1 to use the function. Download link is on the main page, www.vaianalytics.com.

In version 1.1 also, all future features will be installed automatically. Let me know if you're still having problems.

1643531255-cut.png
 
Posted : 30/01/2022 4:27 pm
pjm
 pjm
(@pjm)
Posts: 13
Active Member User
Topic starter
 

@vanguardai thank you for responding.

i'm using v1.2

1643535890-vanguard-v12.png

pjm

 
Posted : 30/01/2022 5:44 pm
Mike
 Mike
(@vanguardai)
Posts: 70
Co-Founder Admin
 

Ok, im using the same version also 1.2. Can you send a screenshot of your script editor instead? Double clicking on the chart will show the editor with your script in it

 
Posted : 30/01/2022 5:56 pm
pjm
 pjm
(@pjm)
Posts: 13
Active Member User
Topic starter
 

@vanguardai 
Here is the screenshot

1643543267-vanguard-error2.png
This post was modified 3 years ago by pjm

pjm

 
Posted : 30/01/2022 7:46 pm
Mike
 Mike
(@vanguardai)
Posts: 70
Co-Founder Admin
 

We tested the script with another PC and it works fine. Can you create a new chart window (click on Chart/Widget button in the toolbar) and copy/paste the script to that new chart window's script editor instead? See if that works.

 
Posted : 31/01/2022 4:08 pm
pjm
 pjm
(@pjm)
Posts: 13
Active Member User
Topic starter
 

@vanguardai 

 

tried it but still variable error

1643721944-vanguard-variable-error.png

pjm

 
Posted : 01/02/2022 9:25 pm
pjm
 pjm
(@pjm)
Posts: 13
Active Member User
Topic starter
 

variable error

1643721981-vanguard-variable-error2.png

pjm

 
Posted : 01/02/2022 9:26 pm
pjm
 pjm
(@pjm)
Posts: 13
Active Member User
Topic starter
 

if i disable the plot(cut,buy,yellow,main) by putting # in the beginning the script runs without variable error.

I'm not into programming but this line might be causing the problem for me.

1643722174-disable-the-plot-cut.png

pjm

 
Posted : 01/02/2022 9:29 pm
pjm
 pjm
(@pjm)
Posts: 13
Active Member User
Topic starter
 

i tried to rewrite the plot cut into a new line manually and the script runs. i don't know why it solves the variable error.

1643722441-rewrite-the-plot-cut-manually.png

pjm

 
Posted : 01/02/2022 9:34 pm
Mike
 Mike
(@vanguardai)
Posts: 70
Co-Founder Admin
 

yeah, weird but glad it worked out haha reported this to the devs

 
Posted : 03/02/2022 9:51 am
pjm
 pjm
(@pjm)
Posts: 13
Active Member User
Topic starter
 

@vanguardai sir patulong bakit ganito lumalabas

undefined variable "SET NFS" error

copy ko lang yung script galing dito sa Knowledge base functions

 

//Alignment of the Stars Screener

//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 Aligned = sma1 > sma2 and sma2 > sma3

//Plot Indicators
//Plot(value,type,color,pane)
plot(sma1,line,green,main)
plot(sma2,line,blue,main)
plot(sma3,line,red,main)

 

//Set Variable
Set RSI = RSI(close,14)

//Plot Indicators
//Plot(value,type,color,pane)
plot(RSI,line,cyan,RSI)
plot(70,line,Red,RSI)
plot(30,line,Green,RSI)
plot(50,line,gray,rsi)

//Plot Net Foreign
Set NFS = NetForeign
Plot(NFS,bar,any,NFS)

//Signals - used to display flags in screener and backtesting.
signals(Aligned,0)

1654303761-Set-NFS-error.jpg

pjm

 
Posted : 04/06/2022 8:49 am
pjm
 pjm
(@pjm)
Posts: 13
Active Member User
Topic starter
 

@vanguardai sir meron pa isang tanung.

paano po palakihin yung font size ng indicator value, yung mga value ng RSI SMA etc. (black circle in the photo)

1654304666-indicator-value-font-size.jpg

pjm

 
Posted : 04/06/2022 9:04 am
Share: