Figuring out the Buy/Sell condition type in Explorer column



I have 2 different conditions for both Buy and sell.
I want to FILTER the signals of both conditions combined using the OR condition.

Now i just want to add a separate column in EXPLORER to figure out which condition it has actually met out of 2 buy and 2 sell conditions.

How to do it?

Your Help is much appreciated.

buyadd1= -------- ;
selladd1= --------- ;
Buyadd2= -------- ;
Selladd2= -------- ;

Buycond1=buyadd1  AND  Ref(C,0)>PRICERANGE AND T>= STARTTIME AND T<= ENDTIME AND TimeNum()>100000;
Sellcond1=selladd1  AND Ref(C,0)>PRICERANGE AND T>= STARTTIME AND T<= ENDTIME AND TimeNum()>100000;

Buycond2=buyadd2  AND  Ref(C,0)>PRICERANGE AND T>= STARTTIME AND T<= ENDTIME AND TimeNum()>100000;
Sellcond2=selladd2  AND Ref(C,0)>PRICERANGE AND T>= STARTTIME AND T<= ENDTIME AND TimeNum()>100000;

Buy=Buycond1 or Buycond2;
Sell=Sellcond1 or Sellcond2;

PlotShapes( shapeUpArrow*Buy, colorAqua,0, L, -20);
PlotShapes( shapeDownArrow*Sell, colorAqua,0,H, -20) ;

Filter=Buy OR Sell;

Gloria Filamino


@Gloriafilamino in any exploration you can add as many columns as you want.

In general, when you have some complex rules, it is beneficial to use explorations as a debugging tool, adding a column for each condition to be sure that you are actually applying the desired logic rules.

Here is a modified version of your code to add many more columns (some are commented out, but you should be able to uncomment and test them when you apply it to your data).

I also added a little utility custom function that I use to make the result exploration more readable. I apply it to boolean arrays (logic conditions): I prefer to see only True values (1 - ones) leaving the False (0 - zeros) cells empty.

// some fake conditions to test
buyAdd1  = C > O;
sellAdd1 = C < L;
BuyAdd2  = C > Ref( H, -1 ); // was buyaAd2 
SellAdd2 = C < Ref( L, -1 );

/* Uncomment when you have true data
ExtraCondition1  = Ref(C,0) >PRICERANGE;
ExtraCondition2  = T >= STARTTIME;
ExtraCondition3  = T <= ENDTIME; 
ExtraCondition4  = TimeNum()>100000;
ExtraCondition = ExtraCondition1 AND ExtraCondition2 AND ExtraCondition3 AND extraCondition4;
// comment out when uncommenting the above block
ExtraCondition = True;

BuyCond1 = buyAdd1 AND ExtraCondition;
SellCond1 = sellAdd1 AND ExtraCondition;

BuyCond2 = buyAdd2 AND ExtraCondition;
SellCond2 = sellAdd2 AND ExtraCondition;

Buy = Buycond1 or Buycond2;
Sell = Sellcond1 or Sellcond2;

PlotShapes( shapeUpArrow*Buy, colorAqua, 0, L, -20 );
PlotShapes( shapeDownArrow*Sell, colorAqua, 0, H, -20 ) ;

/////// Exploration

// A small utility function to improve readibility of exploration
// results for boolean arrays - only ones (1) will appear
function nil(array) 
	return (IIf(array, 1, Null));

// Filter = 1;
Filter = Buy OR Sell;
Addcolumn( nil(Buy), "Buy", 1 );
Addcolumn( nil(Sell), "Sell", 1 );
AddColumn( nil(buyAdd1), "BuyAdd1", 1 );
AddColumn( nil(sellAdd1), "SellAdd1", 1 );
AddColumn( nil(buyAdd2), "BuyAdd2", 1 );
AddColumn( nil(sellAdd2), "BuySell2", 1 );
AddColumn( nil(BuyCond1), "BuyCond1", 1 );
AddColumn( nil(SellCond1), "SellAdd1", 1 );
AddColumn( nil(BuyCond2), "BuyCond2", 1 );
AddColumn( nil(SellCond2), "SellCond2", 1 );
/* Uncomment when you have true data
AddColumn( nil(ExtraCondition1), "Extra 1", 1);
AddColumn( nil(ExtraCondition2), "Extra 2", 1);
AddColumn( nil(ExtraCondition3), "Extra 3", 1);
AddColumn( nil(ExtraCondition4), "Extra 4", 1);
AddColumn( nil(ExtraCondition), "Extra Combined", 1);


Thanks a lot Beppe.
Thanks for your time and effort.
I have not applied it yet.
I will feed back the results soon.
Thanks again

Gloria Filamino


Hi Beppe,
It worked like charm.
Thanks once again.

Gloria Filamino.