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
How to use Region Highlight Y as takeprofit Target
Collapse
X
-
How to use Region Highlight Y as takeprofit Target
Hello, I want to use existing region highight Y drawings if a position is entered. Is it possible to let the strategy check the nearest Y-value (price) in the existing of the opened chart drawings and set takeprofit and stoploss orders?Tags: None
-
Hello WbrTrader,
Welcome to the NinjaTrader forums!
You can assign the drawing object to a variable when you draw this, and then use the anchors for that object to get the .Price of the anchor. The prices will be a double that can be used for order methods limit price and stop price as long as the prices are valid for the order type and direction.
Below are links to the help guide.
Chelsea B.NinjaTrader Customer Service
-
thank you for your answer. I am totally new to this and dont know how to assign the drawing object to a variable. Do you have time to give me some more help? The attached links dont give me the information i need.
What the strategy should do:
What the strategy should do:
As soon as the strategy opens a position in compliance with my rules, a StopLoss or TakeProfit order should be created at the next price mark.
The price marks required for this should be given by RegionHighlight Y markings that I have entered manually.
How can I do that exactly?Last edited by WbrTrader; 12-12-2022, 01:05 PM.
Comment
-
Hello WbrTrader,
Keep in mind that knowing C# does come pre-requisite to learning NinjaScript.
Below is a link to a forum post with helpful resources on getting started with C# and NinjaScript.
Knowing how to assign values to variables, knowing the basic syntax of C#, understanding scope and object types, knowing how branching commands and loops work, should be your first path in learning.
The first line in the code sample in the help guide I have linked in my previous post shows calling a draw method as assigning the drawing object to a variable.
Code:RegionHighlightY myReg = Draw.RegionHighlightY(this, "tag1", 10, 0, Brushes.Blue);
Check the anchor price is a valid price for the order type and direction.
You can submit an ExitLongStopMarket() / ExitShortStopMarket() from OnExecutionUpdate() or OnOrderUpdate() when the entry order fills.
Below is a link to an example.
https://ninjatrader.com/support/foru...269#post802269
Then use the anchor price as the stopPrice parameter.Chelsea B.NinjaTrader Customer Service
Comment
-
Hi WbrTrader,
I think I know what you're trying to do. You want to drawn levels/regions on the chart and then you want your strategy to trade those levels.
Here's what you can do:- Manually raw a line/region/rectangle on the chart.
- Right-click on the newly drawn object and select Properties.
- Rename the Tag to something your strategy can easily identify using a unique name. (For example, "MyYRegion-01"
- Repeat 1-3 for the objects you want on the chart.
- In your strategy code, use DrawingObjects, found here: https://ninjatrader.com/support/help...rawobjects.htm
- Iterate over the drawing objects, finding the tags you drew above.
- Then using the properties to obtain the levels you want.
Obviously, the coding is considerably more detailed than this but it should point you the right direction. See the code examples in the link for DrawObjects; that should help.
Hope that helps!
Matt
- Likes 1
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
14 responses
1,788 views
0 likes
|
Last Post
by aligator
Today, 11:47 AM
|
||
Started by Jimmyk, 01-26-2018, 05:19 AM
|
6 responses
837 views
0 likes
|
Last Post
by emuns
Today, 11:27 AM
|
||
Started by jxs_xrj, 01-12-2020, 09:49 AM
|
6 responses
3,293 views
1 like
|
Last Post
by jgualdronc
Today, 10:56 AM
|
||
Started by Touch-Ups, Today, 10:36 AM
|
0 responses
13 views
0 likes
|
Last Post
by Touch-Ups
Today, 10:36 AM
|
||
Started by geddyisodin, 04-25-2024, 05:20 AM
|
11 responses
63 views
0 likes
|
Last Post Today, 10:08 AM |
Comment