Post by fxshrat on May 6, 2016 22:09:52 GMT
The connection is OR not AND, see both being separate.
As you can see zshort retunrs true and the other one false
So if both are connected via OR the result should be true and as such it should return price value too, so it should return same one as in single case. The other version using "!IsNull(..) OR !IsNull(..)" is returning the correct expected one. So I don't understand why if using > 0 returns different result.
It is same if you have a Buy rule Buy = cond1 OR cond2; if one of both is true then Buy signal becomes true.
So here I don't understand why it returns zero.
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
bi = BarIndex();
XLong = (bi % 200) == 0;
XShort = ((bi+20) % 200) == 0;
//_TRACE( "XLong: g, XShort: %g", XLong, XShort);
Plot(XLong, "XLong", colorGreen, styleHistogram | styleOwnScale);
Plot(XShort, "XShort", colorRed, styleHistogram | styleOwnScale);
// else zero
zLongEntry = IIf(XLong, C, 0);
zShortEntry = IIf(XShort, C, 0);
//_TRACEF( "zLong price: %g, zShort price: %g", zLongEntry, zShortEntry);
// else NULL
nLongEntry = IIf(XLong, C, Null);
nShortEntry = IIf(XShort, C, Null);
//_TRACEF( "nLong price: %g, nShort price: %g", nLongEntry, nShortEntry);
zS = ValueWhen( zLongEntry > 0 OR zShortEntry > 0, zShortEntry);
nS = ValueWhen( !IsNull(nLongEntry) OR !IsNull(nShortEntry), nShortEntry);
Plot(ValueWhen( zShortEntry > 0, zShortEntry), "zeroShort", colorRed, styleLine | styleNoLabel);
Plot(ValueWhen( zLongEntry > 0, zShortEntry), "zeroShort", colorGreen, styleLine | styleOwnScale | styleNoLabel);
As you can see zshort retunrs true and the other one false
So if both are connected via OR the result should be true and as such it should return price value too, so it should return same one as in single case. The other version using "!IsNull(..) OR !IsNull(..)" is returning the correct expected one. So I don't understand why if using > 0 returns different result.
It is same if you have a Buy rule Buy = cond1 OR cond2; if one of both is true then Buy signal becomes true.
So here I don't understand why it returns zero.