Accessing values in the Trendline Indicator
Accessing values in the Trendline Indicator
06 Feb 2014, 18:33
Hi,
Is it at all possible to access the values in the trendline indicator? /algos/indicators/show/359
It would be a huge advantage to able to use the extreme values of the trendline in cbots. I have tried but it doesn't seem to be working for me.
Can anyone help me with the code (if its possible) please?
Thanks!
Replies
Delta_Gamma
13 Feb 2014, 13:10
Hi, thanks for the reply.
Can you please help me or direct me to where I can find out how to modify the indicator in that way? I am afraid I have no idea where to begin.
Perhaps you could provide some code?
Thanks again!
@Delta_Gamma
Delta_Gamma
13 Feb 2014, 13:17
Hi sorry to post again but I forgot about this..
I am also trying to get parameters for the Linear Regression Channel indicator. I appreciate that these indicators have been posted but my problem is I cannot use them in my robot because they have no parameters, I have checked the documentation but I am still unsure what to do. For example, this is the code from the Linear Regression Channel
protected override void Initialize() { // Parse color from string, e.g. "Yellow", "Green", "Red". string must start with large letter, "Red" is valid, "red" - not. if (!Enum.TryParse(Color, out color)) color = Colors.Yellow; } public override void Calculate(int index) { if (IsLastBar) LinearRegression(MarketSeries.Close); } private void LinearRegression(DataSeries series) { // Linear regresion double sum_x = 0, sum_x2 = 0, sum_y = 0, sum_xy = 0; int start = series.Count - Bars; int end = series.Count - 1; for (int i = start; i <= end; i++) { sum_x += 1.0 * i; sum_x2 += 1.0 * i * i; sum_y += series[i]; sum_xy += series[i] * i; } double a = (Bars * sum_xy - sum_x * sum_y) / (Bars * sum_x2 - sum_x * sum_x); double b = (sum_y - a * sum_x) / Bars; // Calculate maximum and standard devaitions double maxDeviation = 0; double sumDevation = 0; for (int i = start; i <= end; i++) { double price = a * i + b; maxDeviation = Math.Max(Math.Abs(series[i] - price), maxDeviation); sumDevation += Math.Pow(series[i] - price, 2.0); } double stdDeviation = Math.Sqrt(sumDevation / Bars); // draw in future end += 20; double pr1 = a * start + b; double pr2 = a * end + b; if (ShowCenter) { ChartObjects.DrawLine("center", start, pr1, end, pr2, color, LineThickness, LineStyle.Lines); } if (ShowChannel) { ChartObjects.DrawLine("top", start, pr1 + maxDeviation, end, pr2 + maxDeviation, color, LineThickness, LineStyle.Solid); ChartObjects.DrawLine("bottom", start, pr1 - maxDeviation, end, pr2 - maxDeviation, color, LineThickness, LineStyle.Solid); } if (ShowDeviantion) { ChartObjects.DrawLine("dev-top", start, pr1 + stdDeviation, end, pr2 + stdDeviation, color, LineThickness, LineStyle.DotsVeryRare); ChartObjects.DrawLine("dev-bottom", start, pr1 - stdDeviation, end, pr2 - stdDeviation, color, LineThickness, LineStyle.DotsVeryRare); } } }
All I want to be able to do is make it so my cbot buys when the price is under the bottom parallel line and sells when the price is above the top parallel line. I'm not sure how to convert the ChartObject into a parameter.
Thanks.
@Delta_Gamma
Spotware
13 Feb 2014, 14:06
We can recommend you to post a job here: /jobs/
Also you can contact one of cAlgo consultants: /consultants/
@Spotware
Delta_Gamma
12 Feb 2014, 08:08
Any chance of a reply?
It's been a week.
@Delta_Gamma