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!
See more
See less

Partner 728x90

Collapse

Change a SetStopLoss() Order

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • sjmuk1
    replied
    Thanks that's helped me.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello sjmuk1,

    There is a sample in the following link that shows how you can do a breakeven. The sample is not using SetStopLoss but is instead using ExitLongStopMarket, if you wanted to use SetStopLoss instead you could replace the ExitLongStopMarket order syntax with SetStopLoss. This sample otherwise lines up with what you described, it uses Order objects to know the state of the orders and also uses the order events to drive its logic.



    The important parts of this sample would be its use of OnExecutionUpdate and OnOrderUpdate to manage its Order variables. Also OnBarUpdate where the entry is submitted and the break even for the target is managed. The Position and Order information are used from OnBarUpdate to delegate the breakeven and entry.

    This sample only uses 1 order for simplicity, I would suggest that you initially do the same to make sure you have a single order being tracked correctly. That also lets you change to using SetStopLoss if you wanted. Once you do that you can expand it to support multiple entries or scaling if you wanted to.



    Leave a comment:


  • sjmuk1
    replied
    OK Thanks, How could you suggest i approach checking my open positions for moving them to breakeven at some point if I am using SetStopLoss(). I'll have filled entry order objects to check and some will be closed positions with cancelled or filled stops and some will be open positions with active working stops. I want to only check breakeven on the ones that are currently open positions. What do you suggest?

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello sjmuk1,

    Yes its the same exact concept you would just have two separate entry orders and two separate SetStopLoss syntax.

    The Signal name from the entry order is used to tie a stop to that entry so you would have two entries with unique signal names and then each of your targets can reference a specific entry to close out part of a position.

    Leave a comment:


  • sjmuk1
    replied
    Thanks, what if i have two speperate entry orders and I want to manage two separate stoploss orders for them, can I do that with SetStopLoss()?

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello sjmuk1,

    The Set methods are submitted based on the entry fill but you can change it later by calling SetStopLoss again with new values.

    The two ways to use SetStopLoss orders would be statically by calling SetStopLoss in State.SetDefaults, that gives an always used stop. The other way would be to initialize the stop then submit the entry so that the stop is attached to the entry, that looks like this:

    SetStopLoss(yourvalues);
    EnterLong();

    later you can call SetStopLoss again from other conditions in OnBarUpdate to update it.

    Leave a comment:


  • sjmuk1
    started a topic Change a SetStopLoss() Order

    Change a SetStopLoss() Order

    Hi, Can a StopLoss submitted after an order execution, which was set using SetStopLoss() be subsequently changed?

Latest Posts

Collapse

Topics Statistics Last Post
Started by csksbot, Today, 11:11 AM
1 response
2 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by Skifree, Yesterday, 06:06 PM
2 responses
14 views
0 likes
Last Post Skifree
by Skifree
 
Started by mtamaku, Today, 11:08 AM
0 responses
2 views
0 likes
Last Post mtamaku
by mtamaku
 
Started by franjcy, Today, 03:27 AM
3 responses
15 views
0 likes
Last Post NinjaTrader_Gaby  
Started by Ryan333, Today, 10:48 AM
2 responses
5 views
0 likes
Last Post Ryan333
by Ryan333
 
Working...
X