I am new to WealthLab coding and am trying to add a simple piece of code to below. Have looked through the forum and found some help but cannot get it to work?
All I want to do is say that SPY must be greater than 40 SMA.
CODE:
Please log in to see this code.
Size:
Color:
This question has been raised numerous times on the forum, for example:
Buy/sell signal using external symbol SPY or .SPXSPY criteriaQUOTE:
All I want to do is say that SPY must be greater than 40 SMA.
You're now authorized to use
Community.Rules with conditions like:
* External Symbol Price is above (below) its Moving AverageThis is the simplest option which requires no programming. Anyway, here's code sample as requested:
CODE:
Please log in to see this code.
Size:
Color:
Thank You Eugene
Size:
Color:
At your service.
Size:
Color:
Eugene, why did you express the SPY variables as "var" in stead of DataSeries? I wrote the code as I would have written it and see no difference.
CODE:
Please log in to see this code.
Size:
Color:
Len, it's just syntactic sugar (and less room for error for new users).
Size:
Color:
QUOTE:
why did you express the SPY variables as "var" in stead of DataSeries?
QUOTE:
less room for error for new users
As us computer professionals on the forum know, strongly typed languages (like C#) were specifically created to
reduce errors. The intent is to discover the errors (and spelling typos) at compile time,
not at run time. I think that's the subtle point being made in Post# 5.
There are situations where the returned type is "unknown" like in a Linq query or data read from an Excel XML file when "var" may be necessary; otherwise, we want to use the power of a strongly typed language to catch errors early (compile time).
Size:
Color: