AntoineOpala Posted July 10, 2023 Report Share Posted July 10, 2023 (edited) Hello, My goal is to create the following saved order : - Buy/sell (depending on which DOM column the mouse is currently over) StopLimit (Stop = PriceAtMouse; Limit = PriceAtMouse+0.01), 83 quantity. It is an OTOCA. Therefore, two more orders come with it. An order to buy/sell (whichever is the opposite of the first action above) StopMarket at PriceAtMouse-0.06. This is basically my stoploss. Another order to buy/sell (whichever is the opposite of the first action above again) at PriceAtMouse+33. This is my take profit. Which formulas would be the correct ones? I cannot find what works to buy or sell depending on which DOM column the mouse is at. I currently have programmed the following thing, but the action "CapOrderType" doesn't work. Using it creates the following message: Error in tag "Action": CapOrderType is invalid - mouse is not over the window." Yet, I guarantee you I'm executing this in a DOM window. Best regards, Antoine Edited July 10, 2023 by AntoineOpala Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted July 11, 2023 Report Share Posted July 11, 2023 CapOrderType is the order type of the Capsule over which the mouse is hovering. Since there is no capsule, don't use it. I would suggest using instead PriceAtMouse<=Price?'Buy':'Sell' for the main order and PriceAtMouse<=Price?'Sell':'Buy' for the legs? Also - I am not sure how you decided on your limit and stop prices both in main and in legs. That doesn't look like it works both for sells (if mouse is on left side of DOM) and buys (if mouse is on right). Are you sure about those? Quote Link to comment Share on other sites More sharing options...
AntoineOpala Posted July 12, 2023 Author Report Share Posted July 12, 2023 (edited) Your first suggestion, for the main order, works perfectly. It is indeed what I needed there. Thank you. For the legs, it doesn't work as intended. I'm trying to flip the stoploss and target prices upside down depending on whether the main order is long or short. If the main order is long, the stoploss should be -0.06 below the entry price. This is currently the case ✔. If the main order is short, then the stoploss should move around to the other side and be +0.06 above the entry price. This is currently not the case ❌. How to program this? Currently, the stoploss is always below the entry price regardless of whether I'm buying or shorting a stock. It should flip above in case I'm shorting. The limit and stop prices I decided are designed to make me risk $5 per trade. Basically, if I buy 83 stocks and if my trade fails, I will only lose 83 * $0.06. If you do the math, I will only lose $4.98. As for my target limit order, it is set to +33. I know it's too far to trigger. I'm doing this just so a target limit order exists in the machine. I can later adjust its price on the fly depending on where the market will have gone. Edited July 12, 2023 by AntoineOpala Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted July 12, 2023 Report Share Posted July 12, 2023 1. That 'Buy' and 'Sell' variables - put them in Variable section. Makes it easier Not sure about your +33 / -33 third leg but I retained it here. Something like this? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.