Hello
I want to code to show, on the top right corner of my chart the value of the actual spread (bid-ask)
I know I could get the value from GetApiInfo for the time and price
My interrogation is more, How can I calculate to have the string at a visually fix location. A pip does not have the same value depending the pair that i trade or the zoom applied to the charts
Just like the status line, it is always at the same visual location with all charts.
Martin
Put text on the right top corner: visual fix location [SOLVED]
- ABC
- Posts: 721
- Joined: 16 Dec 2006
- Location: www.abctradinggroup.com
- Has thanked: 125 times
- Been thanked: 409 times
- Contact:
Re: Put text on the right top corner: visual fix location
Hi Martin,
you can accomplish this with aiHighestDispValue and aiLowestDispValue. Take a look at the Text_Float function, that should be build into MC, if not let me know and I will post it here.
Another idea would be to paste the text in the status line using plot from an indicator. Like the --- Market Depth on Chart --- indicator does for example.
Regards,
ABC
you can accomplish this with aiHighestDispValue and aiLowestDispValue. Take a look at the Text_Float function, that should be build into MC, if not let me know and I will post it here.
Another idea would be to paste the text in the status line using plot from an indicator. Like the --- Market Depth on Chart --- indicator does for example.
Regards,
ABC
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Put text on the right top corner: visual fix location
If you are using sub-minute charts or non-time based charts, you have to use the _s suffix on the text keywords.Hello
I want to code to show, on the top right corner of my chart the value of the actual spread (bid-ask)
I know I could get the value from GetApiInfo for the time and price
My interrogation is more, How can I calculate to have the string at a visually fix location. A pip does not have the same value depending the pair that i trade or the zoom applied to the charts
Just like the status line, it is always at the same visual location with all charts.
Martin
Re: Put text on the right top corner: visual fix location
Any idea where could be the error. Nothing is display
** This code section extract from the main indicator
Get the Highest display value
Get the date and time of the last visible bar on the chart
In the text location
Extract the date frim the Date_and_time
Extract time from Date_and_time
The Text_new is created once. The same Text variable is use
Martin
** This code section extract from the main indicator
Get the Highest display value
Get the date and time of the last visible bar on the chart
In the text location
Extract the date frim the Date_and_time
Extract time from Date_and_time
The Text_new is created once. The same Text variable is use
Code: Select all
Var:
SpreadTextLine (0),
Spreadtext (""),
Spread (0),
HighLocation (0),
Date_And_Time (0),
HighRoundedup (0),
LowRoundedDown (0),
ID_SpreadTextLine (0);
SpreadtextLine = Text_New_self (date, time, 0, "Text"); // create the Text_New
// this section is the first line that is place at the top of the code...
Highlocation = getappinfo(aiHighestdispValue);
Date_And_Time = getappinfo(aiRightDispDateTime);
Spread = (InsideBid -InsideAsk);
SpreadText = NumtoStr(Spread,5);
text_setLocation(SpreadtextLine,intportion(Date_And_Time),datetime2eltime(Date_And_Time),highlocation);
Text_SetString( SpreadtextLine , ("SPread: " + Spreadtext));
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Put text on the right top corner: visual fix location
Still nothing on the screen
- Tried the setstyle 0,1,2
- Added color
- used the lastbar time
Martin
Martin
- Tried the setstyle 0,1,2
- Added color
- used the lastbar time
Martin
Code: Select all
once begin
SpreadtextLine = Text_New_self (date, time, 0, "Text");
Text_setStyle(SpreadtextLine,1,2);
Text_SetSize(SpreadtextLine, 12);
Text_setcolor(SpreadtextLine, blue);
end;
Highlocation = getappinfo(aiHighestdispValue);
Date_And_Time = getappinfo(aiRightDispDateTime);
Spread = (insideask -insidebid)*10000;
SpreadText = NumtoStr(Spread,5);
text_setLocation(SpreadtextLine,intportion(Date_And_Time),time_s,highlocation);
Text_SetString( SpreadtextLine , ("SPread: " + Spreadtext));
- Attachments
-
- Textline.png
- (133.92 KiB) Downloaded 824 times
- ABC
- Posts: 721
- Joined: 16 Dec 2006
- Location: www.abctradinggroup.com
- Has thanked: 125 times
- Been thanked: 409 times
- Contact:
Re: Put text on the right top corner: visual fix location
At a quick glance you are using text_setLocation with time_s. This will surely create problems. Use text_setLocation_s or text_setLocation_dt.
Regards,
ABC
Regards,
ABC
- ABC
- Posts: 721
- Joined: 16 Dec 2006
- Location: www.abctradinggroup.com
- Has thanked: 125 times
- Been thanked: 409 times
- Contact:
Re: Put text on the right top corner: visual fix location [SOLVED]
You should also apply this to Text_New_self. If you are using Text_New_self and having the indicator running in a subchart, shouldn't the text appear in that subchart, too (I am guessing that SetScreenLocation is the name of your indicator)?
Regards,
ABC
Regards,
ABC
Re: Put text on the right top corner: visual fix location
ABC, TJ
Text_Float was the solution
Text_Float was the solution
Code: Select all
If lastbaronchart then begin
Spread = (insideask -insidebid) ;
If jpy_pair = true then spread = spread *1000 else spread = spread *10000;
SpreadText ="Spread: " + NumtoStr(Spread ,2);
SpreadtextLine = Text_New_s (0,0,0, Spreadtext);
Text_setStyle(SpreadtextLine,1,2);
Text_SetSize(SpreadtextLine, 10);
Text_setcolor(SpreadtextLine, blue);
value2 =Text_float (SpreadTextLine,25,100);
end;
- Attachments
-
- Spread.png
- (34.71 KiB) Downloaded 825 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Put text on the right top corner: visual fix location
LOL... ABC told you that in post #2.ABC, TJ
Text_Float was the solution
Glad you made it working,
and thanks for sharing your code.
Re: Put text on the right top corner: visual fix location
I'M an old old adolescent... Did you follow all your parent advise??....Yo manLOL... ABC told you that in post #2.
Glad you made it working,
and thanks for sharing your code.
A little problem remain. The line is unreadable the first time that I the chart is loaded. I need to reload by changing the scale to get it clear. The problem disappear after changing the scale and returning to the original.
Martin
- Attachments
-
- spread_2.png
- (39.06 KiB) Downloaded 815 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Put text on the right top corner: visual fix location
try this:I'M an old old adolescent... Did you follow all your parent advise??....Yo man
A little problem remain. The line is unreadable the first time that I the chart is loaded. I need to reload by changing the scale to get it clear. The problem disappear after changing the scale and returning to the original.
Martin
Code: Select all
once begin
SpreadtextLine = Text_New(0,0,0, "");
end;
If lastbaronchart then begin
Spread = (insideask -insidebid) ;
If jpy_pair = true then spread = spread *1000 else spread = spread *10000;
Text_setString(SpreadtextLine, "Spread: " + NumtoStr(Spread ,2));
Text_setStyle(SpreadtextLine,1,2);
Text_SetSize(SpreadtextLine, 10);
Text_setcolor(SpreadtextLine, blue);
value2 =Text_float (SpreadTextLine,25,100);
end;
ps. I have not tested this... will test it as soon as I have MultiCHarts loaded.
Re: Put text on the right top corner: visual fix location
Thanks TJ, Just resolved the problem by rewriting the code to use the GetAppInfo directly instead of using the Text_Floattry this:I'M an old old adolescent... Did you follow all your parent advise??....Yo man
A little problem remain. The line is unreadable the first time that I the chart is loaded. I need to reload by changing the scale to get it clear. The problem disappear after changing the scale and returning to the original.
Martin
Code: Select all
once begin
SpreadtextLine = Text_New(0,0,0, "");
end;
If lastbaronchart then begin
Spread = (insideask -insidebid) ;
If jpy_pair = true then spread = spread *1000 else spread = spread *10000;
Text_setString(SpreadtextLine, "Spread: " + NumtoStr(Spread ,2));
Text_setStyle(SpreadtextLine,1,2);
Text_SetSize(SpreadtextLine, 10);
Text_setcolor(SpreadtextLine, blue);
value2 =Text_float (SpreadTextLine,25,100);
end;
ps. I have not tested this... will test it as soon as I have MultiCHarts loaded.
Coded posted there
See viewtopic.php?f=1&t=45615&p=99649#p99649
Martin