Click here to Login

How to create a custom trendline

Updated on 2011-04-30

I know there is already a build-in trendline in QuantShare. But, I wanted to show you how to create your own using the Custom drawing tools plug-in. I will also show you how to add and create more features for this trend line.


- Select "Tools" then "Custom Drawing Tools".
- Click on "Add", type "MyTrendLine" then click on "Save".
- Type the following formula:

if(Functions.ClickPositions.Length == 0) // No click on the chart -> Exit

PointPosition point1 = Functions.ClickPositions[0]; // First click location
PointPosition point2 = Functions.CursorPosition; // Second click set Mouse cursor
if(Functions.ClickPositions.Length > 1) // There is a second click
point2 = Functions.ClickPositions[1]; // Second click associated with point2
Functions.FinishDrawing(); // Finish drawing after the second click

// Draw line using point1 and point2 locations
LineObj line = Functions.PaneObject.DrawLine("Line1", point1.X, point1.Y, point2.X, point2.Y);

// If point1 Y value is higher than point2 Y value then set the line color to Red
if(point1.Y > point2.Y)
line.Line.Color = Color.Red;
else // Otherwise we set the line color to Green
line.Line.Color = Color.Green;

Adding our trendline to the bookmark panel

- Right click on the Bookmark panel (bar under the menu) then click on "Add Shortcut".
- Select "Drawing Tools", keep "Create a shortcut for an existing..." checked then click on "OK".
- Select "MyTrendLine" item then click on "Load selected item".
- To use the drawing item, simply double click on it then click on a chart.

no comments (Log in)


Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2015
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.