DYO: Boolean Logic Examples
|
Q: In the Howard Stoch template (which I am investigating) I would like to STOP and Long or Short from taking place unless a certain other condition is met. For instance, say when GV220 is true I will allow a long, but not unless it is true; and, for a short, GV221 needs to be true; and, if both GV220 and 221 are true, do not allow any trade.
A: Simply add [220] and [221] as Flags that is ANDed with the Buy Signal. Real Buy Signal = GV[220] AND NOT GV[221] AND Buy Signal.
Same principle for your final Sell Signal. Real Sell Signal = GV[221] AND NOT GV[221] AND Sell Signal
They naturally will block both trades when both are true.
Assume the Buy signal is in GV[1] for this example:
Now Line D has the Real Buy Signal by ANDing in 220 for True and 221 for False by using the Not Flag selection.
Q: I would also like to add some filtering to this by performing some "go-nogo" logic on each trade; for example if (GV220 and GV221) were true and gv222 was false and GV223 was between 550 and 650. I do not expect you to build this DYO, but guide me in putting the conditions in a AND [#] STRUCTURE LINE TEST A SEQUENCE OF GVs would be helpful.
The conditional part of DYOing is the most difficult for me. I understand the arrays and all but getting things to work based on a series of AND OR and GT or RANGE conditions seems to me my weak spot.
A:

Lines A and B are the first two Flags you want to be True. Line C is the 3rd flag you want to be False. Lines D and E implement the GV[223] being between 550 and 650. When these 5 conditions are met, then Line F will be True. Line F is ANDing 5 flags because the Number field = 5. The start of the set of GVs containing the flags is the Read GV reference to GV[1].
Q: Can you show me how to implement these rules?
(close current bar > close prior bar) OR (close current bar = close prior bar AND close current bar > close 2 bars ago)
A:

2nd bar on chart is example of the close=prior AND close above 2 bars back. So Line A and B are the 2 ANDed conditions, and Line C is the close>prior close condition. Line D does the AND and the OR in one statement.
Feedback:
Scrutch: You sure do make this stuff look easy... @Buffy2: Doesn't he though Scrutch: Thanks @Buffy2: Nice Howard Scrutch: Very nice @Buffy2: Never thought of using net @Buffy2: Boy were we making a mountain out of a molehill @Buffy2: So OR Next goes to C?
A: The AND set is of size 2, beginning with GV[1]. So it is [1] AND [2]. Thus Next will be the GV after the AND set which is GV[3].
Feedback:
InvalidSync: It looks even better when you color the bars

Comment:
The above color bar suggestion is unnecessary as this is the same logic as the Close v. Open Color Bars study, which happens to be the color bar study on the 1st example. Notice in the 1st example the color bars are Blue when the zone is pink, and Red otherwise. This confirms the Color Bar logic is the same as the DYO example.
Q: You posted the above solution to one of my problems. Thanks ever so much for that...greatly appreciated. Could you please help me with a DYO that does the following:
Higher Close: (this is the one you posted the dyo for) (current close > prior close) OR ((current close = prior close) AND (current close > close two bars ago))
Higher Volume: (current volume > prior volume) AND (current volume > volume two bars ago)
Marker: (when the higher close is true) AND (when the higher volume is true)
A: The DYO in the 1st example will have the Volume conditions added as follows.

Line E gets the volume from 2 bars ago and stores this in GV[10]. Line F then compares this volume to the current volume and stores the Boolean result in GV[5]. Line G compares current volume with prior volume and stores the result in GV[6].
Now we have all three conditions in GV[4], [5] and [6]. Line H is the final answer with the pink zone marking where the price condition from Line D and the Volume conditions from Lines F and G are all True simultaneously.
Last modified 8/25/09 1:24 PM
|