Page 1 of 1

Could I get some help plotting this please

Posted: Jan 22 2009
by shortski
I am just trying to get a basic +1/-1 histogram up to reflect when 2 indicators are both showing positive or negative values. The code looks good to me and compiles but doesn't show up anything on the chart. Ideas?

vars:

value1(0),
value2(0);

value1 = $rtOscillatorDivergence(high,low,GordoMACDDiff(close,12,26),1.0);
value2 = ThreeLineBreak;

If
value1 > 0 and value2 > 0 then begin
Plot1(1,"Buy",green);
end
else If
value1 < 0 and value2 < 0 then begin
Plot1(-1,"Sell",red);
end
else
NoPlot(1);

if(value1 > 0 and value2 > 0) then Green

else if(value1 < 0 and value2 < 0) then Red

Thanks

Shortski

Posted: Jan 22 2009
by TJ
do you know the value of value1 and value2?

they are pretty complicated functions. Do you know if they are returning any useable data?
if both conditions were not met, then you won't have any plot at all.

you can debug this by adding a plot3 and plot4:

plot3(value1, "value1");
plot4(value2, "value2");

then you will know if you are actually getting any returns from those function calls.

the plot code itself looks ok.

Posted: Jan 22 2009
by brodnicki steven
I don't have your functions , so I replaced them with a simple oscillator. It seems to work. See image attached.
if, when you plug in your functions it stops working, the problem is with the functions. If you post them , I'll insert them and check it out.

vars:

value1(0),
value2(0);

value1 = average(H,10)-average(H,50); {$rtOscillatorDivergence(high,low,GordoMACDDiff(close,12,26),1.0);}
value2 = average(L,10)-average(L,50);{ThreeLineBreak;}

If
value1 > 0 and value2 > 0 then begin
Plot1(1,"Buy",green);
end
else If
value1 < 0 and value2 < 0 then begin
Plot1(-1,"Sell",red);
end
else
NoPlot(1);

Posted: Jan 22 2009
by shortski
Yes both functions/indicators are giving me results on the chart so both are working. That is how I can see that the code I am inputting for combining them isn't working. The second response is interesting in that by simply changing the indicators, you get results. I will have to look at that and see if it is just the inputs.

Thanks

S

Posted: Jan 23 2009
by TJ
you should add a catch-all at the end for the following conditions:

value1 > 0 and value2 <0,

or

value1 < 0 and value2 >0,



Code: Select all

vars:

value1(0),
value2(0);

value1 = average(H,10)-average(H,50); {$rtOscillatorDivergence(high,low,GordoMACDDiff(close,12,26),1.0);}
value2 = average(L,10)-average(L,50);{ThreeLineBreak;}

If
value1 > 0 and value2 > 0 then begin
Plot1(1,"Buy",green);
end
else If
value1 < 0 and value2 < 0 then begin
Plot1(-1,"Sell",red);
end


else
Plot1(0,"neither",blue); { <--- add this }


p.s. in the Format Study, make sure you define the plot style to thick line for the zero to show up.

.

Posted: Jan 23 2009
by shortski
I added the

value1 > 0 and value2 <0

at the end and it wouldn't compile.

Is there something more to do...?

Thanks

S

Posted: Jan 23 2009
by shortski
I just noticed the

Plot1(0,"neither",blue);

and it Plots as a solid blue line but no Histogram where there should be one.

Posted: Jan 23 2009
by TJ
I just noticed the
Plot1(0,"neither",blue);
and it Plots as a solid blue line but no Histogram where there should be one.
I have tried your code (with another function). It works, so the problem is not in the code.

there are 3 scenario for plotting:

1. value1 > 0 and value2 <0, (green)
2. value1 < 0 and value2 >0, (red)
3. neither (blue)

you are getting blue.

i.e. your functions are not returning the values you thought.

next step: use the print statement to debug.
(thank you for posting this question. this is a great learning experience for all)

add the following code to the end of the indicator:

Code: Select all

if barstatus = 2 then
print(
"d=" + text(d)
+", t=" + text(time_s)
+", v1=" + text(value1)
+", v2=" + text(value2)
);
go to your PowerEditor>View
make sure the Output Bar is checked.

On the bottom half of the PowerEditor, click on the Output tab.

Now you will see the values your indicator is processing.

enjoy.

Posted: Jan 23 2009
by shortski
Interesting. The Output tab is blank. Thanks for your time on this. I do appreciate it and am learning something as I go along.

shortski

Posted: Jan 23 2009
by TJ
the output tab is blank?
it should show red something like this:

Code: Select all

d=1090123.00, t=91000.00, v1= 2.50, v2= 2.50
d=1090123.00, t=91500.00, v1= 0.50, v2= 0.50
where
D= is the date (in EL time)
T= is the closing time of the bar
V1= is the value in Value1
V2= is the value in Value2


if you had plotted Value1 and Value2 as I suggested before, the V1 and V2 should not be blank.

Posted: Jan 23 2009
by TJ
I added the
Value1 > 0 and value2 <0
this not a good way to debug...
because you are not covering the situation where

Value1 = 0

and/or

Value2 = 0

a catch-all with no condition is preferred.

Posted: Jan 23 2009
by shortski
I may have found the problem. There is a line of code that is proprietary in the Functions I am using and the programmer just got back to me on it. He is unlocking it now and I will try it and let you know if it works.