Indicator help (IF... THEN... ELSE)

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
miltonc4
Posts: 150
Joined: 14 Apr 2006
Has thanked: 1 time
Been thanked: 4 times

Indicator help (IF... THEN... ELSE)

Postby miltonc4 » 25 Nov 2006

Hi All
the below plotsOK,but some bars are not colored because they do not fall within the criteria...C > C[1]and C > C[2] and C > C[3]
I refer to these unpainted bars as "Warning Bars"

Could someone show me how to color these "Warning Bars" yellow
Thanks
Milton

Code: Select all

If C > C[1]and C > C[2] and C > C[3] then begin
Condition1 = True ;
end else begin
Condition1 = False;
end;
If C < C[1]and C < C[2] and C < C[3] then begin
Condition2 = True ;
end else begin
Condition2 = False;
end;

Value1 = HIGH[0] ;
Value2 = LOW[0] ;

if Condition1 then
begin
PlotPaintBar[0]( Value1, Value2, "Plot", Cyan ) ;
Alert( "Close > than 3 prev Closes" ) ;

end
else if Condition2 then
begin
PlotPaintBar[0]( Value1, Value2, "Plot", Red ) ;
Alert("Close < than 3 prev Closes" ) ;
end ;

fs

Postby fs » 25 Nov 2006

There are probably many ways of doing this, but here is one way of doing it.

Regards
- Fanus

Code: Select all

{------------------------Start------------------------}

Condition1 = (C > C[1] and C > C[2] and C > C[3]);
Condition2 = (C < C[1] and C < C[2] and C < C[3]);

Value1 = HIGH;
Value2 = LOW;

if Condition1 then begin
PlotPaintBar( Value1, Value2, "Plot", Cyan ) ;
Alert( "Close > than 3 prev Closes" ) ;
end;

if Condition2 then begin
PlotPaintBar( Value1, Value2, "Plot", Red ) ;
Alert("Close < than 3 prev Closes" ) ;
end;

If Condition1 = false and Condition2 = false then begin
PlotPaintBar( Value1, Value2, "Plot", Yellow );
End;


{-----------------------------end---------------------------------------}
The last if statement can also be replaced with:
If Condition1 = Condition2 then
PlotPaintBar( Value1, Value2, "Plot", Yellow );

Since the only time both will be equal is if both are false.

miltonc4
Posts: 150
Joined: 14 Apr 2006
Has thanked: 1 time
Been thanked: 4 times

Postby miltonc4 » 25 Nov 2006

Hi Fanus
Thaks for help
Your version lays out the code in a clearer format
Appreciate
Milton


Return to “User Contributed Studies and Indicator Library”