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-.
Size:
Color:
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 TimeoutsOr 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.
Size:
Color:
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.
Size:
Color:
Thanks, Eugene. I really appreciate that you wrote the code explicitly!
Size:
Color:
You're welcome.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
Do you have any ideas why the indicators aren't plotting on the chart?
Thanks.
Size:
Color:
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?
Size:
Color:
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
Size:
Color:
Time frame? Bars loaded?
Compiled before running or just pasted in an Editor window?
Size:
Color: