Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Trailing stop utilizing currency rather than ticks
Collapse
X
-
Trailing stop utilizing currency rather than ticks
I would like an automated trailing stop that with an ATM profit target of $100 and a loss target of $100 would trail with the following conditions. 1) if profit = $20 then stop loss = $80. If profit reaches $40 stop loss = 0 or break even. If profit = 80 stop loss = $70 profit. Is this possible? Thanls in advance for any advice.Tags: None
-
Hello TheDailyBenjamins,
Yes, this would be possible.
Code:if (/* entry conditions here */) { SetStopLoss(CalculationMode.Currency, 100); // the stop loss needs to be set before the entry is submitted to the initial distance EnterLong(); } if (Position.MarketPosition != MarketPosition.Flat) { // storing this to a variable to shorten conditions double currentPnL = Position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]); // profit is equal to or greater than 20 and less than 40, set stop loss to $80 if (currentPnL >= 20 && currentPnL < 40) SetStopLoss(CalculationMode.Currency, 80); // profit is equal to or greater than 40 and less than 80, set stop loss to breakeven if (currentPnL >= 40 && currentPnL < 80) SetStopLoss(CalculationMode.Price, Position.AveragePrice); // profit is equal to or greater than 80, set stop loss to $70 if (currentPnL >= 80) SetStopLoss(CalculationMode.Currency, 70); }
Chelsea B.NinjaTrader Customer Service
-
Thank you for the response. Do you know anyone who would code this for me? I do not know anything about Ninja coding.
Comment
-
Hello TheDailyBenjamins,
You can search our extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!
Programming Services - https://ninjatraderecosystem.com/sea...mming-services
Educators - https://ninjatraderecosystem.com/sea...ures=education
You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third party services for NinjaTrader all pricing and support information will need to be obtained through the consultant.
This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
Below I am also providing a link to a forum post with helpful resources on getting started with NinjaScript and C#.
Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
577 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment