Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Appling Text to non price panel
Collapse
X
-
Hello MarthaClines,
Thanks for your reply.
Regarding your session timer, all you need to do is to adjust the session end time as you want, for example, TimeSpan span = sesEndTime.AddMinutes(-45) - Core.Globals.Now
If the session ends at 4:00 PM, this would adjust the time to reference 3:15 PM and provide the time remaining from there.
Regarding the DrawTextFixed(), there is not a direct way using the method (there is no overload for bottom center). You can indirectly accomplish this by using C# escape codes in your actual text. For example, if you use "\t", this will place a tab. You would likely have to give up using either the lower left or the lower right to accomplish this or combine the text in one string that would include the \t in the center, for example: Draw.TextFixed(this, "mytext1", "CenterLocation\t\t\t\t\t\t\tRight Location", TextPosition.BottomRight); To be clear this may not be a good solution because the number of tabs depends on the chart width and if you change the chart width the text will remain in the same relationship to the other text but would not be in the center. I've attached a screenshot of what the draw text example looks like:
To be sure this is a "work around" to accomplish your goal using the provided Draw.TextFixed() method.
A better solution that would be more difficult to implement would be to use the OnRender() method to draw custom graphics with complete control. An example of this is in your NinjaTrader and is it called SampleCustomRender.
-
Thanks Mr Paul for the reply.
I am having a hard time conveying what I am trying to do. I am not interested in NT executing any orders. Lets say at 12noon CST I am flat and have no open positions in the market and I decide to go down the Bayou for some crawfish etouffee. I return home to my computer at 2PM cst and look at the ES 06-19 range bar chart. The countdown time that I want to see is 01:15:00 and not 02:00:00. Regardless if I decide to take a trade. I want to be able to quickly glace at a chart and know how much time I have left for the margin flip. So, if I am returning to my computer at 2PM and the margin flip happens at 3:15CST for ES, it should show 01:15:00. However, it shows 02:00:00, meaning its using 4PM instead of 3:15PM CST. My timer is 45 mins off. I am looking for the correct time value to display the calculation. What I am asking is if that exists anyplace where I can access it programmatically, or do I need to create a user defined field in my indicator so the user can input that data and calculate from that? I would prefer not to use a user defined field.
I have another questions... is there a way to print text in the center of the panel, for example between the ES counter and Roll Over counter at the bottom of the screen in the image below. I am using Draw.TextFixed with TextPosition to place the text in the current place. However, there isn't a TextPosition.Center available
Leave a comment:
-
Hello MarthaClines,
Thanks for your reply.
If you want to use the session end time as the reference and you do not want to exit at the end of the session, then you would want to set the Exit on session close seconds to meet your specific needs. Using the ES example, if the session end is 4:00 PM EST and you want to actually exit at 3:00 PM CST then you would set the Exit on session close seconds to: 60 minutes times 60 seconds per minute = 3600 seconds. If you want to exit at 3:15 PM CST then 45 minutes times 60 seconds per minute = 2700 seconds.
If you are using the default <use instrument settings> for the trading hours, then your charts will reflect the actual session closes as specified by the exchanges and the exitoncloseseconds will adjust to each session accordingly, so for example with corn and seconds set to 3600 the strategy would exit at 12:20 PM. CST.
If this solution does not meet your needs you can use the previously advised time filter but using the end of session time minus the preferred exit time, for example:
if (Times[0][0] >= sesEndTime.AddHours(-1))
{
ExitLong();
ExitShort();
}
Both of these solutions are relatively the same.
Leave a comment:
-
Thanks Mr Paul: I have the chart plotting the text in an indicator panel just like I want it.
However, the session end time usingTimeSpan span = sesEndTime - Core.Globals.Now
Leave a comment:
-
Hello MarthaClines,
Thanks for your post.
Regarding this line: TimeSpan span = sesEndTime.Subtract(Time[0]), you might try instead: TimeSpan span = sesEndTime - Core.Globals.Now
Another way to protect yourself would be to add a time filter so that if the time is when you want to be flat, that you simply call ExitLong() and ExitShort(), these are market orders so they get executed immediately and if no position exists then they do nothing, for example:
if (Times[0][0].TimeOfDay >= new TimeSpan(15, 0, 0))
{
ExitLong();
ExitShort();
}
Also, in the strategy parameters you can enable "Exit On Session Close" and set the "Exit on session close seconds" to a value that automatically meets your time needs.
Reference:
In your screenshot you are using non-time based bars and if your code runs with Calculate.OnBarClose, you may want to either change that to Calculate.OnPriceChange or Calculate.OneEachTick to ensure any time filters used will function when you expect. Alternatively, you could simply add a faster time frame such as 1-second bars to provide a barclose (to trigger OnbarUpdate) every second that you could check your timing against that known time data series.
Regarding the DrawText(), while IsOverlay will create an indicator panel and any plots or lines in your code will be drawn in that panel, by default, all draw objects would still be drawn in the price panel. You can change this setting through DrawOnPricePanel = false; that you set in OnStateChange's SetDefaults.
Reference:
Leave a comment:
-
Appling Text to non price panel
I have several questions with respect to the following screen shot:
Question One:
Code Snippet:
private SessionIterator mcSessionI;
private DateTime sesEndTime;
mcSessionI.GetNextSession(Time[0], true);
sesEndTime = mcSessionI.ActualSessionEnd;
TimeSpan span = sesEndTime.Subtract(Time[0])
Question Two:
IsOverlay = false;
Draw.TextFixed(this, tag, xtext, TextPosition.TopLeft, xBrush, myFont, outLineBrush, areaBrush, 255);
Draw.TextFixed(this, tag + "2", "Roll Over " + tDay, TextPosition.BottomLeft, xBrush, myFont, outLineBrush, areaBrush, 255);
Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by mattbsea, Today, 05:44 PM
|
0 responses
4 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
31 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
2 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
16 responses
3,282 views
0 likes
|
Last Post
by Leafcutter
Today, 04:14 PM
|
||
Started by WHICKED, Today, 12:45 PM
|
2 responses
20 views
0 likes
|
Last Post
by WHICKED
Today, 03:36 PM
|
Leave a comment: