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 space multiple entrees from each other?
Collapse
X
-
How to space multiple entrees from each other?
I wonder if you can give me some code example on how to space multiple entrees from each other by a set number of ticks. For example if I am scaling in to a position with extra entrees I don't want the next entree to be made too close to my last one.Tags: None
-
Hello relogical,
You may use the "TickSize" object to be able to set the number of ticks away from a price so that you may space out some of your scale in orders.
For example:
Code:protected override void Initialize() { EntryHandling = EntryHandling.UniqueEntries; } protected override void OnBarUpdate() { //...Entry condition code. if ( /* Scale in Condition */ ) { // Sets a Long limit order 5 Ticks above the average position price. EnterLongLimit(Position.AvgPrice+5*TickSize,"EnterLong2"); // Set order name unqiuely to scale in } // Rest of code. }
JCNinjaTrader Customer Service
-
Hello relogical,
That was just an example. If you would like to if you would like to store the the price of the last executed order then you may want to get the information from the OnExecution() method.
Code:double lastTradedPrice; protected override void OnExecution(IExecution execution) { // Condition to check to see if OnExecution is being called for your entry order and not an exit // Note you will want to change this to your own logic as this is an example if (entryOrder != null && entryOrder == execution.Order) { lastTradedPrice = execution.Price; // Now you can use the lastTradedPrice variable for your scale in orders } }
JCNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by NM_eFe, Today, 10:13 AM
|
0 responses
1 view
0 likes
|
Last Post
by NM_eFe
Today, 10:13 AM
|
||
Started by hdge4u, Yesterday, 12:23 PM
|
1 response
10 views
0 likes
|
Last Post
by hdge4u
Today, 09:58 AM
|
||
Started by 1001111, Today, 09:45 AM
|
0 responses
4 views
0 likes
|
Last Post
by 1001111
Today, 09:45 AM
|
||
Started by DTSSTS, 01-28-2024, 12:07 PM
|
11 responses
557 views
0 likes
|
Last Post
by bmo111
Today, 09:34 AM
|
||
Started by Torontobluejays, Today, 08:43 AM
|
0 responses
1 view
0 likes
|
Last Post Today, 08:43 AM |
Comment