Drawing trend line in the right margin  [SOLVED]

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Drawing trend line in the right margin

Postby arjfca » 14 Mar 2014

Hello

I'm seeking info to resolve my interrogation

I want to draw small square using trend line in the right margin ( free space) on the workspace.

My question how to determine the date and time value for the left part of the square. I got the right value using the getappinfo

Martin
Attachments
DrawSquare.jpg
(258.34 KiB) Downloaded 361 times

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

Re: Drawing trend line in the right margin

Postby TJ » 15 Mar 2014

Hello
I'm seeking info to resolve my interrogation
I want to draw small square using trend line in the right margin ( free space) on the workspace.
My question how to determine the date and time value for the left part of the square. I got the right value using the getappinfo
Martin
Count the bars...
how many bars do you want to offset from the right margin?
then deduct 5 min from each number of bars, and you will have your left-side time coordinate.


(5 min per bar being your chart example)

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Drawing trend line in the right margin

Postby JoshM » 15 Mar 2014

My question how to determine the date and time value for the left part of the square. I got the right value using the getappinfo
I thought about using Symbol_Time_s, but this did not work. However, you can calculate with DateTime (see the small red arrow):

Image

Code: Select all

Variables:
timePerBarMinutes(0),
futureBarTime(0),
oneMinute(ELTimeToDateTime(1));

if (LastBarOnChart_s = true) and (BarStatus(1) = 2) then begin

// Number of minutes each price bar has (assuming minute chart)
timePerBarMinutes = BarInterval;

// Calculating the future bar time.
// Multiplied by 10, so if you have a chart shift of 20 bars, the arrow
// will be halfway.
futureBarTime = ELTimeToDateTime_s(Time_s) +
((timePerBarMinutes * 10) * oneMinute) +
ELDateToDateTime(Date);

// Now we can plot
value1 = Arw_New_s(
JulianToDate(futureBarTime),
DateTime2ELTime_s(futureBarTime),
Close,
True);

end; //: LastBarOnChart
Attachments
scr.15-03-2014 07.17.01.png
(9.27 KiB) Downloaded 391 times

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Resolve: Drawing trend line in the right margin  [SOLVED]

Postby arjfca » 15 Mar 2014

THanks TC / Josh

The solution was to use the new function TL_SetBegin_BN. This one use the bar number instead of date and time as reference.

Code: Select all

R_Space = getappinfo(aiSpaceToRight); //Read the margin space
If R_Space <> 0 then R_Space = r_Space /2; // Use half of the space . R_Space now hold the number of bars in the margin / 2

//To draw a vertical line
If LasBaronchart then begin
TL_SetBegin_BN (LeftLine, BarNumber + R_Space, R_Highest ) ;
TL_SetBegin_BN (LeftLine, BarNumber + R_Space, R_LOwest ) ;

end;
Martin


Return to “MultiCharts”