Trend lines not appearing on chart

Questions about MultiCharts and user contributed studies.
PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Trend lines not appearing on chart

Postby PD Quig » 29 May 2012

I'm using two data streams to calculate an indicator and then plotting the indicator on the chart. Even though I'm displaying data1, data2, and the indicator all on SubChart #1, a simple horizontal trendline that I'm also calculating does not plot. When I go to Format Objects>Drawings the trendline is listed and the values are correct--but it does not appear on the chart. It should appear as a red line from 9:30-16:15 at a value of 171.4. Not there.

I've done trend lines before on charts with a single data stream and never had a problem. I'm wondering if the two data streams are screwing things up? (I'd actually like to hide the two data streams and plot only the indicator and trendlines, but when I hide data 1 and data 2 the trendline automatically defaults to hidden as well and I can't see how to change it). I've been messing around with this P-in-the-A now for three hours. Anybody ever have a similar issue before? Am I missing something obvious?

Thanks in advance.

PDQ
Attachments
trendline problem.png
(110.61 KiB) Downloaded 951 times
Last edited by PD Quig on 29 May 2012, edited 1 time in total.

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

Re: Trend lines not appearing on chart

Postby TJ » 29 May 2012

I'm using two data streams to calculate an indicator and then plotting the indicator on the chart. Even though I'm displaying data1, data2, and the indicator all on SubChart #1, a simple horizontal trendline that I'm also calculating does not plot. When I go to Format Objects>Drawings the trendline is listed and the values are correct--but it does not appear on the chart. It should appear as a red line from 9:30-16:15 at a value of 171.4. Not there.

I've done trend lines before on charts with a single data stream and never had a problem. I'm wondering if the two data streams are screwing things up? (I'd actually like to hide the two data streams and plot only the indicator and trendlines, but when I hide data 1 and data 1 the trendline automatically defaults to hidden as well and I can't see how to change it). I've been messing around with this P-in-the-A now for three hours. Anybody ever have a similar issue before? Am I missing something obvious?

Thanks in advance.

PDQ

can't help you without the codes.



ps. you do not have to hide the data1, just set the instrument to invisible plot and you won't see it.

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Trend lines not appearing on chart

Postby PD Quig » 29 May 2012

Here's the code to plot the trendlines. Haven't even begun working on the guts of the strategy...was just trying to get the basics in place first:

Code: Select all

//*****************************************************************************
// inputs and variable initialization section
//****************************************************************************

inputs:
Entry_Level_1_pts (10),
Entry_Level_1_Contracts (5),
Entry_Level_1_ActualPosition (0),
Entry_Level_2_pts (15),
Entry_Level_2_Contracts (5),
Entry_Level_2_ActualPosition (0),
Entry_Level_3_pts (20),
Entry_Level_3_Contracts (10),
Entry_Level_3_ActualPosition (0),
RegressionLine (161.4),
Exit_Points (1),
StartTime (930),
EndTime (1615),
OrderExecutionTime (1614);

variables:
Entry_Level_1 (0),
Entry_Level_2 (0),
Entry_Level_3 (0),
Exit_Level (0),
CurrentEntryLevel (0),
Intrabarpersist FirstTrade (false),
ProfitTartgetPrice (0);


//****************************************************************************
// entries execution section
//*****************************************************************************

// reset parameter that limits the system to one trade each day

if Date <> Date[1] then begin
FirstTrade = true;
end;


Entry_Level_1 = Round((RegressionLine + Entry_Level_1_pts),1);
Entry_Level_2 = Round((RegressionLine + Entry_Level_2_pts),1);
Entry_Level_3 = Round((RegressionLine + Entry_Level_3_pts),1);
Exit_Level = Round((RegressionLine + Exit_Points),1);


//****************************************************************************
// plot and text section
//****************************************************************************

variables:
Decimals ($DecOfPriceScale),
Plot_high1 (0),
Plot_high2 (0),
Plot_high3 (0),
Plot_low (0),
Low_line (-1),
High_Line1 (-1),
High_Line2 (-1),
High_Line3 (-1),
High_text1 (-1),
High_text2 (-1),
High_text3 (-1),
Low_text (-1);

if time = StartTime then begin
Plot_high1 = Entry_Level_1;
Plot_high2 = Entry_Level_2;
Plot_high3 = Entry_Level_3;
Plot_low = Exit_Level;

// Draw lines

High_line1 = TL_new(Date,Time,Plot_high1,Date,EndTime,Plot_high1);
Tl_setstyle(High_line1,tool_dashed2);
Tl_setcolor(High_line1, red);
High_line2 = TL_new(Date,Time,Plot_high2,Date,EndTime,Plot_high2);
Tl_setstyle(High_line2,tool_dashed2);
Tl_setcolor(High_line2, yellow);
High_line3 = TL_new(Date,Time,Plot_high3,Date,EndTime,Plot_high3);
Tl_setstyle(High_line3,tool_dashed2);
Tl_setcolor(High_line3, yellow);
Low_line = TL_new(Date,Time,Plot_low,Date,EndTime,Plot_low);
Tl_setstyle(Low_line,tool_dashed2);
Tl_setcolor(Low_line, yellow);

// Plot text

High_text1 = Text_new(Date,StartTime,Plot_high1,numtostr(Plot_high1,decimals));
High_text2 = Text_new(Date,StartTime,Plot_high2,numtostr(Plot_high2,decimals));
High_text3 = Text_new(Date,StartTime,Plot_high3,numtostr(Plot_high3,decimals));
Low_text = Text_new(Date,StartTime,Plot_low ,numtostr(Plot_low,decimals));
end;

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

Re: Trend lines not appearing on chart

Postby TJ » 29 May 2012

Here's the code to plot the trendlines. Haven't even begun working on the guts of the strategy...was just trying to get the basics in place first:
What is the instrument?
What is the chart resolution?

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Trend lines not appearing on chart

Postby PD Quig » 29 May 2012

instruments: TF (data1) and EMD (data2)
chart resolution: 1 minute

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

Re: Trend lines not appearing on chart

Postby TJ » 29 May 2012

you can try this:

Code: Select all

High_line1 = TL_new(Date, Time, Plot_high1, Date, TIME, Plot_high1);
TL_setextright(High_line1, TRUE);
at the beginning of a a new day, add these lines:

Code: Select all

TL_setend(High_line1, Date[1], TIME[1], Plot_high1[1]);
TL_setextright(High_line1, FALSE);

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Trend lines not appearing on chart

Postby PD Quig » 29 May 2012

No luck...

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

Re: Trend lines not appearing on chart

Postby TJ » 29 May 2012

No luck...
can't help you more without more information or code.

other debugging ideas:

1. check your starttime.

2. add a PLOT statement next to the TL_NEW.

Plot a dot at the TL_NEW start point.
if you do not see the dot, your condition was never met,
and your logic never went as far as the TL_NEW statement.

My speculation is, it has nothing to do with the TL statement. The problem is in your logic.

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Trend lines not appearing on chart

Postby PD Quig » 29 May 2012

Well, fer Chrissakes TJ, I found the "missing" trendlines: they are plotting....just not where I could see them. The default scaling was set to "Screen" and the TF plot would fill the screen. When I set the scaling to "User Defined" and changed the minimum to a value lower than the expected trendline, VOILA!, they appeared.

Now, how to get the trendlines to plot with the indicator below and not with the TF plot?

Sheesh.
Attachments
trendline problem_2.png
(125.61 KiB) Downloaded 950 times

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

Re: Trend lines not appearing on chart

Postby TJ » 29 May 2012

Well, fer Chrissakes TJ, I found the "missing" trendlines: they are plotting....just not where I could see them. The default scaling was set to "Screen" and the TF plot would fill the screen. When I set the scaling to "User Defined" and changed the minimum to a value lower than the expected trendline, VOILA!, they appeared.

Now, how to get the trendlines to plot with the indicator below and not with the TF plot?

Sheesh.
You said on subchart #1

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Trend lines not appearing on chart

Postby PD Quig » 29 May 2012

They were all on SubChart #1 at first and I have returned them back to SubChart #1. Here is a picture. The yellow indicator's scale is on the right and the instruments' scale is on the left, with the trendlines way down at the bottom. If they are all on SubChart #1 why doesn't the indicator show down at the bottom with the trendlines? This is just really non-intuitive.
Attachments
trendline problem_3.png
(50.57 KiB) Downloaded 956 times

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

Re: Trend lines not appearing on chart

Postby TJ » 30 May 2012

They were all on SubChart #1 at first and I have returned them back to SubChart #1. Here is a picture. The yellow indicator's scale is on the right and the instruments' scale is on the left, with the trendlines way down at the bottom. If they are all on SubChart #1 why doesn't the indicator show down at the bottom with the trendlines? This is just really non-intuitive.
Don't understand what you mean.



ps. Always use the KISS principle and everything will be fine.

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Trend lines not appearing on chart

Postby SP » 30 May 2012

PD Quig,

for plotting lines/text on the same subchart as the indicator you need to use
tl_new_self and text_new_self.

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Trend lines not appearing on chart

Postby PD Quig » 30 May 2012

SP, TJ,

Thanks. Tried that, but still no go. All objects are assigned to SubChart #1. The problem is that for some reason the trendlines and indicator are plotted using two different scales--so they don't line up--making the trendlines worthless. I can't figure out what combination of settings will cause them all to just show on one chart with the same scale. Way too many combinations of settings and way too counter-intuitive.
Attachments
trendline problem_5.png
Scales out of alignment
(88.8 KiB) Downloaded 946 times

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

Re: Trend lines not appearing on chart

Postby TJ » 30 May 2012

SP, TJ,

Thanks. Tried that, but still no go. All objects are assigned to SubChart #1. The problem is that for some reason the trendlines and indicator are plotted using two different scales--so they don't line up--making the trendlines worthless. I can't figure out what combination of settings will cause them all to just show on one chart with the same scale. Way too many combinations of settings and way too counter-intuitive.
1. make sure the scale on your indicator is set to "Same as Instrument".

2. right click on the price scale (Y-axis) on the chart, make sure the instrument is checked.

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Trend lines not appearing on chart

Postby PD Quig » 30 May 2012

Thanks TJ. Just got off a chat with Customer Service. The problem was that unless the instrument is selected on the scale, the indicator reverts to "User Defined" and breaks the scale relationship. Tricky little bugger. I appreciate your help.


Return to “MultiCharts”