Instead of drawing these trendlines manually every day and on the day itself. I would like to have an indicator to do the work for me.
I know how to draw a trendline on the chart. The problem arises to determine the price range on the chart and then divide this by the input interval. In this way:
If price range is 7500 - 7520 and input is 5:
7500
7505
7510
7520
If input is 2:
7500
7502
7504
7506 etc.
And then plot these. The amount of trendlines is every day (this even changes on the day) different, because the pricerange on the chart changes all the time. So the amount of trendlines to be drawn on the chart is dynamic.
Made some code to start with.
Code: Select all
inputs:
Round_to_value(5);
variables:
Trendline_1(0),
Trendline_2(0),
Start_time(lastbaronchart),
End_time(Getappinfo(airightdispdatetime)),
Highest_value_on_chart(0),
Lowest_value_on_chart(0),
Chart_pricerange(0);
If date = currentdate then begin
// Determine pricerange today
Highest_value_on_chart = getappinfo(aihighestdispvalue);
Lowest_value_on_chart = getappinfo(ailowestdispvalue);
Chart_pricerange = Highest_value_on_chart - Lowest_value_on_chart;
How to do?
divide the chart_pricerange into the interval that is set in "round_to_value" and plot the
trendlines
//Trendlines:
trendline_1 = TL_New(date,start_time,"result calculation divide",date,end_time,"result calculation divide");
trendline_2 = TL_New(date,start_time,"result calculation divide",date,end_time,"result calculation divide");
Trendline_3
Trendline_4 etc.
//Trendlines formatting:
TL_Setcolor(trendline_1,RGB(223,87,217)); {colorsetting purple}
TL_Setcolor(trendline_2,RGB(161,238,253)); {colorsetting lightblue}
Value1 = TL_setStyle(trendline_1, 4); {line style}
Value2 = TL_setstyle(trendline_2, 5); {line style}
end;
The trendlines I have drawn are from the left to the right. If possible I like to have these from last price to the end of the chart that is on the screen to get a less busy chart. Someone who already did this or want to share his/her idea about this?