realtime indicator help EL

chrisleonard

Junior member
Messages
13
Likes
0
Hi i have a bit of code i have written to plot a dot if the right conditions match!!

The problem is that it plots the dot fine but if the price then goes the other way it just reverts the dot to the default color for that plot!!

How do i tell it that if the conditions change to remove the plot all together?

Thanks

here is the code and the problem its causing!

if cti= 0 and Value1 > Value1[1] and Value2 > Value2[1] and barColor = barColor[1]


then begin
SetPlotColor( 4, green ) ;
Plot4(low,"testy");

test.jpg


Thanks Again

Chris
 
Try this and see how you get on:

if cti= 0 and Value1 > Value1[1] and Value2 > Value2[1] and barColor = barColor[1]
then begin
Plot4(low,"testy");
SetPlotColor( 4, green ) ;
End;


Paul
 
tried that its basically because it plot a plot and when condition changes it leaves the plot there but removes the colour

Im trying to use the noplot command to remove the plot but it messes up the rest of it!

here it all is

if
(cti = 0 and Value1 > Value1[1] and Value2 > Value2[1] and barColor = barColor[1]) or
(cti = 0 and Value1 > Value1[1] and Value2 > Value2[1] and barColorpl = barColorpl[1])


then
Plot4(low,"test",green)
else NoPlot(4); <----------------------------- here it removes the plot and
cti = 1;
ID = Text_New(D,T,L-range, "S: " + numtostr(ATR*10000+5,0) );
Value7 = Text_SetColor(ID ,Red);
Value8 = Text_SetStyle(ID,2,0);


end;


if
(cti = 1 and Value1 < Value1[1] and Value2 < Value2[1] and barColor = barColor[1]) or
(cti = 1 and Value1 < Value1[1] and Value2 < Value2[1] and barColorpl = barColorpl[1])
then begin
Plot5(high,"test",green); ;
ID = Text_New(D,T,H+Range, "S: " + numtostr(ATR*100+5,0) );
Value9 = Text_SetColor(ID ,Red);
Value10 = Text_SetStyle(ID,2,0);
cti = 0;
end;
end;

where do i put the noplot(4) no it will not effect any of the other code?

i just want it to remove the plot and text if conditions change before the cadle closes!!

Thanks
 
Last edited:
Have you tried using the Paintbar study rather than an indicator ? That way you can use the noplot syntax to remove the plot when conditions are not met. Also if previous bars have met your criteria then they will stay as plotted and it is only the current bar that may change. What you may need to do is to specify that the plot only occurs on the current bar.


Paul
 
Hmm i did think about it but i just got my head nearly around this and its taken me weeks.

Im only having 1 small problem!!

if
(cti = 0 and Value1 > Value1[1] and Value2 > Value2[1] and barColor = barColor[1]) or
(cti = 0 and Value1 > Value1[1] and Value2 > Value2[1] and barColorpl = barColorpl[1])


then begin
cti = 1;
Plot4(low,"test",green);
ID = Text_New(D,T,L-range, "S:"); < ------------ how do i get rid of this if the plot is removed???
end
else
noplot(4);
end;
 
As I understand it you want to place a dot and some text having a certain colour below the bar if a condition is met and no dot or text when the condition is not met.

In my example I am placing a dot and some text giving the low of the bar only if the low of the current bar is greater than the low of the previous bar. In addition (just to illustrate multiple conditions) I am making the dot and the text red if the low is below 120.96 but blue if it is equal to or above 120.96. There is no dot or text if the low of the current bar is not higher than the previous bar.

The code has been placed into a SHOWME analysis technique.

The code that I used for this example is:

Vars:
ID(0);

value1 = close;



if
Value1 > Value1[1] and value1 < 120.96
then
begin
ID = Text_New(D,T,L-0.01, "S:" + numtostr(low,2));
Value7 = Text_SetColor(ID ,Red);
Value8 = Text_SetStyle(ID,2,0);
plot4 (low, "test",red);
end
else
if
Value1 > Value1[1] and value1 >= 120.96
then
begin
ID = Text_New(D,T,L-0.01, "S:" + numtostr(low,2));
Value7 = Text_SetColor(ID ,blue);
Value8 = Text_SetStyle(ID,2,0);
plot4 (low, "test",blue);
end
else
begin
noplot(4);

end;
 

Attachments

  • text_new.png
    text_new.png
    16.4 KB · Views: 222
When the system is running live, you may flip between 1 condition and another. If you want to avoid this, you can just check for the condition to plot (or not) at the end of the bar.

if barstatus(1) = 2 then begin
put your plot code here
end;

Another thing that will drive you nutty if you don't understand it is that your code is run on every tick and all variables are reset to their start of bar value when it runs the code for each tick. So, even if you set a value in a variable, it will be cleared on the next tick. The exception to this is the last tick on a bar. When your code runs for the last tick on a bar, the values 'stick' and are held until the next bar and this in turn becomes the value that is reset at each tick.

So - you may want to know which condition occured first on a bar and not have it reset on succesive ticks. To do that, you need to use the intrabarpersist clause when defining the variable.

Var : intrabarpersist varname(0);

If a var is defined in this way, then your code will still run for each tick BUT your variable will retain it's value from one tick to the next.
 
Top