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.

Steps

- 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
{
return;
}

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)

Back







QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2012 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items