Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 7/26/2006 Posts: 23
|
Bruce,
I would like to have a graphical indicator (arrowhead down) that points down when one 5MA (which is advanced one bar) crosses up another 5MA and a second indicator (arrowhead up) when the advanced MA crosses down the other 5MA. I would like these indicators to be color orange and blue repectively.
Eliezer
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You can create the Rules for this by simply Dragging and Dropping one of the Moving Averages onto the other and selecting Create Rule | Crossing Up Through or Create Rule | Crossing Down Through.
The only way I know of to create the Arrows you mention on the Chart would be by using Block Diagram based Indicators.
- Right-click on the Chart and select Create New | Indicator Block Diagram.
- Give the Indicator a Name.
- Change the Plot Type to True Markers.
- Select OK.
- Left-click and drag on the input to the True Markers Block.
- Select Link From Another Tool | (one of your Drag and Drop Rules).
- Optionally left-click and drag on the input to the Screen Location Block.
- Select Link From Another Tool | (one of the Moving Averages).
- Close the Block Diagram.
- Right-click on the True Marker Indicator and select Copy.
- Close the Pane with the True Marker Indicator.
- Right-click in the Price History Pane and select Paste.
- Right-click in the Price History Pane and select Paste (a second time).
- Right-click on the second of the Pasted True Marker Indicators and select Block Diagram.
- Left-click and drag on the input to the True Markers Block.
- Select Link From Another Tool | (the other of your Drag and Drop Rules).
- Close the Block Diagram.
- Right-click on each of the True Markers Blocks in turn and select Edit.
- Adjust the Direction and Color settings as desired.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 7/26/2006 Posts: 23
|
Bruce,
The following program does not return a value. In particular, the variables TH, TL, ATR do not have a value different from zero. And I wouldn't be surprised if the variable 'resistance' also did not return a value different from zero. Could you help fix this code so that I can run it and get positive results in the backscanner.
Eliezer
Static upcount As Integer = 0
Static ATR As Single = 0
Dim TH As Single
Dim TL As Single
Dim resistance As Single = 0
If currentindex > 0 AndAlso Price.Close(1) >= Price.Open(1) Then
upcount += 1
Else
upcount = 0
End If
If upcount >= 3 Then
For i As Integer = 1 To 5
TH = System.Math.Max(price.high(i), price.Close(i + 1)) AndAlso _
TL = System.Math.Min(price.low(i), price.close(i + 1)) AndAlso _
ATR += (TH - TL)
Next i
ATR = ATR/5
Else
ATR = 0
End If
If upcount >= 3 AndAlso _
price.Close > price.Open AndAlso _
price.TradeRange >= ATR AndAlso _
price.Close - price.Open > price.TradeRange * 0.8 AndAlso _
system.Math.Min(price.open(-1), price.Close(-1)) > price.Close AndAlso _
price.Close(-2) < price.Open(-2) AndAlso _
price.Close(-2) <= price.Close AndAlso _
system.Math.Max(price.close(-3), price.Open(-3)) < resistance Then pass
' price.open (-2) - price.close(-2) > price.traderange(-2) * 0.8 Then pass IS NOT REQUIRED
'Sequence of statements find
' First candle is red
' The range of the first candle >= the Average True Range
' The body of the first candle is >= 0.8*(high-low)
' There is a gap between the bodies of the first candle and the second - candle(-1)
' The third candle must be red
' The body of the third candle, candle(-2), must penetrate or touch the body of the first green candle
' The maximum of the body of the fourth candle must be less than the high of the star, candle(-1)
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
...
...
system.Math.Min(price.open(-1), price.Close(-1)) > price.Close AndAlso _
price.Close(-2) < price.Open(-2) AndAlso _
price.Close(-2) <= price.Close AndAlso _
system.Math.Max(price.close(-3), price.Open(-3)) < resistance Then pass
At first glance your code is using future values.
Price.close(1) is yesterday's close
Price.close(-1) is tomorrow's close.
Is that your intent?
|
|
Registered User Joined: 7/26/2006 Posts: 23
|
jas051,
I intend to use future values because the condition that upcount >= 3 leaves the code at the beginning of a three candle pattern, so I have to examine the future candles in the pattern. In backscan it works out alright if I put the condition that the code open on the 3rd candle.
Eliezer
Bruce
I found that the first two sections of the code are working alright by making an indicator with the same code with a plot = ATR after the 2nd End If. But the above code gives an error message 'End of statement expected' for the line of code ATR += TH-TL; I didn't get this message in the indicator.
Eliezer
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
QUOTE (edrichmond) jas051,
I intend to use future values because the condition that upcount >= 3 leaves the code at the beginning of a three candle pattern, so I have to examine the future candles in the pattern. In backscan it works out alright if I put the condition that the code open on the 3rd candle.
Eliezer
...
...
If you are buying on the 3rd day you are cheating, and should have excellent scan results. You would need to buy on open on the 4th day to avoid using future information.
You can also rewrite the code to avoid using future data be adding 3 to all offsets. So for example Price.close(-3) would become price.close(0) or price.close.
Also Stockfinder offers ATR so you could use the ATR indicator instead of computing your own.
|
|
Registered User Joined: 7/26/2006 Posts: 23
|
Bruce,
I still have the question about the error message in the above realcode rule. I can't use the indicator Average True range in my realcode - at least I don't know how
Eliezer
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
edrichmond,
I'm not a programmer. That said, I would think the End of statement expected is a result of the "AndAlso _"s at the end of the preceeding two lines (as eliminating them causes the error message to go away).
I'm assuming you are commenting out the If Then Pass structure when attempting to check the Values by Plotting this as an Indicator as you made no mention of a "Name 'Pass' is not declared." error message. The RealCode itself seems intended for use as a RealCode Rule.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |