Using Several Indicators that Don't Occur Simultaneously
Author: NewDayTrader
Creation Date: 7/22/2009 5:01 PM
profile picture

NewDayTrader

#1
I would like to use several different indicators to trigger a buy. My problem is that they don't occur simultaneously so I cannot simply "AND" these together. How can I trigger a buy if ALL of these indicators take place within a specified time period?

(1)Stochastic %D is oversold (below 20).
(2)Stochastic %K crosses above %D.
(3)Price is above moving average.
(4)CMF is increasing overall during the specified time period.
(5)ADX is above 20.
(6)DI+ crosses DI-.
profile picture

Eugene

#2
Triggering a signal like this can't be implemented by drag & drop rules, it requires some programming. For example, this pattern can probably be put to use:

Tutorial: Setups, Triggers, Delays, and Timeouts

Or as an alternative, a "binary wave" indicator could be created for every condition out of the 6, that would trigger "1" when condition is true, and another indicator that would sum them up.
profile picture

Eugene

#3
Here's an attempt to code it, considering your requirement ("ALL of these indicators") and without overcomplicating the logic and taking much time:
CODE:
Please log in to see this code.
profile picture

NewDayTrader

#4
Thanks, Eugene. I really appreciate that you wrote the code explicitly!
profile picture

Eugene

#5
You're welcome.
profile picture

NewDayTrader

#6
I have attempted to add code to implement (1) a trailing stop and (2) draw the various indicators to aid me in refining this strategy. I obtained this code by writing rules in WealthLabPro and converting to code. Unfortunately, I have a problem where I think I'm trying to use two different types for defined variables: "bool" and "WealthLab.DataSeries" (I realize that I'm also defining several variables differently but I think I can fix that. I'll attempt to use Eugene's definitions for the code obtained from writing rules.) In the end, my basic problem is that I'm not a programmer.

Any suggestions would be greatly appreciated!

Here's my amended code:

CODE:
Please log in to see this code.
profile picture

Eugene

#7
1. As you figured out, there's a need to pick up some different names for your data series -- other than the already existing boolean variables.
2. You have to define some entry signal first before adding an exit.
3. This part should not be placed inside the main loop or the code isn't going to work:
CODE:
Please log in to see this code.

So, that's where we stand:
CODE:
Please log in to see this code.


Remember: this code is an approximation to avoid overcomplicating the logic. It starts incrementing conditions after your Stochastic Oversold rule becomes true (we need a starting point).

It's up to you to verify the correctness of indicator and rule definitions.
profile picture

NewDayTrader

#8
Do you have any ideas why the indicators aren't plotting on the chart?

Thanks.
profile picture

Eugene

#9
Everything is plotting for me perfectly. We're somewhat limited in our telepathic abilities, so please help us by following this checklist:

How to report a Problem?
profile picture

NewDayTrader

#10
I'm using Wealth-Lab Pro 5.4. I'm running Windows Vista on an Intel Pentium Dual Processor @ 1.80 GHz w/ 3GB RAM. I opened a new strategy from code and ran it on SPY data from June 2009 provided by Fidelity. In examining the chart, I see the price and volume data but do not have the EMA, STO, ADX, DI+, DI-, and CMF indicators.

•Wealth-Lab Version (e.g., WLD Build 20, WLPro Version 3.5.52)
•Computer Description: (e.g. Win XP, Intel PIV 3.2GHz, 1GB RAM)
•ChartScript or sample code used. Again, we ask that you provide an "as-small-as-possible" ChartScript that demonstrates the anomaly. If you're using a un-modified public ChartScript, the name is sufficient.
•Wealth-Lab tool in use (DataSource Manager, $imulator, ChartScript Window, Scans, RT Scans, etc.)
•Position Sizing Control and Data Loading Control settings (refer to image)
•Options (F12), especially from the Trading Costs/Control group.
•Symbol(s)
•Data provider or real-time data feed
profile picture

Eugene

#11
Time frame? Bars loaded?

Compiled before running or just pasted in an Editor window?
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).