Trendlines with input interval  [SOLVED]

Questions about MultiCharts and user contributed studies.
evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Trendlines with input interval

Postby evdl » 09 Dec 2012

I draw some trendlines on the chart (see attachment). What I try to achieve is to calculate the pricerange that is on the chart and divide this in intervals (that can be set as an input). And then plot these on the chart.

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?
Attachments
Trendlines at input interval.png
(84.69 KiB) Downloaded 235 times

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Trendlines with input interval  [SOLVED]

Postby TJ » 09 Dec 2012

look under
Pivots, Levels, Support & Resistence

there should be lots of examples

http://www.tradersxchange.com/index.php


Return to “MultiCharts”