Page 1 of 1

Indicator Superposition

Posted: Jun 30 2010
by ym
I wrote an indicator that is supposed to display some info on the LAST BAR ONLY.
The problem is that it works right when the indicator is applied to the strat at first, but as soon as another 1mn tick comes in, the display just DOUBLES and the (lastbaronchart - 1) does NOT erase.
How can I have this indicator just displaying on LAST BAR ONLY (see snapshot) ?
Here's the code (fyi, "displ" is a very simple function that I wrote) :

Code: Select all

value3 = GVGetNamedDouble("tot_pl",value1);
value4 = GVGetNamedDouble("mo_pl",value1);
value5 = GVGetNamedDouble("sprd",value1);
if LastBarOnChart then value10=displ("TotP/L:" + numtostr(value3,0) + "$", +2, "yellow" ) ;
if LastBarOnChart then value10=displ("MonthlyP/L:" + numtostr(value4,0) + "$", +4, "yellow" ) ;
if LastBarOnChart then value10=displ("Spread:" + numtostr(value5,1) + "p", +6, "yellow" ) ;
thanks

Posted: Jun 30 2010
by TJ
look up the function

Text_Float

Posted: Jun 30 2010
by ym
TJ,
It still does not work ... (see snapshot)
Here's the code :

Code: Select all

vars : textid(0);
value5 = GVGetNamedDouble("sprd",value1);
TextID = Text_New( Date, Time, 0, "new" );
Text_Float(TextID, 0,5);
Text_SetString(TextID, "Sprd:" + numtostr(value5,1) + "pip");

Posted: Jun 30 2010
by janus
look up the function

Text_Float
What :shock: Yet another useful but undocumented feature? I'm still using 5.5 so I hope 6.0 has a more comprehensive and up to date list of supported commands on PLEditor. Does it?

Posted: Jun 30 2010
by TJ
look up the function

Text_Float
What :shock: Yet another useful but undocumented feature? I'm still using 5.5 so I hope 6.0 has a more comprehensive and up to date list of supported commands on PLEditor. Does it?
that's a standard TS function.

Posted: Jun 30 2010
by janus
I'm not interested in TS documentation. I only rely on MC documentation, as one would logically expect.

Posted: Jun 30 2010
by TJ
I'm not interested in TS documentation. I only rely on MC documentation, as one would logically expect.
Text_Float is in the PLE dictionary (v6.0.3445.204).

Posted: Jun 30 2010
by janus
That's good, thanks.

Posted: Jul 09 2010
by janus
I just noticed text_float is not a real text floating function. If I adjust the vertical scale, the text will move along with it. However, the text will move back to the appropriate position on the next tick update. What is really needed is something that is fixed in the requested position no matter what, similar to the status lines for the window and the studies.

Posted: Jul 09 2010
by Dave Masalov
Dear janus,

This behavior is logical, because the script is not calculated on the event (adjusting the scale), it is calculated on event (new tick). That is why the text moves back.

Posted: Jul 09 2010
by janus
Dear janus,

This behavior is logical, because the script is not calculated on the event (adjusting the scale), it is calculated on event (new tick). That is why the text moves back.
You miss my point. What's really needed is a way to place text in the window that remains fixed relative to the window, the same way as the status lines work. After all, that's the sole purpose of the float_text feature, but it unfortunately doesn't deliver exactly what's required. It may require a totally different approach to displaying text other than initially using the text_new function as it requires a date and time. What may be required is a function like text_new_fixed(x, y, text), where x = % along the x-axis, y = % along the y axis, text = the text. You already are doing something like this for the status lines, so all is required is to "expose" the same feature to us.

Re: Indicator Superposition

Posted: Nov 13 2010
by ym
janus,
reading back your post dated july-09 :
What may be required is a function like text_new_fixed(x, y, text)

that's exactly the kind of function that I need nowadays for an indic I am currently working on.
since your last post, could you figure out how to code such a function ?

Re: Indicator Superposition

Posted: Nov 13 2010
by TJ
janus,
reading back your post dated july-09 :
What may be required is a function like text_new_fixed(x, y, text)

that's exactly the kind of function that I need nowadays for an indic I am currently working on.
since your last post, could you figure out how to code such a function ?
look at the sample codes in the #6 post of this thread.

Re: Indicator Superposition

Posted: Nov 13 2010
by ym
TJ,
I don't have a login to access those two 'traderslaboratory' links.
Would you mind to make me a copy of the pertaining code ?
(you also may PM it to me, if you prefer)
Thanks.

Re: Indicator Superposition

Posted: Nov 13 2010
by TJ
TJ,
I don't have a login to access those two 'traderslaboratory' links.
Would you mind to make me a copy of the pertaining code ?
(you also may PM it to me, if you prefer)
Thanks.
TL registration is free.

plus, there are lots of other codes you can use.

Re: Indicator Superposition

Posted: Nov 13 2010
by ym
TJ,
Thanks for the advice : I have DL the TL's indics.
Actually, those two indics remain static and do not 'FLOAT' as I was expecting.
What I want is text to appear on the chart at the same position (be it on top, bottom, right or left, no matter) EVEN WHEN I MOVE THE HORIZONTAL SCROLL BAR.
I know that it may work well when ticks flow in (during weekdays) but I also want to have it 'float&follow' when market is off (weekends).
So far, I have never found any solution to this issue.

Re: Indicator Superposition

Posted: Nov 13 2010
by TJ
TJ,
Thanks for the advice : I have DL the TL's indics.
Actually, those two indics remain static and do not 'FLOAT' as I was expecting.
What I want is text to appear on the chart at the same position (be it on top, bottom, right or left, no matter) EVEN WHEN I MOVE THE HORIZONTAL SCROLL BAR.
I know that it may work well when ticks flow in (during weekdays) but I also want to have it 'float&follow' when market is off (weekends).
So far, I have never found any solution to this issue.
Indicators recalculate on new tick.
If there is no new tick (eg. off line or on weekends), you will see the indicator dead in the water.


I do not fully understand how you want your text to "float".
May a few mock up charts would help to illustrate your intention.

Re: Indicator Superposition

Posted: Nov 13 2010
by ym
TJ,
Actually, what I meant by 'float' was 'any determined position', but this is not the real problem here.
My problem is to make sure to have SOME text (at any 'determined' position in the current window) to appear EVEN when I scroll the time bar left or right.
I want to "follow" visually the price action hour after hour, day after day, while making sure that my 'floating' text remain ALWAYS visible.
See here-attached pic.

Re: Indicator Superposition

Posted: Nov 13 2010
by TJ
TJ,
Actually, what I meant by 'float' was 'any determined position', but this is not the real problem here.
My problem is to make sure to have SOME text (at any 'determined' position in the current window) to appear EVEN when I scroll the time bar left or right.
I want to "follow" visually the price action hour after hour, day after day, while making sure that my 'floating' text remain ALWAYS visible.
See here-attached pic.
re: your illustration
the sample code you downloaded from TL would do just that.
HOWEVER, as with any indicator, it will "float" only in real time when there is a constant data feed (ie new tick coming in).

if you want to see the data when you scroll, you can put it in the data window.

Re: Indicator Superposition

Posted: Nov 13 2010
by ym
TJ,
That's a great idea (putting it in the data window), I had never thought about that ... really !
Now, how to do that ?
I am not familiar with the 'data window' usage ...

Here's the code pertaining to my 'floating text' :

Code: Select all

Once ( BarStatus(1) = 2 )
begin
Floating_Text= Text_New( Date, Time, 0, "new" );
Text_SetStyle( Floating_Text, 1, 2) ;
end;

if LastBarOnChart then begin
RightDateTime = GetAppInfo( aiRightDispDateTime ) ;
HighestDispValue = GetAppInfo( aiHighestDispValue) ;
LowestDispValue = GetAppInfo( aiLowestDispValue) ;
TextDispValue = LowestDispValue + ( 0.01 * (VerticalPerCent+ 5) * ( HighestDispValue - LowestDispValue) ) ;
Text_SetLocation( Floating_Text , JulianToDate( IntPortion( RightDateTime ) ), MinutesToTime( FracPortion( RightDateTime ) * 60 * 24 ), TextDispValue) ;
Text_Setsize(Floating_Text,12);
if loss<>0 then Text_SetString(Floating_Text, iffstring(pl>0,"+","") + numtostr(PL,1) + "pips - W/L="+ numtostr(100*(win/(win+loss)),0) + "%(" + numtostr(win,0) +"/" + numtostr(loss,0)+ ") ");
if PL>0 then text_setcolor(Floating_Text , green);
if PL<0 then text_setcolor(Floating_Text, red);
end;

Re: Indicator Superposition

Posted: Nov 13 2010
by TJ
TJ,
That's a great idea (putting it in the data window), I had never thought about that ... really !
Now, how to do that ?
I am not familiar with the 'data window' usage ...

Here's the code pertaining to my 'floating text' :

the data window displays all the plots you have in the indicator.

eg.
adding the following code to your indicator will add a line to the data window on "pips - W/L".
plot10(100*(win/(win+loss)), "pips - W/L");

Re: Indicator Superposition

Posted: Nov 14 2010
by ym
TJ,
Actually the 'data window' displays only the data of the bar your mouse is currently on, not the 'LastBarOnChart' data.
So I finally managed differently : I used your 'plot' hint and now I have the PL & Win/Loss (of the LastBarOnChart) showing in the indicator's status line.
That's way enough for me to visually keep track of the info that I wanted !
Thanks for your help.

Re: Indicator Superposition

Posted: Nov 14 2010
by TJ
TJ,
Actually the 'data window' displays only the data of the bar your mouse is currently on, not the 'LastBarOnChart' data.
So I finally managed differently : I used your 'plot' hint and now I have the PL & Win/Loss (of the LastBarOnChart) showing in the indicator's status line.
That's way enough for me to visually keep track of the info that I wanted !
Thanks for your help.
status line... oh yes, that's a good one.

Re: Indicator Superposition

Posted: Nov 17 2010
by Spaceant
Hi,

I am new to this and have played with "Masthead" and "Bottomline" for two days and it looks good.

Can anyone help with the following?

1) Color Issue
I have added the P&L for my strategy attached together with those already present: HL, ATR20, ATR10, Range[1], Range, P&L. I wonder if I can code to change the coloe of P&L only, say with blue when positive and red when negative.

2) Activate the display when "Maximize SubChart 1" while Deactive when Restore SubChart 1
As my charts have 8 indicators attached, it will be very busy (astually messy) when displaying Masthead / Bottomline. But with maximized SubChart 1, it plots great! I wonder if I can code it to just activate the display when "maximize SubChart 1" and deactivate when displaying all 8 indicators.

3) Any way to check the price range plotted?
Why I want to check it? As with 8 indicators and maximizing SubChart 1, the head and bottom lines are sometimes out of range, i.e. outside the chart. I need to do some adjustment like this:
topprice = getappinfo(aihighestdispvalue) - TAdj;
bottomprice = getappinfo(ailowestdispvalue) + BAdj;
But the bad thing is that TAdj and BAdj are needed to be adjusted when the chart's price range varies. With the ability to check the "Price range" plotted on th echart, I think it can be coded to adjust automatically with a factor.

Sa

Re: Indicator Superposition

Posted: Nov 17 2010
by TJ
Hi,

I am new to this and have played with "Masthead" and "Bottomline" for two days and it looks good.

Can anyone help with the following?

1) Color Issue
I have added the P&L for my strategy attached together with those already present: HL, ATR20, ATR10, Range[1], Range, P&L. I wonder if I can code to change the coloe of P&L only, say with blue when positive and red when negative.
...
you can only set one color per text object.

if you put P&L into another text object,
then you can have different color then the other texts.

Re: Indicator Superposition

Posted: Nov 17 2010
by Spaceant
TJ,

If 2 text objects can be done, it can be done easily with two lines!

However, can 2 text objects be merged and displayed smoothly (as # of digits of P&L and others may vary) as one line??

Sa

Re: Indicator Superposition

Posted: Nov 17 2010
by TJ
TJ,

If 2 text objects can be done, it can be done easily with two lines!

However, can 2 text objects be merged and displayed smoothly (as # of digits of P&L and others may vary) as one line??

Sa
you can use the current bar (Time) as reference;
align one text object to the left of the current bar,
and align another text object to the right.

Re: Indicator Superposition

Posted: Nov 17 2010
by Spaceant
TJ,

Can you illustrate with a code in more details?

Re: Indicator Superposition

Posted: Nov 17 2010
by TJ
TJ,

Can you illustrate with a code in more details?

Code: Select all

var:
id.txt1(-1),
id.txt2(-1);

...

text_setstyle(id.txt1, 0,2);
text_setstyle(id.txt2, 1,2);