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
Could I get some help plotting this please
- TJ
- Posts: 7775
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times
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.
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.
-
- Posts: 407
- Joined: Jan 01 2008
- Been thanked: 3 times
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);
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);
- Attachments
-
- Candlesticks painted2.png
- (59.2 KiB) Downloaded 601 times
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
Thanks
S
- TJ
- Posts: 7775
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times
you should add a catch-all at the end for the following conditions:
value1 > 0 and value2 <0,
or
value1 < 0 and value2 >0,
p.s. in the Format Study, make sure you define the plot style to thick line for the zero to show up.
.
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.
.
- TJ
- Posts: 7775
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times
I have tried your code (with another function). It works, so the problem is not in the code.I just noticed the
Plot1(0,"neither",blue);
and it Plots as a solid blue line but no Histogram where there should be one.
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)
);
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.
- TJ
- Posts: 7775
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times
the output tab is blank?
it should show red something like this:
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.
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
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.
- TJ
- Posts: 7775
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times
this not a good way to debug...I added the
Value1 > 0 and value2 <0
because you are not covering the situation where
Value1 = 0
and/or
Value2 = 0
a catch-all with no condition is preferred.