NexusFi: Find Your Edge


Home Menu

 





Attaching stops / brackets to limit orders in Easylanguage


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,064 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Attaching stops / brackets to limit orders in Easylanguage

  #1 (permalink)
TraderWalrus
Bangkok Thailand
 
Posts: 36 since May 2016
Thanks Given: 15
Thanks Received: 17

I am using Multicharts with IB.

My strategy should enter with a limit order and exit with a bracket.
Below is a simplified version of my code:


Quoting 
if marketposition(0) = 0 then
buy next bar at x limit;

setstoploss(stopSize);

if marketposition(0) = 1 then
sell next bar at y limit;

That works well at the backtesting stage, but when I moved to automating it I am not happy with the way the orders are transmitted.

At the first stage the limit order is transmitted to IB, without any attached stop. The stop will be there only when the position was initiated (if it is initiated), at the next bar. This means that if I lose connection after sending the limit order, and then it is executed, I have no stop.

Is it possible to transmit a limit order with an attached stop (or even better, with an attached bracket)?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NexusFi Journal Challenge - May 2024
Feedback and Announcements
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
35 thanks
Tao te Trade: way of the WLD
25 thanks
Bigger Wins or Fewer Losses?
24 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628


TraderWalrus,

unfortunately this is expected behavior when working without intrabar order generation (IOG). You would have to switch to IOG (which might bring other modifications to your code) when you want the stop in place during the entry bar already.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #4 (permalink)
TraderWalrus
Bangkok Thailand
 
Posts: 36 since May 2016
Thanks Given: 15
Thanks Received: 17

Thank you for your quick reply, ABCTG.

Since I enter with limit orders at certain levels that may or may not be reached, if I switch to IOG this means my orders will be repeatedly transmitted and cancelled at every tick rather than at every bar, correct?

Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

TraderWalrus,

you are welcome. By the way you can show your appreciation using the "Thanks" button under a post.
The order stays active as long as the conditions that generated it stay true. If you don't change these, your order wouldn't get cancelled and resend.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #6 (permalink)
TraderWalrus
Bangkok Thailand
 
Posts: 36 since May 2016
Thanks Given: 15
Thanks Received: 17

Actually, I don't want the stop to be placed during the entry bar. I want to be there already when the limit order is transmitted, since it may happen that my limit order is there for a while before it's executed - whether the script is evaluated every bar or every tick.

If I cannot have a "real" attached stop to my limit order then I think I need to rewrite the whole thing to use market orders that are executed when the price hits my intended entry rather then limit orders that are transmitted beforehand. Makes sense?

Reply With Quote
Thanked by:
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

TraderWalrus,

I don't think you can have actual OSO orders in Multicharts, it would only work to send the stops and targets after the fill and MC will include them into one OCO bracket.
Therefore you might have to use the market order approach you described.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on May 25, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts