Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

How to write a Real Code indicator giving price.close / (price.close at left end of chart) Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
SDRODIMER
Posted : Thursday, October 19, 2017 8:41:14 PM
Platinum Customer Platinum Customer

Joined: 2/14/2005
Posts: 169

Hi,

Here's a blocks diagram that I would like to convert to a RC indicator:

Didn't find a way to do it in RC.

Would you give it a try?

 

Steve

 

 

Bruce_L
Posted : Friday, October 20, 2017 9:49:37 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

The following should be very near or match the values returned by indicator on the chart. Note however that ZoomStartDate has a chart context and will not work anyplace besides the chart.

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:GAIN
'|******************************************************************
'#RECALC_ON_ZOOM_SCROLL
Static Basis As Single
If isFirstBar Then
	Basis = Single.NaN
End If
If Price.DateValue = ActiveChart.ZoomStartDate Then
	Basis = Price.Close
End If
Plot = Price.Close / Basis


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
SDRODIMER
Posted : Friday, October 20, 2017 9:53:21 PM
Platinum Customer Platinum Customer

Joined: 2/14/2005
Posts: 169

Hi,

So far, so good.  It worked in a chart that I tried, but as you pointed out, only in a chart context.

 

Is there a way to also be able to get a watchlist column from this indicator or something similar?

 

I was able to do that with the following blocks indicator.  The Cumlator block turns off AutoSize which allowed the indicator to have the same values in a WL data column as the chart values.

 

Problem was that, for some unknown reason, the WL column kept blinking and I could not find a way to turn that off.  Is there a command or RC statement to turn off the blinking?

 

 

Steve

Bruce_L
Posted : Monday, October 23, 2017 9:08:11 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

No, there isn't any sort of command I am aware of to get rid of the blinking. The WL Column really doesn't like having to reference a the chart context even if it comes from a Block Diagarm. It will do it, but as you have seen, only begrundingly.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
SDRODIMER
Posted : Tuesday, October 24, 2017 11:55:57 AM
Platinum Customer Platinum Customer

Joined: 2/14/2005
Posts: 169

OK

 

I'm sure the blinking was programmed in to detect / warn a programmer or user of some condition that the code generates.  Any idea what the purpose is?

 

I have not run into it with any other RC or blocks indicators I have used.

 

Thx

Bruce_L
Posted : Tuesday, October 24, 2017 12:14:24 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

I really doubt that is the case. It just has to keep refreshing because it is trying to pull data using a block using a chart context.

Since that block doesn't have a WatchList context it just doesn't behave well on in the WL.It is designed to work within a chart, but each time it switches symbols to calculate the next symbol in the WatchList, the context of the block changes to a different chart.

That is why the chart will WL Column will start working if you unlink it from the chart. It is a bit surprising it works at all while still linked to the chart.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
SDRODIMER
Posted : Tuesday, October 24, 2017 9:01:52 PM
Platinum Customer Platinum Customer

Joined: 2/14/2005
Posts: 169

OK,  but other blocks indicators that I've put into WL data columns didn't blink.

 

The block that seems to set off the blinking is the Value for Date block which is exactly the one I needed to anchor some calcs to the chart at the left end.

Unlinking the indicator using the WL command does turn off the blinking but then I am locked into whatever left end date was active when that command was done, so then if I subsequently change the chart zoom, I have to repeat the process of creating a WL data column for the indicator in question, etc.

I'll work with it when needed.

 

Thx 4 your help!

 

Steve

Bruce_L
Posted : Wednesday, October 25, 2017 9:12:53 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

Something like the following would allow you to adjust the date without requiring a chart context.

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:GAIN
'|******************************************************************
'# StartDate = UserInput.Date
Static Basis As Single
If isFirstBar Then
	Basis = Single.NaN
End If
If Single.IsNaN(Basis) = True AndAlso _
	Price.DateValue >= StartDate Then
	Basis = Price.Close
End If
Plot = Price.Close / Basis


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.