Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop loss and take profit for orders with OIF files

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

  • NinjaTrader_ChelseaB
    replied
    Hello jeremyed,

    Yes, you can use the CHANGE orders to move them to a new price.
    If you are using an Atm with trailing, this will undo any changes you make.

    No, this could not be in the same OIF file as the orders have to exist and have an order id before you can change them.

    Leave a comment:


  • jeremyed
    replied
    So let me know if I have this straight. My aim is to create an order with target and stop and have the stop trail. For now I have an ATM Strategy that has a custom stop template with trailing behavior. So I can create an Oif* file with the PLACE command for that order and the defaulted target and stops are set. Then to change them to what I would like I create another Oif* file with a CHANGE command for the Target1 and the Stop1 giving the strategy Id that was initially passed to the PLACE command. Does this sound proper or could I do this in one Oif* file?

    Thanks

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Jeremy,

    Atm's can have the 'Parameter type' set to 'Percent' for the initial distance as a percent of the entry price.


    However, this only applies to the initial distance and not trailing behavior.

    Leave a comment:


  • jeremyed
    replied
    Not for orders directly sent through OIF.

    However, if you specify an Atm template that has a stop strategy saved in it, this will be effective on the stop loss created by the Atm.
    ​I was looking at the templates and wasn't sure if I could programmatically enter trades. Currently I'm running a custom program that writes the OIF files when necessary and each trade has its own stop loss percentage in the moment. From what I've seen the templates are "hard coded". Is that correct or is there a way for the stop order template to create a stop behavior with the percentage specified?

    Thanks,
    Jeremy

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello jeremyed,

    Welcome to the NinjaTrader forums!

    Not for orders directly sent through OIF.

    However, if you specify an Atm template that has a stop strategy saved in it, this will be effective on the stop loss created by the Atm.

    Leave a comment:


  • jeremyed
    replied
    Is it possible for the STOPMARKET orders in the oif files to be trailing?

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Bruce,

    Unfortunately, this is not possible with OIF (Order-Instruction-Files). These are for submitting orders only.

    I would recommend that you create a NinjaScript Indicator if you want to do something like this.

    Leave a comment:


  • trymph
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello Bruce,

    This wouldn't be something that could be accomplished with OIF files.

    edited

    If your application is where you are triggering actions from keypresses, the application could copy an OIF file into the incoming directory..
    Thanks for your reply Chelsea I missed it when you sent it. Just to clarify. My application is triggering a visual marker to BUY/SELL on my chart which in turn prompts me to manually press my F4/F9 keys which then places the NT ATM entry working orders based on those respective hot keys.

    What I'm wondering is if its possible to write a txt output in my app to the appropriate directory in NT that will automate the F4/F9 key presses; rather than me manually hitting those respective keys on my keyboard. The only thing my application is doing is painting a marker on my chart but it is capable of sending a txt message to any directory on my computer......So is it possible to create a OIF txt message that will tell NT to activate my F4/F9 hot keys (at the same time it paints a marker on my chart) rather than me pressing them on my keyboard manually?

    Thanks
    Bruce

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Bruce,

    This wouldn't be something that could be accomplished with OIF files.

    With a NinjaScript Strategy or Indicator, you could use undocumented code to detect key presses and send an order.

    This example may give you some ideas.


    If your application is where you are triggering actions from keypresses, the application could copy an OIF file into the incoming directory..

    Leave a comment:


  • trymph
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello spondishy,

    An Atm could be applied to the entry by specifying an Atm Strategy Template name and ID.
    PLACE;<ACCOUNT>;<INSTRUMENT>;<ACTION>;<QTY>;<ORDER TYPE>;[LIMIT PRICE];[STOP PRICE];<TIF>;[OCO ID];[ORDER ID];[STRATEGY];[STRATEGY ID]


    The quantity can be changed by supplying that same strategy ID.
    CHANGE;;;;<QUANTITY>;;<LIMIT PRICE>;<STOP PRICE>;;;<ORDER ID>;;[STRATEGY ID]

    However, a market order cannot be modified. You would need to place an additional order to change the position quantity.
    HI Chelsea

    I've too have been looking for more info on OIF prompting me to reply to you on this post. I've read a lot of the instructions on OIF but I'm no coder and some of the NT custom code partners havent responded. So I'll ask here:

    Can a text command be written and sent to my NT8 appropriate directory that merely asks NT to either hit the F4 or F9 Hot keys which will initiate a BUY or SELL respectively? If executed the rest will be handled by my ATM and its embedded Stop Strategy/trailing instructions. My external app has all my triggering concurrent signals and, when fulfilled, is capable of generating a txt message to any directory on my computer; NT is on the same computer.

    Basically I'm trying to devise a OIF poor man's algo to auto trade by putting my Red/Black chip down and letting the ATM do its thing..........Stick 2 Plan: my note to self above my monitor and stay out of the way!!!

    Thanks for the advise in advance
    Bruce
    Last edited by trymph; 02-05-2024, 07:30 AM.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello spondishy,

    Yes, the position will be in the position update file.

    Below is a link to the help guide.


    This text file can be opened with Notepad which is installed with Windows by default.

    Leave a comment:


  • spondishy
    replied
    Thanks, that appears to work. Is there any way of finding out the current position from files in the outgoing folder? I need to do it externally from ninjatrader really.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello spondishy,

    The spaces were not intentional and were added by the forum. (It adds weird spaces every now and then)
    I've put that in a code block so the spaces in the OCOID are removed, but it is still adding a weird invisible character to the beginning and end of some lines which need to be manually removed.

    Video of testing the code as posted in post # 8, with slight modification for the stop price to be a valid price and removing the extra characters at the end of the lines.


    I am also attaching the OIF files, with all of the weird spaces and characters removed that the forum is injecting.
    Attached Files

    Leave a comment:


  • spondishy
    replied
    Hey, any chance you can give this a try on your systems as even your example doesn't work. Mostly due to spaces in OCO ID's I believe.

    Leave a comment:


  • spondishy
    replied
    Thanks for the response. So I've changed my oif files and partial success. I can place a MARKET order and LIMIT and see the position and order for the limit but there is no STOPMARKET order in the orders tab. Can you look through this file for me please? It looks like your file to me.

    PLACE;Sim101;MNQ SEP23;BUY;1;MARKET;;;DAY;;6ca70fb0-5d3b-48d0-96c5-438fd1c5b9a9;
    PLACE;Sim101;MNQ SEP23;SELL;1;STOPMARKET;0;15195.00;DAY;MYOCI1;d9ed 9994-df5f-47ed-9935-0c26bdb466eb;;
    PLACE;Sim101;MNQ SEP23;SELL;1;LIMIT;15215.00;0;DAY;MYOCI1;3edc0ede-a291-40f4-8621-f6539d48b5d6;;

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by chuggachoo, Today, 11:58 AM
1 response
9 views
0 likes
Last Post NinjaTrader_Erick  
Started by xabcdtrading, Yesterday, 12:35 PM
1 response
33 views
1 like
Last Post xabcdtrading  
Started by Genesis2021, 05-23-2022, 04:13 PM
11 responses
11,472 views
0 likes
Last Post xabcdtrading  
Started by owen5819, Today, 10:23 AM
5 responses
19 views
0 likes
Last Post owen5819  
Started by Simon59, Today, 11:36 AM
1 response
9 views
0 likes
Last Post NinjaTrader_Clayton  
Working...
X