Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 3/14/2007 Posts: 24
|
I am using manual looping to perform a complex calculation.Once I find a pattern, I need to draw horizontal lines on the price chart or draw a region. Think of it like the pivot points that I need draw lines for the support/resistance levels. How can I use RealCode to do it? There is no drawing API to use from the documentation. Please help!Thanks,Ken
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You would generally need to not plot anything during the base calculations and then do another loop through the data to plot the desired values once the calculations are complete.
As you stated, Pivot Points are a good example. Take a look at the RealCode in the Class tab for any of the lines being drawn in the Pivot Points Indicator attached to my Tuesday, December 15, 2009 2:57:57 PM ET post in the Pivot point as plotted in Freestockcharts.com topic.
In the PP Indicator, all of the drawing is actually done in just four lines:
For i = 0 To Price.Bar.Count - 2
AddToOutput(Price.Bar.DateValue(i), PP)
Next
AddToOutput(Price.Bar.DateValue(Price.Bar.Count - 1), PP, "PP " & PP.ToString("0.000"))
And if it didn't put a label on the chart, the fourth line wouldn't be necessary at all. you would just have the loop going to Price.Bar.Count - 1 instead of Price.Bar.Count - 2.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 3/14/2007 Posts: 24
|
Hi Bruce:The code is nice but does not work for my situation. The reason being unlike PP which has only 7 lines to draw, in my situation, I have a list of support/resistance lines (unknown ahead of time) based on a complex model calculation. I like to draw them as lines on the price chart so I can visually detect if price hitting those lines. So all I need is an API method to draw a horizontal line (or a rectangle is better)on the price chart when needed. How can I accomplish this? Thanks again!Ken
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
A RealCode Indicator can only draw either one line or one bar. So you have either one value or four values at each data point. You have to have a different indicator for each line.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |