Code in scanner window

Questions about MultiCharts and user contributed studies.
iso
Posts: 204
Joined: 08 Feb 2006
Has thanked: 1 time
Been thanked: 1 time

Code in scanner window

Postby iso » 24 Apr 2009

Hi,

I can't figure out why this isn't working. Sometimes it is correct and sometimes not. It is trying to color a cell when price is below or above yesterdays range. I was trying to run it on an intraday timeframe. Any ideas?

if highest(h,1) > highd(1) then begin
SetPlotBGColor(3, green);
SetPlotColor(3,black);
end;
if lowest(l,1) < lowd(1) then begin
SetPlotBGColor(3, red);
SetPlotColor(3,darkred);
end;

Thanks

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 24 Apr 2009

1. "...trying to color a cell when price is below or above yesterdays range."

when you say price, do you mean the last price (ie "Close" in EasyLanguage)?
this is different from highest(h,1) because the bar can make a higher high, then retreat below previous bar's high. Do you still want the color changed?

2. highest(h,1) gets you the high of the current bar. Is this what you want?
or maybe you are thinking of highD(0) ? which returns the highest high of current day.

iso
Posts: 204
Joined: 08 Feb 2006
Has thanked: 1 time
Been thanked: 1 time

Postby iso » 24 Apr 2009

I was just trying to use a channel high/low because I couldn't get "last" or "close" to work. I just want to know when it is above or below yesterdays range.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 24 Apr 2009

I was just trying to use a channel high/low because I couldn't get "last" or "close" to work. I just want to know when it is above or below yesterdays range.
what is it?

current price?
high of the day?
high of THIS bar?

???

iso
Posts: 204
Joined: 08 Feb 2006
Has thanked: 1 time
Been thanked: 1 time

Postby iso » 24 Apr 2009

current price

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 24 Apr 2009

current price
if C > highd(1) then begin
SetPlotBGColor(3, green);
SetPlotColor(3,black);
end
else
if C < lowd(1) then begin
SetPlotBGColor(3, red);
SetPlotColor(3,darkred);
end;

iso
Posts: 204
Joined: 08 Feb 2006
Has thanked: 1 time
Been thanked: 1 time

Postby iso » 24 Apr 2009

I tried that but the results are sporadic. Sometime it works but often price will be inside yesterdays range and it will display the color as if it were outside the range.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 24 Apr 2009

I tried that but the results are sporadic. Sometime it works but often price will be inside yesterdays range and it will display the color as if it were outside the range.
try this:

if C > highd(1) then
begin
SetPlotBGColor(3, green);
SetPlotColor(3,black);
end
else
if C < lowd(1) then
begin
SetPlotBGColor(3, red);
SetPlotColor(3,darkred);
end
else
begin
SetPlotBGColor(3, white);
SetPlotColor(3, black);
end;

iso
Posts: 204
Joined: 08 Feb 2006
Has thanked: 1 time
Been thanked: 1 time

Postby iso » 27 Apr 2009

I tried the code above from TJ this morning but it is still not accurate. You can see in the attached snapshot 9:45:31 this morning price on many of these were hovering just above the previous days low but the coloring is plotting red as if they were below the previous days low.

Any other ideas?

Thanks
Attachments
2009-04-27 09.45.31001.png
(11.17 KiB) Downloaded 617 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 27 Apr 2009

I tried the code above from TJ this morning but it is still not accurate. You can see in the attached snapshot 9:45:31 this morning price on many of these were hovering just above the previous days low but the coloring is plotting red as if they were below the previous days low.

Any other ideas?

Thanks
you'd better post your complete code...

and the complete screen shot of your scanner window.

iso
Posts: 204
Joined: 08 Feb 2006
Has thanked: 1 time
Been thanked: 1 time

Postby iso » 27 Apr 2009

The entire screenshot of the scanner window is in the above post. Here is the complete code...

Code: Select all


if LastBarOnChart then
begin
var: last_(0),
prevclose_(0),
open_(0);

last_ = close;
prevclose_ = closed(1);
open_ = opend(0);

if ( last_ <> 0 ) then
begin
value1 = darkgray;

if ( last_ > open_ ) then value1 = green
else if ( last_ < open_ ) then value1 = red;
plot3 (last_, "Last", value1);

end;


if C > highd(1) then
begin
SetPlotBGColor(3, green);
SetPlotColor(3,black);
end
else
if C < lowd(1) then
begin
SetPlotBGColor(3, red);
SetPlotColor(3,white);
end
else
begin
SetPlotBGColor(3, darkgray);
SetPlotColor(3, black);
end;


if ( last_ <> 0 ) and ( prevclose_ <> 0 ) then
begin
value2 = last_ - prevclose_;
value3 = value2 / prevclose_ * 100;
plot4 (value2, "Net", value1);
plot5 (value3, "%Net", value1);
end
else
begin
NoPlot(4);
NoPlot(5);
end;

end;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 27 Apr 2009

I have changed your plot 4 and 5 to display highD(1) and lowD(1).

you can see the code works.

you can try the same and see if it you have the same result.

I can't explain otherwise.




p.s. I do not understand why you have the value1 for plot3.
Attachments
scanner.jpg
(26.41 KiB) Downloaded 632 times


Return to “MultiCharts”