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
PriorDayOHLC
Collapse
X
-
PriorDayOHLC
Can the PriorDayOHLC be modified to show "PrevHigh" "PrevLow" "PrevOpen" "PrevClose" on the far right in lieu of the price of the lines? If so, can you walk me through this? -
Hello crabman777,
Welcome to the NinjaTrader support forum.
I wanted to clarify, do you mean to also display this as text in addition to the price shown on the right scale?
Placing text in the scale its self would not be possible for this use case, however, you could likely use drawing objects or OnRender to place text at the CurrentBar. If this is what you are trying to do, I believe I could provide some instruction to get you started on doing that. Otherwise can you provide more specific detail on the outcome you want to see here?
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
-
Hi Jesse,
It was easier for me to make a quick image to show what I am hoping to accomplish. Please see attached.
If this is something that can be done, can it also be done for "PrevOpen2" "PrevHigh2" "PrevLow2" "PrevClose2"
Thank you1 Photo
Comment
-
Hello crabman777,
Thank you for your reply.
Yes, this type of display is possible using just Drawing tools. You could either modify the existing indicator by duplicating it and adding the drawing objects to its code, or you could make a new indicator that replots the PriorDay values in addition to drawing objects. I will provide details on the first option or duplicating the code.
You can find samples of the various drawing objects syntax in the help guide here: https://ninjatrader.com/support/help...us/drawing.htm
For this use, Draw.Text could be used: https://ninjatrader.com/support/help.../draw_text.htm
The most simple use would be the following, this shows how to plot text on the CurrentBar for the Close price:
Code:Draw.Text(this, "MyClosePrice", "Close", 0, Close[0]);
- From the control center:
- Click New -> NinjaScript editor
- In the editor, locate the PriorDayOHLC indicator in the Indicators folder and double click it to open it.
- Right-click in the file and choose Save As
- Give it a name and click OK.
- In the new file, add a new line between lines 132 and 133 and then paste the following code:
Code:Draw.Text(this, "MyClosePrice", "Prior Close", 0,PriorClose[0]);
Code:if (ShowClose) PriorClose[0] = priorDayClose; } [B]Draw.Text(this, "MyClosePrice", "Prior Close", 0,PriorClose[0]);[/B] }
This will put text on the line similar to your image, this can be further controlled using BarsAgo to push it more Left if required, you can also use one of the Draw.Text overloads which has "Y Pixel Offset" if you wanted to push the text off of the line. Alternatively, you can supply modified prices to move this up or down off of the line:
Code:PriorClose[0] - 1 * TickSize
After making changes, press F5 or right-click and Compile to save and make the changes. Next, apply the indicator to the chart.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
-
HI Jesse,
That worked great. I don't quite understand moving the text plot though. Can you tell me how to move the new text about 10 bars to the right? Thanks
Comment
-
Hello crabman777,
Thank you for the reply.
The sample I had provided uses 0 BarsAgo, so this should place the text on the bar where this was called, are you trying to place the object into the future 10 bars when this is placed?
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
I think I misunderstood you. Where do I place the "0 BarsAgo"? I did not add that to the script. I only have:
}
Draw.Text(this , "MyOpenPrice", "Prior Open", 0, PriorOpen [0]);
Draw.Text(this , "MyHighPrice", "Prior High", 0, PriorHigh [0]);
Draw.Text(this , "MyLowPrice", "Prior Low", 0, PriorLow [0]);
Draw.Text(this , "MyClosePrice", "Prior Close", 0, PriorClose [0]);
}
Thank you,
Comment
-
Hello crabman777,
Thank you for clairifing.
In this, you have used 0 BarsAgo:
Code:Draw.Text(this , "MyOpenPrice", "Prior Open",[B] 0 //<<< BarsAgo[/B]
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Yes, I believe I want in in the future (like the image I uploaded). Right now, the test covers price action. I would like it to the right of the end of the plotted line, so it is not in the same space as my candles..
Comment
-
Hello crabman777,
Thank you for your reply.
Technically you could use a BarsAgo of -10 here because you are not trying to look in the future for data but just to push the text forward, however using negative bars ago is not documented so use at your own risk.
The alternative would be to use Onrender here and the right side margin property of the chart. There is a sample indicator in NinjaTrader which draws text using OnRender called SampleCustomRender, this shows the syntax needed to render.
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
Comment
-
I'm going to need help with this one Jesse. I looked over the sample indicator, but am at a loss on how to apply it. Please help.
Comment
-
Hello crabman777,
In the sample, it demonstrates how to use OnRender for drawing which allows for drawing anywhere on the chart in X and Y coordinates. For what you are asking, the alternative would be to draw fixed text on the Right side of the chart and to also use the charts Right side margin to push the bars away from the right giving it space. Using OnRender is quite a bit more involved so you would need to use some of the code from this sample.
The sample has comments and the part you would need to reference is noted as:
// 1.6 - Simple Text Rendering
The X position of the text will be mainly what you would be interested in here to place the text at the fixed end position in the chart.
The Y value you can use the GetYByValue method to create a Y value from a Price: https://ninjatrader.com/support/help...ub=getybyvalue
The Price would come from the plot, and in this context getting the price is a little different:
Code:PriorDayOHLC().PriorOpen.GetValueAt(Bars.Count - 1);
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
Comment
-
-
Hello crabman777,
Thank you for your reply.
The sample is very specific and explains each step in its comments, are you having difficulty with some part of this script?
The comments in the file would be able to explain what each step of the text rendering is doing, and that would be essentially what is required to render text at a fixed position on the right of the chart. I would suggest making a new indicator and first trying to replicate the text rendering logic so that part makes more sense.
The other items I had noted would be things you can change to give the text the result you wanted. Are you having difficulty with one of these parts of this description? If you can provide more specific details about what you don't understand, we can try to cover that in more detail.
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Aviram Y, Today, 05:29 AM
|
0 responses
1 view
0 likes
|
Last Post
by Aviram Y
Today, 05:29 AM
|
||
Started by quantismo, 04-17-2024, 05:13 PM
|
3 responses
25 views
0 likes
|
Last Post Today, 05:23 AM | ||
Started by ScottWalsh, 04-16-2024, 04:29 PM
|
7 responses
34 views
0 likes
|
Last Post Today, 05:15 AM | ||
Started by cls71, Today, 04:45 AM
|
0 responses
6 views
0 likes
|
Last Post
by cls71
Today, 04:45 AM
|
||
Started by mjairg, 07-20-2023, 11:57 PM
|
3 responses
216 views
1 like
|
Last Post
by PaulMohn
Today, 04:22 AM
|
Comment