Registered User Joined: 5/15/2009 Posts: 11
|
Request assistance to create the following screens in real time, using 3 minute data
Screen 1
a) slope of 50 period sma is negative
b) 4, 9 & 18 period sma all < 50 period sma
c) MACD histogram changes from negative to > 0
Screen 2
a) slope of 50 period sma is negative
b) 4, 9 & 18 period sma all < 50 period sma
c) MACD histogram > 0
d) 4 period sma crosses above 9 period sma
Thanks in advance for the help
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
QUOTE (gojotoby) Screen 1
a) slope of 50 period sma is negative
b) 4, 9 & 18 period sma all < 50 period sma
c) MACD histogram changes from negative to > 0
If you Drag and Drop the Moving Averages and MACD Histogram into the Code tab of the RealCode Editor, it should create something similar to the first five lines of the following RealCode Rule (I had to change the variable names assigned to the Moving Averages so they weren't all just MA):
'# MA4 = indicator.MovingAverage.4
'# MA9 = indicator.MovingAverage.9
'# MA18 = indicator.MovingAverage.18
'# MA50 = indicator.MovingAverage.50
'# MH = indicator.MACDHistogram
If MA50.Value < MA50.Value(1) AndAlso _
MA4.Value < MA50.Value AndAlso _
MA9.Value < MA50.Value AndAlso _
MA18.Value < MA50.Value AndAlso _
MH.Value(1) < 0 AndAlso _
MH.Value > 0 Then Pass
QUOTE (gojotoby) Screen 2
a) slope of 50 period sma is negative
b) 4, 9 & 18 period sma all < 50 period sma
c) MACD histogram > 0
d) 4 period sma crosses above 9 period sma
If you Drag and Drop the Moving Averages and MACD Histogram into the Code tab of the RealCode Editor, it should create something similar to the first five lines of the following RealCode Rule (I had to change the variable names assigned to the Moving Averages so they weren't all just MA):
'# MA4 = indicator.MovingAverage.4
'# MA9 = indicator.MovingAverage.9
'# MA18 = indicator.MovingAverage.18
'# MA50 = indicator.MovingAverage.50
'# MH = indicator.MACDHistogram
If MA50.Value < MA50.Value(1) AndAlso _
MA4.Value < MA50.Value AndAlso _
MA9.Value < MA50.Value AndAlso _
MA18.Value < MA50.Value AndAlso _
MH.Value > 0 AndAlso _
MA4.Value > MA9.Value AndAlso _
MA4.Value(1) <= MA9.Value(1) Then Pass
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 5/15/2009 Posts: 11
|
Bruce,
I started with the second of the 2 requests.
When I enter the code into real code editor, I receive the following errors:
Name 'MA50' is not declared for lines 6,6,7,8,9
Name 'MA9' is not declared for lines 8,11,12
Name 'MA18' is not declared for lines 9
Please help to resolve the errors.
I get similar errors when I try the 1 st of the 2 requests.
Thanks
Stan
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You don't type in the first five lines. You Drag and Drop the charted versions of the Moving Averages and MACD Histogram from the Charts into the Code tab of the RealCode Editor to create those first five lines. When you first do so, they'll look something like (they probably won't be exact as the lines will depend on the actual names of your charted Moving Averages):
'# MA = indicator.MovingAverage.4
'# MA = indicator.MovingAverage.9
'# MA = indicator.MovingAverage.18
'# MA = indicator.MovingAverage.50
'# MH = indicator.MACDHistogram
But you'll have to change the variable names assigned so all of the Moving Averages aren't using the same Variable name. I used the period of the Moving Average to differentiate them and ended up with the following:
'# MA4 = indicator.MovingAverage.4
'# MA9 = indicator.MovingAverage.9
'# MA18 = indicator.MovingAverage.18
'# MA50 = indicator.MovingAverage.50
'# MH = indicator.MACDHistogram
Then I referenced the charted Indicator by using the variable names assigned in the rest of the RealCode.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 5/15/2009 Posts: 11
|
Bruce,
OK, I've now created the rules without errors. How do I run them? I tried scanning and filtering on the entire list of all stocvks without any results (this was done after market close). Not sure if it needs to be run in real time?
My intent with this code is to use it in real time on 3 minute charts, with a watchlist of about 20-50 stocks, and will want an alert or indication of when the rules is triggered as true for any of the stocks within the watchlist. Please advise how I should proceed.
Thanks
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
It doesn't need to be run while the market is open.
You didn't mention your MACD Histogram settings, so I'm using what was there when added it to the Chart (Simple MACD Histogram 12,26,9). When I Drag and Drop the first Rule to the Watchlist and select Scan with All Items in System selected and a 3-Minute Time Frame, the following symbols currently have a Watchlist Light: EVG, SQNM, CLDX, NGAS, REFR, MNTA, CHTP, KNOT, KNO, SWKS, EXT, ACOR, BAF, MXT, PDLI, MJT, DIGA, CPSI, SSBI, JFT, LEDR, PMO, MGRC, WRLS, POOL, PWOD, TRBR, LOAN, TSEM, TRU, MTT, EXEL, MNE, GTIV, $TICK, NII, COSI, TRA, HARL, OXM, MYGN, IBA, AXU, UTHR, DTF, GT, CYNO, ECF, ALXN, ATK, EJ, LAVA, QUIX and COGT.
When I do the same thing with the second Rule, I get the following symbols with Watchlist Lights: MIN, EVG, FFC, AMNB, FBN, OVX-X, LPHI, GOLF, IGI, STSI, CFBK, BIE, UCBH, CSBK, ORCD, KMM, MNTA, IRDM, RGCI, CLDX, CSA, NGAS, DVA, CLFD, CFW, IMGN, TOD, SQNM, OMCL, HMH, SENO, ROSE, RCKY, MR, LNCE and REFR.
It took quite a long time do run using the All Items in System Watchlist, but runs very quickly on a small Watchlist of the size you are describing. The "alert" is simply that a Watchlist Light appears by the symbol in the Watchlist.
Rule Basics
The RealCode Programmers Reference has a section on Simulating an Alert with RealCode Rules which covers one method of creating alerts in StockFinder.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|