I would like to do this (using hourly data):
(7sma - 35sma) for the current hour MINUS (7sma - 35sma) for the period 2 previous
and if that value is > X then buy SPY at the market
if that value is < Y then sell SPY at the market
Seems relatively simple but I don't see that I can do it using the rules that are in "drop and drag".
Any suggestions?
Thanks!
Rick
Size:
Color:
Custom indicators and formulas require programming before they can be utilized in Rules. This goes beyond the Rule Wizard's possibilities. However, not totally in this case. "(7sma - 35sma)" is basically what the
MACD indicator is about. It's just that MACD isn't acceptable for your task for it's not configurable. But if you install
Community Indicators library (
create a support ticket to verify your WLP entitlement to be able to download), restart WLP and take the
customizable MACDEx instead (using 7 and 35 as parameters), you'll get
close to what you want (since MACD and MACDEx use an EMA, not SMA).
Here's how you could approach it in Rules using MACDEx, with the resulting difference between 2 EMAs vs. SMAs:
And here's demo code for your rules using 2 SMAs, to be executed on SPY's hourly chart:
CODE:
Please log in to see this code.
Size:
Color:
Thanks!! I will work on this.
Rick
Size:
Color:
When I compile this it says:
error CS1501 : No overload for method 'Series' takes 2 arguments
Sounds like it wants one more argument for:
CODE:
Please log in to see this code.
?
Size:
Color:
This is impossible with the innocuous code above. How have you modified the regional settings (i.e. separators) in Windows?
Size:
Color:
I will check. I have just started using WL and don't think I have modified much of anything, but I will look.
I took the code above and pasted it into a 'new strategy' I created. Then clicked on the compile button.
Size:
Color:
I was rather talking about customizing Windows than WL. There's no way you can get this error with WL 6.8 unless you edited the SMA in my code with an EMA - then it starts to make sense. Less likely if comma is not the separator on your PC or your browser is somehow replacing the "," character with a similar one.
Size:
Color:
sorry.
The code you sent above. DOES compile fine.
I was going to try it using EMA's !
And changing SMA.Series(Close,7) - SMA.Series(Close,35);
to EMA.Series(Close,7) - EMA.Series(Close,35);
is what causes the error, apparently EMA needs 2 arguments
Size:
Color:
In the future please do not waste a technician's time by supplying a different code and not letting know about an unknown edit you're making behind the scenes - or anything like that. We can not help if you're not telling what you're actually doing. Thanks.
Re: EMA, indeed it requires an extra argument. Here's an excercise for you to quickly learn any indicator's syntax. Open the Indicators window (Ctrl-F11), find "EMA", and click "More info..." This will open the indicator's online guide in the Wiki with its syntax and usage example. Hope this helps.
Size:
Color:
I apologize that I changed the code. With your help I have it working, and learned a lot.
Size:
Color:
Size:
Color: