What does the command “Line” mean and how is it used ?
Forums › ProRealTime English forum › ProBuilder support › What does the command “Line” mean and how is it used ?
- This topic has 11 replies, 4 voices, and was last updated 1 month ago by XORANDNOT.
-
-
10/08/2024 at 10:04 AM #238666
There is a command called “Line” in the command list f(x), when an indicator is coded. But I find nothing in the language documentation. Does anyone know how this command is used and what the parameters are ?
Or, is there a simple way or a simple command that allows calculation of a straight line between two points in an automatic trading system ?
For example, in a 1 second chart, I’d have two points, price = 20000 at Time = 100000, and price = 20100 at Time = 101010, and I want to calculate the value of this line at the current time. Is there a simple command to do this or do I have to calculate the line manually, for example using the Unix time stamp “timestamp” and then calculating the slope of a line between the two points ?
Thank you for any recommendations.
10/08/2024 at 10:06 AM #23866710/08/2024 at 10:13 AM #23866910/08/2024 at 10:40 AM #23868310/08/2024 at 10:41 AM #238684I have just written some small code for a 1 second chart that calculates a line between 2 points of (Price1, Time1) and (Price2, Time2) and returns all values of this line, when time is larger than Time2. Does anyone know a simpler way to do this ?
Calculation of a line after two given points1234567891011121314151617If TIME = Time1 thenTS1 = timestampEndifIf TIME = Time2 thenTS2 = timestampEndifIf TIME > Zeitpunkt2 thenSlope = (Price2 - Price1) / (TS2-TS1)valuenow = Price1 + (slope * (timestamp - TS1))elsevaluenow = closeendifReturn valuenow10/08/2024 at 10:44 AM #238688To calculate the 2 points you need barindex and price and then use those to draw or calculate the line between them by subrtacting the 2 numbers from eatch point from the other point 😛
You can’t do this in a 1 second chart, because there is no new bar at every given second. For many seconds, no bar is shown and barindex does not rise. So you must count the seconds instead of barindex.😛😛😛
1 user thanked author for this post.
10/08/2024 at 10:49 AM #23868910/08/2024 at 11:35 AM #238701Hi…
In the code editor, choosing the ‘All Categories’ via the ‘fx’ icon, brings up a list of available functions.
Some of these functions are indicator functions and some are the Probuilder Keywords.
These keywords sometimes take a limited set of pre-determined value’s, these also appear in the list.
When you look at the ‘fx’ comments for ‘LINE’ , it states, “Line” style.
If you use drawing keywords like, DRAWLINE(x1,y1,x2,y2) you can add following additional parameters after, Coloured(r,g,b,a), Style(Type,Thickness)
In the ‘Style’ syntax, ‘Line’ is the option value of the ‘Type’ of line drawn, ‘Line’ refers to a full/ continuous line.
10/08/2024 at 11:41 AM #23870210/08/2024 at 12:47 PM #238711Following the STYLE documentation link.
Under the heading, ‘Styling Options Available:’
‘LINE’ is the first option, it also states that it is the default style.
This is why all lines appear with this style even if the ‘STYLE’ keyword is not used.
PRC
Regarding the search, you are right that ‘Line’ doesn’t appear with the general search.
The general search doesn’t appear to search the Help/ProBuilder Language Documentation.
‘Line’ doesn’t appear if using Help/ProBuilder Language Documentation search feature either.
PRT
‘Line’ does appear if you use the function search from the code editor however, with the cryptic comment.
Manual
It does appear in the Glossary of keyword on Page 58.
https://assets.prorealtime.com/pdfs/en/probuilder.1718e2f6.pdf
1 user thanked author for this post.
10/08/2024 at 4:25 PM #238733I have seen the LINE command you are talking about, but there’s no instruction, nor indicators, with that exact name. It’s been highlighted being a reserved keyword to be used with the instructio STYLE, as druby said, just to make sure everyone knows it’s a reserved name not to be used to name a variable.
10/09/2024 at 11:32 AM #238765I made a mistake in the code for the calculation of a line between 2 points in a 1 second chart. When you read the 2 points from a line you have manually drawn in a chart, not “Time” has to be taken for the description of the time of a certain point, but “Opentime”, which is the time at the opening of a bar. It is “opentime” what the box for details of a line shows (see image), not the time at the closing of a bar.
So the code should read as follows :
123456789101112131415161718192021Time1 = 105519Price1 = 19041.9Time2 = 111029Price2 = 19058.9If Opentime = Time1 thenTS1 = timestampEndifIf Opentime = Time2 thenTS2 = timestampSlope = (Price2 - Price1) / (TS2-TS1)EndifIf TIME > Time2 thenvaluenow = Price1 + (slope * (timestamp - TS1))elsevaluenow = closeendifReturn valuenowThis code delivers the future points of a line manually drawn in a 1 second chart (see image), after the time of point 2. Before this time, the line can of course not be calculated, and therefore I have set all values before TIME2 to “close”.
“valuenow” can be used in an automatic trading system for the current value of this line you have drawn before in a chart.
1 user thanked author for this post.
-
AuthorPosts