Notifications
Clear all

Creating custom script

pjm
 pjm
(@pjm)
Active Member User

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

Quote
Topic starter Posted : 30/01/2022 4:16 pm
Mike
 Mike
(@vanguardai)
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
ReplyQuote
Posted : 30/01/2022 4:27 pm
pjm
 pjm
(@pjm)
Active Member User

@vanguardai thank you for responding.

i'm using v1.2

1643535890-vanguard-v12.png

pjm

ReplyQuote
Topic starter Posted : 30/01/2022 5:44 pm
Mike
 Mike
(@vanguardai)
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

ReplyQuote
Posted : 30/01/2022 5:56 pm
pjm
 pjm
(@pjm)
Active Member User

@vanguardai 
Here is the screenshot

1643543267-vanguard-error2.png
This post was modified 4 months ago by pjm

pjm

ReplyQuote
Topic starter Posted : 30/01/2022 7:46 pm
Mike
 Mike
(@vanguardai)
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.

ReplyQuote
Posted : 31/01/2022 4:08 pm
pjm
 pjm
(@pjm)
Active Member User

@vanguardai 

 

tried it but still variable error

1643721944-vanguard-variable-error.png

pjm

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

variable error

1643721981-vanguard-variable-error2.png

pjm

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

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

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

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

ReplyQuote
Topic starter Posted : 01/02/2022 9:34 pm
Mike
 Mike
(@vanguardai)
Co-Founder Admin

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

ReplyQuote
Posted : 03/02/2022 9:51 am
Share: