new Font("Arial",20); DrawText("My text",true, "BUY Trigger: " + highPlusTen.ToString() , 0, High[0] + 12 * TickSize, Color.Red, Arial);
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
Price Data on Chart Indicator
Collapse
X
-
Hey Cal, I got the Overload to work with the + sign. But Still can't add Font.
Code:
-
Hello ginx10k,
Here is the complete statement will all overrides
Code:DrawText("My text",true, "BUY Trigger: " + highPlusTen.ToString(), 0, High[0] + 12 * TickSize,0, Color.Red, new Font("Arial",20),StringAlignment.Center, Color.Transparent, Color.Transparent, 5);
Please let me know if I may be of further assistance.JesseNinjaTrader Customer Service
Comment
-
Too Many Lines Problem
Okay So I finally got everything coded. but the Horizontal Lines are being drawn for both Long and Short trades, and I specified in the code that "IF LONG Draw a SET" IF SHORT draw another SET.
But it's NOT Deleting any lines.
Here is the FULL Code (file is attached), hopefully someone can give me a Simple Fix to Stop this from happening. I only want a SET of lines drawn depending whether it's UP bar close or Down Bar Close. I added the RemoveDrawObjects(); to the code and still NOT working
Please Help.
Picture: http://screencast.com/t/4yVjiqazRQ8f
Code:// For LONG Trades if (Close[0] > Open[0]) { RemoveDrawObjects(); //This isn't working //Customize Horizontal Line with Overload statement DrawHorizontalLine(string tag, bool autoScale, double y, Color color, DashStyle dashStyle, int width); //Buy Trigger Price Level DrawHorizontalLine("Trigger Level", true,High[0] + 2 * TickSize, Color.DarkSlateGray, DashStyle.Dash, 3); DrawText("Trigger Price",true, "BUY Trigger: " + highPlusTwo.ToString(), -10, High[0] + 4 * TickSize,0, Color.Red, new Font("Arial",10),StringAlignment.Center, Color.Transparent, Color.Transparent, 4); //Break Even Price Level DrawHorizontalLine("Break Even Level", true,High[0] + 7 * TickSize, Color.DarkSlateGray, DashStyle.Dash, 3); DrawText("Break Even Price",true, "Break Even: " + highPlusSeven.ToString(), -10, High[0] + 9 * TickSize,0, Color.Red, new Font("Arial",10),StringAlignment.Center, Color.Transparent, Color.Transparent, 4); //Take Profit Price Level = 20 tick profit Target DrawHorizontalLine("Take Profit Level", true,High[0] + 25 * TickSize, Color.DarkSlateGray, DashStyle.Dash, 3); DrawText("Take Profit Price",true, "Take Profit: " + highPlusTwentyFive.ToString(), -10, High[0] + 27 * TickSize,0, Color.Red, new Font("Arial",10),StringAlignment.Center, Color.Transparent, Color.Transparent, 4); //Sell Stop Price Trigger DrawHorizontalLine("Sell Stop", true,High[0] - 8 * TickSize, Color.Red, DashStyle.Dash, 2); DrawText("Sell Stop Price",true, "SELL Stop Trigger: " + highMinusEight.ToString(), -10, High[0] - 10 * TickSize,0, Color.Red, new Font("Arial",10),StringAlignment.Center, Color.Transparent, Color.Transparent, 4); //SHORT Hedge Break Even DrawHorizontalLine("Short Hedge BE", true, High[0] - 13 * TickSize, Color.Red, DashStyle.Dash, 2); DrawText("Short Hedge Price",true, "Short Hedge B.E: " + highMinusThirteen.ToString(), -10, High[0] - 15 * TickSize,0, Color.Red, new Font("Arial",10),StringAlignment.Center, Color.Transparent, Color.Transparent, 4); //SHORT Hedge Take Profit and Stop Loss = 10 tick profit target DrawHorizontalLine("Short Hedge TP", true, High[0] - 23 * TickSize, Color.Red, DashStyle.Dash, 2); DrawText("Short Hedge Price",true, "Hedge Take Profit: " + highMinusTwentyThree.ToString(), -10, High[0] - 25 * TickSize,0, Color.Red, new Font("Arial",10),StringAlignment.Center, Color.Transparent, Color.Transparent, 4); } // For SHORT Trades if (Close[0] < Open[0]) { RemoveDrawObjects(); //This isn't working //Customize Horizontal Line with Overload statement DrawHorizontalLine(string tag, bool autoScale, double y, Color color, DashStyle dashStyle, int width); //SELL Trigger Price Level DrawHorizontalLine("Trigger Level", true, Low[0] - 2 * TickSize, Color.DarkSlateGray, DashStyle.Dash, 3); DrawText("Trigger Price",true, "SELL Trigger: " + lowMinusTwo.ToString(), -10, Low[0] - 4 * TickSize,0, Color.Red, new Font("Arial",10),StringAlignment.Center, Color.Transparent, Color.Transparent, 4); //Break Even Price Level DrawHorizontalLine("Break Even Level", true,Low[0] - 7 * TickSize, Color.DarkSlateGray, DashStyle.Dash, 3); DrawText("Break Even Price",true, "Break Even: " + lowMinusSeven.ToString(), -10, Low[0] - 9 * TickSize,0, Color.Red, new Font("Arial",10),StringAlignment.Center, Color.Transparent, Color.Transparent, 4); //Take Profit Price Level DrawHorizontalLine("Take Profit Level", true,Low[0] - 25 * TickSize, Color.DarkSlateGray, DashStyle.Dash, 3); DrawText("Take Profit Price",true, "Take Profit: " + lowMinusTwentyFive.ToString(), -10, Low[0] - 27 * TickSize,0, Color.Red, new Font("Arial",10),StringAlignment.Center, Color.Transparent, Color.Transparent, 4); //BUY Stop Price Trigger DrawHorizontalLine("Buy Stop", true,Low[0] + 8 * TickSize, Color.DarkSlateGray, DashStyle.Dash, 3); DrawText("Buy Stop Trigger",true, "BUY Stop Trigger: " + lowPlusEight.ToString(), -10, Low[0] + 10 * TickSize,0, Color.Red, new Font("Arial",10),StringAlignment.Center, Color.Transparent, Color.Transparent, 4); //LONG Hedge Break Even DrawHorizontalLine("Long Hedge BE", true,Low[0] + 13 * TickSize, Color.DarkSlateGray, DashStyle.Dash, 3); DrawText("Hedge B.E",true, "Long Hedge B.E: " + lowPlusThirteen.ToString(), -10, Low[0] + 15 * TickSize,0, Color.Red, new Font("Arial",10),StringAlignment.Center, Color.Transparent, Color.Transparent, 4); //LONG Hedge Take Profit Target and Short Stop Loss = 10 tick profit DrawHorizontalLine("Hedge T.P", true,Low[0] + 23 * TickSize, Color.DarkSlateGray, DashStyle.Dash, 3); DrawText("Hedge Take Profit",true, "Hedge Profit Target: " + lowPlusTwentyThree.ToString(), -10, Low[0] + 25 * TickSize,0, Color.Red, new Font("Arial",10),StringAlignment.Center, Color.Transparent, Color.Transparent, 4); }
Attached Files
Comment
-
Hello ginx10k,
I'm taking a look at your code and wanted to clarify with you, Are you having issues with it showing the lines for both of your conditions?
Or do you just need to remove the lines when not needed?
You can remove the not needed lines by removing the line by its name using the following:
Code:RemoveDrawObject("Break Even Level");
You might also take a look at the "Price Alert" indicator that comes with NinjaTrader. It has some examples of alternative ways of drawing lines. I don't want to confuse you as this does not really relate to your questions, I just wanted to let you know it’s there for you to look at if you would like.
Please let me know if I may be of further assistance.JesseNinjaTrader Customer Service
Comment
-
I tried the RemoveDrawObject(); empty statement to remove lines that weren't being used. Yea I'm just having a problem with lines that are there that were from previous Bars and aren't needed anymore.
I'm still new to programming, so it's hard for me to find fixes for these things myself. I'll try the RemoveDraw for each statement. Thanks.
Comment
-
Hello ginx10k,
I have attached a revised copy of your indicator. I have left basically everything you did intact I have just changed the way the lines are drawn and removed.
So the way this works for the line redrawing:
There are 6 lines that need to be drawn at a time depending on your conditions.
The issue you were facing was that the other 6 lines would not remove so you were seeing more than 6 lines.
To solve this I have created an IText and an IHorizontalLine in the variables section for each of the 6 lines. Both conditions share the sames lines just different text depending on which condition is active so we only need 6 "place holders"
Next I created a line removal function at the bottom of the script called ClearLines()
This sets the text and line objects we created back to null when were done displaying them.
In your conditions I have changed the DrawHorizontalLine and DrawText statements just a little bit. They now are created and applied to the "placeholders" I set up. Now when they are drawn they are only displayed untill the ClearLines() is called at the beginning of each condition.
Please let me know of I may be of additional assistance.Attached FilesJesseNinjaTrader Customer Service
Comment
-
Moving Average
Jesse Thanks for that. looks great. but I still have a problem, cause I realized that sometimes I want to see the past Price levels cause I might still be in a Trade.
So My thought is this:
is it possible to instead of Having Horizontal lines, perhaps having Moving Averages that do the same thing?? i.e. a MA 10 ticks above the High but showing the price 10 ticks above the high, etc......
This way all the lines can remain on the chart, and If lets say I'm in a trade from the 8:30 5min bar, but it's now 8:50, I can keep looking at the 8:30 Levels in an elegant fashion.
SummarY: Moving Average that holds the price levels chosen at the close of a bar. So let's say 10 ticks above the high, another one is 20 ticks below the High.
Is this idea possible? how can I even begin to look at this??
Any Ideas on how to accomplish this guys.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by CortexZenUSA, Today, 12:53 AM
|
0 responses
1 view
0 likes
|
Last Post
by CortexZenUSA
Today, 12:53 AM
|
||
Started by CortexZenUSA, Today, 12:46 AM
|
0 responses
1 view
0 likes
|
Last Post
by CortexZenUSA
Today, 12:46 AM
|
||
Started by usazencortex, Today, 12:43 AM
|
0 responses
5 views
0 likes
|
Last Post
by usazencortex
Today, 12:43 AM
|
||
Started by sidlercom80, 10-28-2023, 08:49 AM
|
168 responses
2,265 views
0 likes
|
Last Post
by sidlercom80
Today, 12:05 AM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
3 responses
11 views
0 likes
|
Last Post Yesterday, 11:58 PM |
Comment