You are doing this incorrectly.
Filter is array variable and exploration outputs results based on last call of Filter (formula is getting processed from top to bottom). That's why in your code you get results only when dtr_orb < 1.23
as it is in last (bottom) if
statement.
Now, proper way for getting getting check for both conditions (and no matter if dtr_orb
is array or not) are these examples (using IIf
function):
dtr_orb = (orbdiff/newdayopen)*100;
// if dtr_orb > 1.23 then ... else if dtr_orb <= 1.23 then ...
FilterCond = IIf( dtr_orb > 1.23, Buy OR Sell, Condition1 Or Condition2);
Filter = FilterCond AND Status("lastbarinrange");
bkColor = IIf( dtr_orb > 1.23, colorDarkGreen, colorDarkRed);
AddColumn( dtr_orb, "dtr_orb", 1.2, colorLightGrey, bkColor );
Or if you want to get no output or different output if dtr_orb
is equal to 1.23 then
dtr_orb = (orbdiff/newdayopen)*100;
FilterCond = IIf( dtr_orb > 1.23, Buy OR Sell, IIf( dtr_orb < 1.23, Condition1 Or Condition2, 0 ));
Filter = FilterCond AND Status("lastbarinrange");
bkColor = IIf( dtr_orb > 1.23, colorDarkGreen, IIf( dtr_orb < 1.23, colorDarkRed, colorBlack));
AddColumn( dtr_orb, "dtr_orb", 1.2, colorLightGrey, bkColor );
As you can see in both examples I am adding Status("lastbarinrange")
to Filter to output at last bar of selected range. If you do want to output for entire history then remove AND Status("lastbarinrange")
from Filter
.
If you want to output something based on SelectedValue e.g. getting datetime element at last bar of selected range e.g. in column header...
/// code of before...
dtSelect_str = DateTimToStr( SelectedValue(DateTime) );
bkColor = IIf( dtr_orb > 1.23, colorGreen, colorRed);
AddColumn( dtr_orb, "dtr_orb @" + dtSelect_str, 1.2, colorLightGrey, bkColor );
Are you sure it is single number but not array? This name newdayopen
rather suggests it to be an array (e.g. if it is something like newdayopen = ValueWhen(newday, Open);
).
So since you seem to be unsure (and I do not know as you did not add full code) please check type of dtr_orb
via typeof
operator yourself. E.g. trace log output
_TRACE( "dtr_orb is " + typeof( dtr_orb ) );
No, you are wrong. It is not equivalent. SelectedValue in AA returns last bar of selected AA range.