How can I fix a condition and vice versa

For example. If the close hits for example 90 day high
value = 1 and should stay so long at 1 if it hits 90 day low then it change
value = 0 and it stays so long value=0 till the 90 day high is coming again
value =1
How can I programm this to see this in the explorer?
Thanks for any advice to improve my skills.

Use Flip() function
http://www.amibroker.com/f?flip

// tests for 90-day highest/lowest CLOSE price
NewHigh = HHVBars( Close, 90 ) == 0;
NewLow = LLVBars( Close, 90 ) == 0;

YourValue = Flip( NewHigh, NewLow );
4 Likes

For output in explorer you may use AddMultiTextColumn (for example).

bars = 90;

cond1 = HHVBars( Close, bars ) == 0;
cond2 = LLVBars( Close, bars ) == 0;

state = Flip( cond1, cond2 );

color = IIf( state==1, colorGreen, colorRed );

Plot( C, "Price", color, styleBar );

Filter = NOT IsNull(state);

AddMultiTextColumn( state, StrFormat( "*0* LLV(%g)\n*1* HHV(%g)", bars, bars), "Status", 1, -1, color, 80 );

1

1

Links related to AddMultiTextColumn

4 Likes