NexusFi: Find Your Edge


Home Menu

 





Drawing parallel lines


Discussion in Sierra Chart

Updated
    1. trending_up 1,562 views
    2. thumb_up 1 thanks given
    3. group 1 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Drawing parallel lines

  #1 (permalink)
 Grantx 
Reading UK
Legendary no drama Llama
 
Experience: None
Posts: 1,787 since Oct 2016
Thanks Given: 2,826
Thanks Received: 5,059

I have managed to draw a horizontal line using sc.UseTool and DRAWING_HORIZONTALLINE
Does anyone know how to draw 2 additional lines that mirror the first line - one being +50 ticks away and the other being -50 ticks away?

 
Code
#include "sierrachart.h"   
SCDLLName("Grantx Custom Study") 
SCSFExport scsf_TemplateFunction(SCStudyInterfaceRef sc) 
{ 
  // Section 1 - Set the configuration variables and defaults 
  		if (sc.SetDefaults)
	{
		sc.GraphName = "Stop and Loss range tool";
		sc.GraphRegion = 0;
		sc.AutoLoop = 0; //No automatic looping
		return;
	}
	// Do data processing	
	int BarIndex;
	int& r_DrawingLineNumber = sc.GetPersistentInt(1);
	if (r_DrawingLineNumber != 0 && sc.LastCallToFunction)
	{
		// Be sure to remove the Text drawing added as a user drawn drawing
		sc.DeleteUserDrawnACSDrawing(sc.ChartNumber, r_DrawingLineNumber);
		return;//No further processing needed in this case.
	}
	int& r_LineNumber = sc.GetPersistentInt(2);
	s_UseTool Tool;
	Tool.ChartNumber = sc.ChartNumber;
	Tool.DrawingType = DRAWING_HORIZONTALLINE;
	if (r_LineNumber != 0)
		Tool.LineNumber = r_LineNumber;
	// Must set user drawn flag
	Tool.AddAsUserDrawnDrawing = 1;
	Tool.BeginValue = 2875;
	Tool.Color = COLOR_KHAKI;
	Tool.AddMethod = UTAM_ADD_ONLY_IF_NEW;
	sc.UseTool(Tool);
	//Remember the line number which has been automatically assigned
	r_LineNumber = Tool.LineNumber;
	// If the user drawn line exists, we will add a message to the Message Log
	if (sc.UserDrawnChartDrawingExists(sc.ChartNumber, r_DrawingLineNumber))
	{
		sc.AddMessageToLog("User drawn Text exists.", 0);
	}
	if (sc.ChartDrawingExists(sc.ChartNumber, r_DrawingLineNumber))
	{
		sc.AddMessageToLog("Error: User drawn Text should not exist when calling the ChartDrawingExists().", 1);
	}
}

Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
What broker to use for trading palladium futures
Commodities
How to apply profiles
Traders Hideout
Quant vue
Trading Reviews and Vendors
 
  #2 (permalink)
 mkata 
Columbus, OH
 
Experience: Intermediate
Platform: SierraChart
Trading: CL
Posts: 35 since May 2013
Thanks Given: 153
Thanks Received: 24

This may be a little easier to program via a subgraph study. Is there a reason you want to use the Tool function?

Reply With Quote
  #3 (permalink)
 Grantx 
Reading UK
Legendary no drama Llama
 
Experience: None
Posts: 1,787 since Oct 2016
Thanks Given: 2,826
Thanks Received: 5,059



mkata View Post
This may be a little easier to program via a subgraph study. Is there a reason you want to use the Tool function?

Im adding it as a user drawn drawing so that I can drag it around the chart. I dont like the built in risk reward tool that Sierra has so I want to create my own.

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #4 (permalink)
 mkata 
Columbus, OH
 
Experience: Intermediate
Platform: SierraChart
Trading: CL
Posts: 35 since May 2013
Thanks Given: 153
Thanks Received: 24

Would you be open to using the already existing rectangle tool with the draw midline option checked?

Reply With Quote
  #5 (permalink)
 Grantx 
Reading UK
Legendary no drama Llama
 
Experience: None
Posts: 1,787 since Oct 2016
Thanks Given: 2,826
Thanks Received: 5,059


mkata View Post
Would you be open to using the already existing rectangle tool with the draw midline option checked?

Needs to be adjustable entry, exit and target parameters. I tried implementing another sc.UseTool(Tool) instance but that didnt work. I dont know if you can add a bunch of different tools like 3 seperate horizontal lines and then just add them using the one sc.UseTool(Tool).

Problem is that I cant debug and step through the code. The help file is also a tsunami of confusing text written by a schizzo

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #6 (permalink)
 mkata 
Columbus, OH
 
Experience: Intermediate
Platform: SierraChart
Trading: CL
Posts: 35 since May 2013
Thanks Given: 153
Thanks Received: 24

For what you want to do your function would need to call 3 separate horizontal line tools. Easy enough. This is not the problem though.

The main problem is that they are not going to move as one unit that you can drag & drop around the screen.

Each drawing tool has built in levels that define that tool. the Horizontal Line Tool is built as a single line, therefore you
would need 3 separate UseTools. However even if you did this and gave them the same line number they still are not going to move
as a single unit, only one of the lines would move.

You are going to need to use another tool that has multiple levels built in. This will allow you to move the tool as one unit.
Based on your example, as long as your target and stop are equal distance the ideal candidate would be the parallel lines/rays with
one retracement level set at 50% (your entry level). Another candidate could be the rectangle tool with the midpoint checked.
Basically any tool that would provide multiple visual levels with a low, middle, high.

I suggest looking at and playing around with the parallel lines example.

Reply With Quote
  #7 (permalink)
 Grantx 
Reading UK
Legendary no drama Llama
 
Experience: None
Posts: 1,787 since Oct 2016
Thanks Given: 2,826
Thanks Received: 5,059


mkata View Post
For what you want to do your function would need to call 3 separate horizontal line tools. Easy enough. This is not the problem though.

The main problem is that they are not going to move as one unit that you can drag & drop around the screen.

Each drawing tool has built in levels that define that tool. the Horizontal Line Tool is built as a single line, therefore you
would need 3 separate UseTools. However even if you did this and gave them the same line number they still are not going to move
as a single unit, only one of the lines would move.

You are going to need to use another tool that has multiple levels built in. This will allow you to move the tool as one unit.
Based on your example, as long as your target and stop are equal distance the ideal candidate would be the parallel lines/rays with
one retracement level set at 50% (your entry level). Another candidate could be the rectangle tool with the midpoint checked.
Basically any tool that would provide multiple visual levels with a low, middle, high.

I suggest looking at and playing around with the parallel lines example.

What if I added the first line at the last bar and then the other two lines reference that first one. It all depends if one tool can reference the price level of another tool.....surely? There is a built in study called "Study Subgraph Add" which does just this but how would I incorporate this into my code?

pseudo code:
EntryLinePrice = LastBarClosingPriceLevel;
TargetLinePrice = EntryLinePrice + 80 ticks;
StopLinePrice = EntryLinePrice - 50 ticks;

Ill try this and if it fails then the fib retrace or extension tool might do the job.

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #8 (permalink)
 mkata 
Columbus, OH
 
Experience: Intermediate
Platform: SierraChart
Trading: CL
Posts: 35 since May 2013
Thanks Given: 153
Thanks Received: 24


Grantx View Post
It all depends if one tool can reference the price level of another tool.....surely? There is a built in study called "Study Subgraph Add" which does just this but how would I incorporate this into my code?

You can have a Tool reference a subgraph drawing but the subgraph drawing is not available for drag & drop.

Reply With Quote
Thanked by:




Last Updated on May 19, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts