Is ther any way to add a stop loss and target after a position is opened? Also how should I close out the position? For example, I have a buy position open, I am up $190.00 and want to close out to take my profits. How do I do this?
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
Can I add a stop and target after opening a position
Collapse
X
-
Can I add a stop and target after opening a position
Hello,
Is ther any way to add a stop loss and target after a position is opened? Also how should I close out the position? For example, I have a buy position open, I am up $190.00 and want to close out to take my profits. How do I do this?Tags: None
-
Hello dmelleady,
Yes it would be possible to submit the profit target and stop loss some bars after an entry was made.
I have attached a sample strategy which will submit a PT and SL 3 bars after an order was filled you can use as a sample.
Instead of using if(CurrentBar==xBars+3) as my sample does for the if statement related to submitting the PT and SL, you could use BarsSinceEntryExecution too, see.
To close out the position at $190 you could use SetStopLoss with the mode set to CalculationMode.Currency, see the following helpguide link,
You could also write an if statement which said if
Code:if(PositionAccount.GetUnrealizedProfitLoss(PerformanceUnit.Points, Close[0])>$190) ExitLong();
Please let us know if you need further assistance.Alan P.NinjaTrader Customer Service
-
Hello dmelleady,
So I may confirm, you are not using automated strategies?
If you were to be in a trade and hit the close button, a closing trade would be sent at the market and filled at the best bid or offer. Whether that would be for a profit would depend on the bid/ask at that time.
I look forward to your reply.Alan P.NinjaTrader Customer Service
Comment
-
Hello dmelleady,
This would be the automated strategy development section of the forum, in the future if you would please post these types of questions in the support section of the forum or open inquiries in the Control Center>Help>Remote Support that would be appreciated.
What you're asking to do is called an OCO, one cancels other. To place an OCO you must right mouse click on the SuperDOM and enable OCO. Place your buy limit or buy stop, followed by your sell or sell stop. Then disable OCO by right clicking the DOM and unchecking OCO. This last part, unchecking is very important to avoid ID numbers being reused.
Understanding "One Cancels Other"
Let us know if we may be of further assistance.Alan P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by kempotrader, Today, 08:56 AM
|
0 responses
6 views
0 likes
|
Last Post
by kempotrader
Today, 08:56 AM
|
||
Started by kempotrader, Today, 08:54 AM
|
0 responses
4 views
0 likes
|
Last Post
by kempotrader
Today, 08:54 AM
|
||
Started by mmenigma, Today, 08:54 AM
|
0 responses
2 views
0 likes
|
Last Post
by mmenigma
Today, 08:54 AM
|
||
Started by halgo_boulder, Today, 08:44 AM
|
0 responses
1 view
0 likes
|
Last Post Today, 08:44 AM | ||
Started by drewski1980, Today, 08:24 AM
|
0 responses
4 views
0 likes
|
Last Post
by drewski1980
Today, 08:24 AM
|
Comment