Hi, I apply the following indicator in market scanner:
if close > highest(high[1],20) and Average(close,5)>Average(close,20) then plot1("AAA");
plot2(Average(close,5),"5",yellow);
plot3(Average(close,20),"20",cyan);
plot4(Average(close,5)-Average(close,20),"diff",cyan);
It plot "AAA" if fullfil 2 conditions but I find that it even plot "AAA" when 2nd condition [ (Average(close,5) > Average(close,20) ]is not fullfiled. I have attached a output image which show some results like that. Thanks for your opinion.
indicator calculation in scanner watchlist [SOLVED]
indicator calculation in scanner watchlist
- Attachments
-
- scanner image 1.png
- (42.45 KiB) Downloaded 923 times
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: indicator calculation in scanner watchlist
Hi, I apply the following indicator in market scanner:
if close > highest(high[1],20) and Average(close,5)>Average(close,20) then plot1("AAA");
plot2(Average(close,5),"5",yellow);
plot3(Average(close,20),"20",cyan);
plot4(Average(close,5)-Average(close,20),"diff",cyan);
It plot "AAA" if fullfil 2 conditions but I find that it even plot "AAA" when 2nd condition [ (Average(close,5) > Average(close,20) ]is not fullfiled. I have attached a output image which show some results like that. Thanks for your opinion.
Before you jump head first into the scanner,
have you tried to plot the variables on the chart to verified that the logics are valid?
Take the example of this line:
Code: Select all
if close > highest(high[1],20) and Average(close,5)>Average(close,20) then plot1("AAA");
Code: Select all
A5 = Average(close,5);
A20 = Average(close,20);
plot10( highest(high[1],20), "highest(high[1],20)");
if A5 > A20 then plot20( c, "AAA"); // <--- plot as a large dot
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: indicator calculation in scanner watchlist
Hi TJ,
I cannot follow your idea. Could you tell more about your idea? Thanks.
I cannot follow your idea. Could you tell more about your idea? Thanks.
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: indicator calculation in scanner watchlist
Hi TJ,
I cannot follow your idea. Could you tell more about your idea? Thanks.
Have you done all three posts?
Which part do you not understand?
Re: indicator calculation in scanner watchlist
Hi TJ,
You suggest to Look up the keyword: NoPlot in your post link but cannot find it . I don't understand how to relate NoPlot to my current issues. I have read the post which provides guideline how to make a post and make code reading easier.
I post the code using the guideline for easy reading
My intention is to plot "AAA" if 2 conditions are true
condition1 :close > highest(high[1],20)
condition2: Average(close,5)>Average(close,20)
but it plots when only 1 condition is true. I have no idea what's wrong with code and appreciate if anyone can give me suggestion. Thanks.
You suggest to Look up the keyword: NoPlot in your post link but cannot find it . I don't understand how to relate NoPlot to my current issues. I have read the post which provides guideline how to make a post and make code reading easier.
I post the code using the guideline for easy reading
Code: Select all
if close > highest(high[1],20) and Average(close,5)>Average(close,20) then plot1("AAA");
plot2(Average(close,5),"5",yellow);
plot3(Average(close,20),"20",cyan);
plot4(Average(close,5)-Average(close,20),"diff",cyan);
condition1 :close > highest(high[1],20)
condition2: Average(close,5)>Average(close,20)
but it plots when only 1 condition is true. I have no idea what's wrong with code and appreciate if anyone can give me suggestion. Thanks.
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: indicator calculation in scanner watchlist
I would try to turn on/off the "AAA" plot based on the two conditions like this:My intention is to plot "AAA" if 2 conditions are true
condition1 :close > highest(high[1],20)
condition2: Average(close,5)>Average(close,20)
but it plots when only 1 condition is true. I have no idea what's wrong with code and appreciate if anyone can give me suggestion. Thanks.
Code: Select all
if (close > highest(high[1],20)) and (Average(close,5)>Average(close,20)) then begin
Plot1("AAA");
end else
NoPlot(1);
plot2(Average(close,5),"5",yellow);
plot3(Average(close,20),"20",cyan);
plot4(Average(close,5)-Average(close,20),"diff",cyan);
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: indicator calculation in scanner watchlist
When learning a new keyword,Hi TJ,
You suggest to Look up the keyword: NoPlot in your post link but cannot find it .
you should look up the definition and read the usage example in the wiki PowerLanguage Keyword Reference
You need to complete your thought....My intention is to plot "AAA" if 2 conditions are true
::
Computers are dumb, but very obedient. You have to tell them precisely what needs to be done.My intention is to plot "AAA" if 2 conditions are true
but otherwise noplot
Re: indicator calculation in scanner watchlist [SOLVED]
Thanks JoshM and TJ's help to resolve the issues