(Async Mode) Convert Unexecuted Limit Order to Market Order

Questions about MultiCharts and user contributed studies.
Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

(Async Mode) Convert Unexecuted Limit Order to Market Order

Postby Spaceant » 23 Oct 2009

Hi all,

I am looking for a BETTER EXEUTION OF (Async Mode) Convert Unexecuted Limit Order to Market Order. Hopefully, someone can give me clue to resolve it; or help me to resolve it
Background:
Broker: IB
Timeframe: 5 min chart
Ticker: HSIV9 or YM Dec 09
Fixed shares / contracts: 10
Long Signal: MACD LE (for illustration purpose)
Trailing Exit: see below
Auto Trading:
Replace to Market Partially Fillted Order - Checked
Mode Selection: Async
Convert unexecuted limit/stop ENTRY / EXIT orders to market orders after 30 seconds

{Trailing Stop - Code}
Inputs: ATR_No(3),Pds(20);
Vars: LB(0),TS(0),TS_Delayed(0);
LB=H - ATR_No* avgtruerange(Pds);
TS=Iff(C<TS[1],LB,Maxlist(LB,TS[1]));
TS_Delayed=TS[1];
If C<TS_Delayed then Sell ("LX(Lmt)" ) Next Bar at Close Limit;

As you can see, the exit signal is an end-of-bar signal, that will send a Limit Order if triggered.

For example:
1) If a buy signal is triggered at 10:00 AM by MACD LE.
2) And a "Sell" signal is triggered at the bar closing at 15:00 with closing price at 21010. MultiCharts would send a Sell Limit Order of 10 contracts at 21010 at around 15:00:01.

Scenario 1
The next bar opens at 21010, and all 10 contracts are executed.

Scenario 2
The next bar opens at 21010, only two contracts are executed at 21010. Then price slided down to below 21010 for the rest of the bar. Multicharts will convert the unexcuted amount of contracts, 8, to market order after 30 seconds counting from the plot of the exit signal (i.e. when the time that price hits 21010 on bar 15:05). Full execution of 10 contracts, with 8 at prices at market pricces. I am happy with this.

Scenario 3
The next bar opens lower than 21010, say at 21008, then it plunges down to below 21000 for the rest of bar. MulitCharts cound not convert the Limit Order to a Market Order for the 10 contracts as not signal was plotted on the bar. THIS IS A BIG PROBLEM TO ME!!! I need to execute the exit order even in a market order fter a preset timing "30 sec".

To me, the trigger at 15:00 for C<TS_Delayed is the final final trigger to close the position. The purpose of using Async Mode and a Limit Order is trying to trade as close as to the trigger bar's closing price (i.e. the backtested trigger price). I am not happy to convert to code the exit as a market order as the executed prices are always worse than the trigger bar's closing price.

I have come across the Scenario 3 for a few times in real trading which is frustrating !!!

Can I modify the code to do what I want - executing the exit order in all 3 scenario before the bar closing at 15:05 as the above example shown?

My thought: On top of the above entry and exit code, add another exit code similar to the exit code with IOG enabled, but manipulate it to issue a signal as similar to a above non-IOG code to give an exit signal at 15:00 bar close, and delay the "sending" of the exit order to 15:00:45 (45 seconds that should be enough for the above code to send non-IOG order as in scenario 1 or 2. If the non-IOG exit code can close the position, that's good. The redundant signal at 15:00:45 would not do anything more. If timing (45 seconds) is not enough, we can delay it to 15:01 or even 15:02) to let MultiCharts to issue the IOG signal to close any unexecuted contracts as in scenario 3, with the inability to plot signal with the above code, this IOG enabled code (is an just in case signal if all 10 contracts doesn't execute) send an market order at 15:00:45 to close the position.

Additional Thought: I think it could use the Global Variable (GV) to send the signals from the non-IOG strategy to the IOG code.

Can this be done? I am sure it can be done!!

But one question: if at 15:00:45, 2 contracts are executed with the non-IOG exit code (the present one, or the above code). Would the IOG-enabled code to just send 8 contracts. I think it should be okay as uneder the Strategy Property: Fixed Shares/Contracts=10.
Last edited by Spaceant on 30 Jan 2010, edited 1 time in total.

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 25 Oct 2009

The thread doesn't attract anyone yet..... does anyone have the similar experience as I did, the execution is missed as in scenario 3?

Sa
Last edited by Spaceant on 28 Nov 2009, edited 1 time in total.

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 15 Nov 2009

just refresh to see if anyone could give me some thoughts / insight.....

Sa


Return to “MultiCharts”