Draw Trendline from one pivot to the next pivot  [SOLVED]

Questions about MultiCharts and user contributed studies.
rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

Draw Trendline from one pivot to the next pivot

Postby rkhan » 20 Jun 2014

I am trying to draw a trend line from one pivot to the next pivot

So i have obtain

My code is pretty simple i've pasted it below, the problem i am having is the i am getting multiple lines, from both high to low and low to high
So it goes from the low to high, and then i get 2,3,4, lines all going from the same low to high point, but just displaced by one bar.

What i think is happening, is that as it plays on each daily bar, it redraws the same line, but displaced. So i don't know how to get rid of these extra lines

Code: Select all

LastHighPivotBar = PivotHighVSBar(1,H,minorStrength,minorStrength,Lookback);
LastHighPivot = PivotHighVS(1,H,minorStrength,minorStrength,Lookback);
lastHighPivotDate = CalcDate(date, -LastHighPivotBar);



LastLowPivotBar = PivotLowVSbar(1,L,minorStrength,minorStrength,Lookback);
LastLowPivot = PivotLowVS(1,L,minorStrength,minorStrength,Lookback);
lastLowPivotDate = CalcDate(date, -LastLowPivotBar );


Hi_line = TL_new(lastLowPivotDate ,time,LastLowPivot,lastHighPivotDate ,time,LastHighPivot);

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

Re: Draw Trendline from one pivot to the next pivot

Postby TJ » 20 Jun 2014

I am trying to draw a trend line from one pivot to the next pivot

So i have obtain

My code is pretty simple i've pasted it below, the problem i am having is the i am getting multiple lines, from both high to low and low to high
So it goes from the low to high, and then i get 2,3,4, lines all going from the same low to high point, but just displaced by one bar.

What i think is happening, is that as it plays on each daily bar, it redraws the same line, but displaced. So i don't know how to get rid of these extra lines

Code: Select all

LastHighPivotBar = PivotHighVSBar(1,H,minorStrength,minorStrength,Lookback);
LastHighPivot = PivotHighVS(1,H,minorStrength,minorStrength,Lookback);
lastHighPivotDate = CalcDate(date, -LastHighPivotBar);



LastLowPivotBar = PivotLowVSbar(1,L,minorStrength,minorStrength,Lookback);
LastLowPivot = PivotLowVS(1,L,minorStrength,minorStrength,Lookback);
lastLowPivotDate = CalcDate(date, -LastLowPivotBar );


Hi_line = TL_new(lastLowPivotDate ,time,LastLowPivot,lastHighPivotDate ,time,LastHighPivot);
You will need a "Conditional" filter.

You draw the line only if the "Condition" is met.

eg:

Code: Select all


If Condition1 = true then
begin
Hi_line = TL_new(lastLowPivotDate ,time,LastLowPivot,lastHighPivotDate ,time,LastHighPivot);
end;

rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

Re: Draw Trendline from one pivot to the next pivot

Postby rkhan » 20 Jun 2014

Dear Sir,

But i want to draw all swing high to lows like a zig zag
So i don't want to draw them only on a certain condition.

I want to draw them all

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

Re: Draw Trendline from one pivot to the next pivot

Postby TJ » 20 Jun 2014

Dear Sir,
But i want to draw all swing high to lows like a zig zag
So i don't want to draw them only on a certain condition.
I want to draw them all
Please post a mock up chart with the lines you would like to see.
You will soon see the conditions you needed.

rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

Re: Draw Trendline from one pivot to the next pivot  [SOLVED]

Postby rkhan » 20 Jun 2014

Dear Sir,

I have worked it out,

The code line below was wrong,

lastHighPivotDate = CalcDate(date, -LastHighPivotBar)

This correct code is
lastHighPivotDate = date[LastHighPivotBar]

This has now worked.


Return to “MultiCharts”