Keeping Limit order amounts after entry

Questions about MultiCharts and user contributed studies.
Phil18
Posts: 2
Joined: 28 Jan 2020

Keeping Limit order amounts after entry

Postby Phil18 » 28 Jan 2020

Hi everyone,

I have a strategy which identifies a range-bound market and then sells the top of the range and buys at the bottom of the range. The strategy utilizes limit orders. So, for example, the market keeps bouncing from 500 to 510 and then back. After selling at 510, I anticipate that the market will go down to 500 where I will buy, and then back to 510, where I will sell again.

In order to get into the limit order queue as early as possible, I'm trying to enter a limit sell order for 510 while I'm still in the previous short. So say I sold at 510 and the market goes down to 508, I then enter another sell limit at 510

Code: Select all

if MarketPosition_at_Broker = -1 then sellshort ("s1") 1 contract next bar at 510 limit
The problem is, when I enter my long at 500, the sell limit at 510 changes from 1 contract to 2 contracts (in order to get me net short 1), and I lose my place in the queue. Can anyone think of a way that I can get around this?

using

Code: Select all

if MarketPosition_at_Broker = -1 then sellshort ("s1") 2 contracts next bar at 510 limit
doesn't help, because once I go long, that 2 contract order will just be changed to 3 contracts, and I lose my place in the queue again..

Thanks in advance!

Phil18
Posts: 2
Joined: 28 Jan 2020

Re: Keeping Limit order amounts after entry

Postby Phil18 » 03 Feb 2020

No solutions to this problem?

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: Keeping Limit order amounts after entry

Postby Svetlana MultiCharts » 14 Feb 2020

Hello, Phil18

Due to the PowerLanguage rule, there is no specific command to cancel an order, and an order will be cancelled when the script stops generating it at the sequential calculation. Therefore, one cannot fully get rid of order queue loss. However, it is possible to improve this behaviour by using Optimize Order Flow option (Strategy Properties -> Autotrading -> Automate Order Execution Settings -> Optimize Order Flow):
https://www.multicharts.com/trading-sof ... Order_Flow

Please enable Optimize Order Flow and apply the following script

Code: Select all

sellshort ("SE") 1 contract next bar at 510 limit; buy ("LE") 1 contract next bar at 500 limit;sell ("LX") 1 contract next bar at 508 limit; buytocover ("SX") 1 contract next bar at 502 limit;
It includes unconditional entries at 500 and 510 and unconditional exits with 2-point offset. Optimize Order Flow reduces the number of order replacements; however, it does not exclude them at all. In this case the replacement happens at the moment when one of the entries is generated — then both entry limit orders are replaced and exits are placed.


Return to “MultiCharts”