Platinum Customer
Joined: 10/20/2008 Posts: 357
|
How to create that condition that as long as donch moves up, we have a continouos true condition. the condition becomes untrue i.e. false only when the MA falls. Thank you.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You could use something to the logic in the following to create your own RealCode Condition.
'# Cumulative
'# MA = chart.MovingAverage
Static Up As Boolean
If isFirstBar OrElse _
MA.Value < MA.Value(1) = True Then
Up = False
Else If MA.Value > MA.Value(1) = True Then
Up = True
End If
If Up = True Then
Pass
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Platinum Customer
Joined: 10/20/2008 Posts: 357
|
Bruce, Somehow this returned that result that included the true condition even when the MA fell. could you please look into it. My MA was ma 1 of ratio of price to price for symbol. Have a nice long weekend! Thank you.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
It absolutely does not do so on my computer. It just works and it seems to work correctly. Do you have specific example symbols where it is not working for you? If so, I would also need the settings of the Donchian Channels and the parent indicator of the Donchian Channels to try and troubleshoot the issue on my end.
Is the Donchian Channel of something other than price?
RealCode rounds imported indicators to two digits past the decimal place, so it is possible for the moving average of the lower Donchian Channel to have moved down and not trigger the change from true to false if the value of the moving average before and after are the same when rounded to two digits past the decimal. This should only happen if the Donchian Channel is of something besides common stock prices however.
The only way to get around this rounding is to not import an indicator into the RealCode and to calculate the lower Donchian Channel value within the RealCode. The following RealCode Condition does this for price (but you generally shouldn't need it for price).
'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.1 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Lower Donchian Increasing
'|******************************************************************
'# Cumulative
'# Period = UserInput.Integer = 15
'# Offset = UserInput.Integer = 1
Static Up As Single
If isFirstBar Then
Up = False
End If
If CurrentIndex > Period + Offset Then
If Price.MinLow(Period, Offset) > _
Price.MinLow(Period, Offset + 1) Then
Up = True
Else If Price.MinLow(Period, Offset) < _
Price.MinLow(Period, Offset + 1) Then
Up = False
End If
If Up = True Then
Pass
End If
Else
SetIndexInvalid
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|