Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 8/3/2006 Posts: 79
|
I'm trying to learn to write some simple code. First for price to close above a XAvg and second to close below a XAvg.
First to close above
'# PC = indicator.unlinked.PriceClose
'# MA = indicator.unlinked.MovingAvg(30)
'# Period = userinput.integer = 30
If price.Close > price.xavg(period) Then pass
Second to close below
'# PC = indicator.unlinked.PriceClose
'# MA = indicator.unlinked.MovingAvg(30)
'# Period = userinput.integer = 30
If price.Close < price.xavg(period) Then pass
The second one appears to work but the first one doesn't. Any suggestions?
|
|
Administration
Joined: 9/18/2004 Posts: 3,522
|
You're doing it the hard way. You don't need the PC and MA variables, just use this code:
'# Period = userinput.integer = 30
If price.Close > price.xavg(period) Then pass
if price.close < price.xavg(period) then pass
Ken Gilb (Kuf) Chief Software Engineer - Worden Brothers Inc. Try/Catch - My RealCode Blog
|
|
Registered User Joined: 8/3/2006 Posts: 79
|
Thanks, I was trying to experiment with draggign indicators into the code box. But couldn't get them to work. Could you explain why I keep getting " Operator '>' is not defined for type 'WBI.CommonBlocks.CommonBlocks.ScriptingLine' " and also when I use "Then Pass" I get "pass" is not declared.??
I really appreciate the great job you all have done with SF5.
Mac
|
|
Administration
Joined: 9/30/2004 Posts: 9,187
|
If you're getting "pass" not declared, you're trying to code a RealCode condition inside of the indicator editor.
|
|
Guest-1 |