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: 3 times

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

Hi All
the below plotsOK,but some bars are not colored because they do not fall within the criteria...C > Cand C > C and C > C
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 > Cand C > C and C > C then begin
Condition1 = True ;
end else begin
Condition1 = False;
end;
If C < Cand C < C and C < C then begin
Condition2 = True ;
end else begin
Condition2 = False;
end;

Value1 = HIGH ;
Value2 = LOW ;

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

end
else if Condition2 then
begin
PlotPaintBar( Value1, Value2, "Plot", Red ) ;
Alert("Close < than 3 prev Closes" ) ;
end ; fs
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 and C > C and C > C);
Condition2 = (C < C and C < C and C < C);

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: 3 times
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”