how do i find if a given order is filled...

Questions about MultiCharts and user contributed studies.
KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

how do i find if a given order is filled...

Postby KhaosTrader » 13 Oct 2012

I am writing a strategy that will have multiple entries based on different conditions, where each entry needs to be managed separately.

So I am looking at the following code (example code):

Code: Select all

if Cond1= true and Filter1 = true and InCond1Trade = false then begin
InCond1Trade = true;
Buy ("1 Contract Cond1Trade") 1 Contract next Bar Market ;

end;

if Cond2 = true and Filter2 = true and InCond2Trade = false then begin
InCond2Trade = true;
Buy ("1 Contract Cond2Trade") 1 Contract next Bar Market ;

end;


if marketposition = 1 then begin
Sell("Cond1 T Contract") from Entry ("1 Contract Cond1Trade") next Bar at (entryprice + 50*vticksize) Limit;
Sell("Cond1 X Contract") from Entry ("1 Contract Cond1Trade") next Bar at (entryprice - 30*vticksize) Stop;

Sell("Cond2 Contract") from Entry ("1 Contract Cond2Trade") next Bar at (entryprice + 50*vticksize) Limit;
Sell("Cond2 Contract") from Entry ("1 Contract Con21Trade") next Bar at (entryprice - 30*vticksize) Stop;

end;

The problem is how can i determine InCond1Trade = true or false? I need to discover if the "1 Contract Cond1Trade" is filled or not.. how do i do that?

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: how do i find if a given order is filled...

Postby Andrew MultiCharts » 15 Oct 2012

Hello KhaosTrader,

Code: Select all

if currentshares = 2 then // Filled 2 orders
if currentshares = 1 and EntryName="1 Contract Cond1Trade" then // Filled 1 order Cond1Trade
if currentshares = 1 and EntryName="1 Contract Cond2Trade" then // Filled 1 order Cond2Trade
if currentshares = 0 then // Not Filled

KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Re: how do i find if a given order is filled...

Postby KhaosTrader » 15 Oct 2012

Hi,

This can work with contracts perhaps, but I can run into problems if its stocks shares...

Let me explain...

lets say 3 entries of 100 shares each. Entry 1: 100 shares , Entry 2: 100 shares, Entry3: 100 shares.

What if i do a sell order on Entry 1 for 100 shares and Entry2 for 100 shares, but for whatever reason, only 10 shares were sold from Entry 1, and 20 shares were sold from entry 2.

Then I have 270 shares left, but I dont know which shares belong to which entry.

That is why it would be best to be able to query each entry to see how many shares are existing in the entry.

How can I do this?

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: how do i find if a given order is filled...

Postby Andrew MultiCharts » 15 Oct 2012

I see... Yes, if we take this case as an example, there is no opportunity for MultiCharts to return several names of partially filled orders of the same posiiton.

KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Re: how do i find if a given order is filled...

Postby KhaosTrader » 15 Oct 2012

i am not asking for multicharts to return a set of names, I am asking if i give it a given trade name, how many shares within that name.

What i also can do is see if there are trades open, then do a for loop to loop through the counts? thats a lot of querying, I just want more control to know what each order contains. Perhaps u should add this feature in next version if its not possible here...

Alternatively is this type of feature available in mc.net?

KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Re: how do i find if a given order is filled...

Postby KhaosTrader » 15 Oct 2012

can i create a condition like this..

Code: Select all

if currentshares > 0 and currentshares < 10 and EntryName="1 Contract Cond1Trade"
This will see if currentshares are between 1 and 9 solely with the entry name scope "1 Contract Cond1Trade".

With that , then i can do a test for >0 and <5, and then narrow it down to find the number of contracts with a few iterations, is this possible?

**just trying to get creative here to figure out some solution.

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: how do i find if a given order is filled...

Postby Andrew MultiCharts » 16 Oct 2012

i am not asking for multicharts to return a set of names, I am asking if i give it a given trade name, how many shares within that name.

What i also can do is see if there are trades open, then do a for loop to loop through the counts? thats a lot of querying, I just want more control to know what each order contains. Perhaps u should add this feature in next version if its not possible here...
Please leave us such feature request.
Alternatively is this type of feature available in mc.net?
Yes, it should be possible there, since you have access to Order and Position Tracker information through TradeManager. An example of script is attached below.
can i create a condition like this..

Code: Select all

if currentshares > 0 and currentshares < 10 and EntryName="1 Contract Cond1Trade"
This will see if currentshares are between 1 and 9 solely with the entry name scope "1 Contract Cond1Trade".
With that , then i can do a test for >0 and <5, and then narrow it down to find the number of contracts with a few iterations, is this possible?
**just trying to get creative here to figure out some solution.
Well, you can use such condition to find out the number of open contracts for this position. Not sure i understand what exactly you are going to do next with this info.

The name of an entry will be given when the first entry order is filled. Even if other orders extend the open position, the entry name will remain the same. it will be general for the whole position. MultiCharts basically works with positions, not entries.
Attachments
Test_HistoryOrdersLookUp.pln
(2.02 KiB) Downloaded 434 times

KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Re: how do i find if a given order is filled...

Postby KhaosTrader » 16 Oct 2012

Ok let me explain what i want to do, and u can best explain how to use this technology to achieve...

I want to be able to enter a position, then if its going well, add to that position, perhaps i might do 2 or 3 adds... of varying amounts...

But i need to track the profitability of the first entry as well as each of the adds, and I need to be able to manage them, perhaps i will have different stops and targets for each add.

With this in mind, how do u best suggest I approach this?

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: how do i find if a given order is filled...

Postby Andrew MultiCharts » 16 Oct 2012

Only by using MC .NET. EasyLanguage doesn't give you such possibility.

KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Re: how do i find if a given order is filled...

Postby KhaosTrader » 17 Oct 2012

Ok, lets try another approach.

Would it be possible for me to create seperate strategies on teh same instrument on the same chart? such that each one handles a unique trade type? I then have core entry on the first strategy and addontype1 on second strategy and addontype2 on third strategy. Can I make it such that each strategy would only control the positions it placed?

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: how do i find if a given order is filled...

Postby Andrew MultiCharts » 17 Oct 2012

If i get you correctly - no. The thing is that all signals applied to 1 chart form the strategy. All these signals interact within this strategy. What you are trying to do can be achieved by using your separate signals on separate chart windows. In this case they will not interact between each other (unless you use global variables) and you will be able to return values from this particular script on this particular chart. For better understanding of this scenario i strongly recommend you to read this article.


Return to “MultiCharts”