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
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 Klaus Hengher, Yesterday, 03:13 AM
|
2 responses
15 views
0 likes
|
Last Post Today, 03:35 AM | ||
Started by Sebastian - TwinPeaks, Yesterday, 01:31 PM
|
2 responses
13 views
0 likes
|
Last Post Today, 03:27 AM | ||
Started by wbennettjr, 07-15-2017, 05:07 PM
|
16 responses
2,528 views
1 like
|
Last Post
by eladlevi
Today, 03:24 AM
|
||
Started by Human#102, Yesterday, 09:54 AM
|
2 responses
8 views
0 likes
|
Last Post
by Human#102
Today, 03:01 AM
|
||
Started by Patlpp, 08-16-2021, 03:10 PM
|
10 responses
498 views
0 likes
|
Last Post
by Joerg
Today, 02:47 AM
|
Comment