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
Code in scanner window
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
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.
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.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
try this: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.
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;
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
Any other ideas?
Thanks
- Attachments
-
- 2009-04-27 09.45.31001.png
- (11.17 KiB) Downloaded 617 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
you'd better post your complete code...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
and the complete screen shot of your scanner window.
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;
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
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.
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