Custom Watch list ParabolicSAR


Category:
0
0

Pete Hi. I did not see any parabolic nor stochastic Custom Watch mods so I was hoping you can help by looking at this at tell me what I am doing wrong.

def parabolicSAR = close [1] < parabolicSAR [0] ==close > ParabolicSAR;

plot scan = parabolicSAR;

assignBackgroundColor(if parabolicSAR <= 1 then color.RED else color.BLACK);

I a trying to plot a color on custom watch list if the underline is trading above or below ParabolicSAR and choose appropriate high light color

we are also trying to to the same with Stochastic Fast if trading above 80 being one color and if trading below 20 on “K” value being another. please help if u can

 

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on January 18, 2019 1:15 am
109 views
0
Private answer

Since you only asked me to point out what you were doing wrong, I will do just that. Which means this is not a complete solution.

You have structured this statement incorrectly:

def parabolicSAR = close [1] < parabolicSAR [0] ==close > ParabolicSAR;

You cannot (in Thinkscript), chain together multiple operators (>, <, ==) without using the keyword “and” to separate them. One way you can correct this statement is:

def parabolicSAR = close [1] < parabolicSAR [1] and close > ParabolicSAR;

Notice I changed two items. First item I changed was to adjust your index value on the parabolicSAR from [0] o [1]. This should match the index value used on anything you are comparing it to, in this case close[1]. I then replaced your double equals signs with the keyword “and”.

So what this says in English is: “The close of the previous bar is less than the parabolicSAR of the previous bar AND the close of the current bar is greater than parabolicSAR of the current bar”. This essentially defines a change in state for the parabolicSAR from short to long.

You have another error in this line of code:

assignBackgroundColor(if parabolicSAR <= 1 then color.RED else color.BLACK);

The result of parabolicSAR can only be a 1 or a 0. 1 for true and 0 for false. When you test for parabolicSAR less than or equal to 1 you have a result that is always true. You see that? It’s always going to be one or the other. You need to pick one, so get rid of the equal sign.

assignBackgroundColor(if parabolicSAR < 1 then color.RED else color.BLACK);

 

Marked as spam
Posted by (Questions: 37, Answers: 4089)
Answered on January 21, 2019 9:39 am