Misplaced Text using Text_New_BN  [SOLVED]

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Misplaced Text using Text_New_BN

Postby arjfca » 16 Jan 2016

Hello

I use Text_New_BN to define the location of a Text on charts

Strange is that the Text is misplaced by few bars

Code

Code: Select all


if (MouseClickCtrlPressed and MouseClickShiftPressed) then begin

print (MouseClickBarNumber);
ClickTime = MouseClickDateTime;
A_Bar_Number = MouseClickBarNumber;
PriceVal = MouseClickPrice;

ValToShow = GVGetNamedInt("NumberOnChart",0);
GVSetNamedInt("NumberOnChart",ValtoShow + 1);
Text_ID3 = text_new_BN(A_Bar_Number, PriceVal, numtostr(ValtoShow,0));
// print (A_Bar_Number:0:0, " ", Priceval:5:5, " ", valtoshow:0:0);
Text_SetBorder(Text_ID3, True);
text_SetColor(Text_ID3,Black);
text_setsize(Text_ID3,10);
text_setfontname(Text_ID3,"Verdana");

end;
See the result on this snap picture
2016-01-16_11h54_56.png
(90.76 KiB) Downloaded 335 times

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Misplaced Text using Text_New_BN  [SOLVED]

Postby JoshM » 16 Jan 2016

I use Text_New_BN to define the location of a Text on charts

Strange is that the Text is misplaced by few bars
If I would have to guess (the wiki is down so I can't check), it might be because `MouseClickBarNumber' starts with 1 for the first bar, but what is the bar number for the script depends on the script's MaxBarsBack setting. In other words, the current bar number for the script doesn't start at the very first bar of the chart (which `MouseClickBarNumber`, on the other hand, does do).

So I would try this:

Code: Select all

text_new_BN(A_Bar_Number - MaxBarsBack, PriceVal, numtostr(ValtoShow,0));

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Misplaced Text using Text_New_BN

Postby arjfca » 16 Jan 2016

I use Text_New_BN to define the location of a Text on charts

Strange is that the Text is misplaced by few bars
If I would have to guess (the wiki is down so I can't check), it might be because `MouseClickBarNumber' starts with 1 for the first bar, but what is the bar number for the script depends on the script's MaxBarsBack setting. In other words, the current bar number for the script doesn't start at the very first bar of the chart (which `MouseClickBarNumber`, on the other hand, does do).

So I would try this:

Code: Select all

text_new_BN(A_Bar_Number - MaxBarsBack, PriceVal, numtostr(ValtoShow,0));
That was the solution

Strange is I had tried it in another blank chart ( no other indicator) and the position was OK. I supposed that another Indicator do interfered with the Bar Number way to be calculated

Martin


Return to “MultiCharts”