Help with multiple orders

Questions about MultiCharts and user contributed studies.
wegi
Posts: 124
Joined: 02 Jun 2009
Has thanked: 5 times
Been thanked: 13 times

Help with multiple orders

Postby wegi » 09 Dec 2014

Hi,

i am testing an idea in an chart with 1 tick resolution.
My problem is, i can not generate more then one order in one direction.
If i have a long position, i can not buy again, to increase my size.

I tested every option under: format -> signal -> format the selected signal -> properties
I used "Allow any Entry and Exit"


The script is like this:

Code: Select all

[IntrabarOrderGeneration = True]
//.. some Inputs
//.. some variables

//..Calculating the Longsignal and save it in the boolean LongSignal

if LongSignal then Begin
Print(DateTimeToString_Ms(computerdatetime), "Place Buy Order ", NumToStr(possum,0));
buy possum Share this bar on close;
End;
The chart is showing only the first entry.
The output in the log shows that additional entries are generated, but no order appears on the chart.

The same problem is with the short entry.

I have to use tickcharts, because i found no good solution to buy immediately at MARKET in an 15 Min Bar, if my entry condition is true.

What wrong?

thx!

Wegi

wegi
Posts: 124
Joined: 02 Jun 2009
Has thanked: 5 times
Been thanked: 13 times

Re: Help with multiple orders

Postby wegi » 09 Dec 2014

I use: MultiCharts64 Version 9.0 Release (Build 10360)

wegi
Posts: 124
Joined: 02 Jun 2009
Has thanked: 5 times
Been thanked: 13 times

Re: Help with multiple orders [solved]

Postby wegi » 09 Dec 2014

I found the solution:

Strategy Propeties -> check Allow up to 10 orders at ...

Now it works.

wegi
Posts: 124
Joined: 02 Jun 2009
Has thanked: 5 times
Been thanked: 13 times

Re: Help with multiple orders

Postby wegi » 09 Dec 2014

i unresolved the topic, because i still have some problems with multiple orders.

with the solution above, i can enter more long or short position. but i am not able to scale out a position. I do following order commands:
1) buy 75 shares this bar at close
2) sell 25 shares this bar at close
3) sell 25 shares this bar at close
4) sell 25 shares this bar at close

The order commands 1) and 2) are working, but 3) and 4) don´t trigger an order in the chart, only in my output windows, that says me, that the order in the code was triggered.

what i want to do is to increase and reduce my position in a multiple way.
For example: buy 10, buy 20, sell 40, sell 10, buy 20 (we are flatt now :-) )
i am testing this with buy and sell orders, but it does not work as expected.

i know to use sell short and buy to cover as well.
But i am testing this step by step and my little buy - sell example above does not work.

Is there one more setting that i forgot?

thx wegi

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Help with multiple orders

Postby Henry MultiСharts » 09 Dec 2014

Hello wegi,

You need to use Total command in order to scale out of a position.

wegi
Posts: 124
Joined: 02 Jun 2009
Has thanked: 5 times
Been thanked: 13 times

Re: Help with multiple orders

Postby wegi » 09 Dec 2014

Hello Henry,


i added the total command:

Code: Select all

sell absvalue(diff) contracts total this bar on close;
but it does work, there is no difference.

does it work only with next bar at market?

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Help with multiple orders

Postby orion » 09 Dec 2014

For example: buy 10, buy 20, sell 40, sell 10, buy 20 (we are flatt now :-) )
i am testing this with buy and sell orders, but it does not work as expected.
thx wegi
That series of buy and sell commands does not make your position flat. Read the documentation on buy and sell. Also, the following excerpt from TS manual may be helpful to you. This is not spelt out in PL documentation, but we can it applies in PL given compatibility:

Buy this bar on close
When this order is generated, the following actions are taken:
  • A Buy arrow is placed on the current bar at the close tick mark.

    If the order is generated on an intra-day bar and not the last bar on the chart, the order is sent directly into the market as a market order.

    If the order is generated on an intra-day bar and it is the last bar on the chart, or it is a daily, weekly, or monthly chart, then the order is sent directly to the after hours market as a Day+ limit order at the price at the close of the bar. If it is not filled in the after hours session, then the order will be placed as a limit order on the open of the next trading day.

wegi
Posts: 124
Joined: 02 Jun 2009
Has thanked: 5 times
Been thanked: 13 times

Re: Help with multiple orders

Postby wegi » 10 Dec 2014

Here is an example of what i try to do.

Code: Select all

vars: doExit(false);

// Open a long Position of 75 contracts
// selling them in 3 steps.
if date = 1141210 then Begin

if time = 310 then buy 75 contracts this bar on close;

doExit=false;

if time = 330 then doExit = true;

if time = 400 then doExit = true;

if time = 430 then doExit = true;

if doExit then Begin
print(datetimetostring(datetime), "Sell 25 Contracts");
sell 25 contracts total this bar on close;
End;

End;
The output windows shows me 3 times my sell order, but i have only one in the chart.

but it´s interesting to see, that this version is working:

Code: Select all

vars: doExit(false);

// Open a long Position of 75 contracts
// selling them in 3 steps.
if date = 1141210 then Begin

if time = 310 then buy 75 contracts this bar on close;

doExit=false;

if time = 330 then sell 25 contracts total this bar on close;

if time = 400 then sell 25 contracts total this bar on close;

if time = 430 then sell 25 contracts total this bar on close;

End;
What is the difference?
i am not able to use the second way, because i generate the exit trigger like the first version.
And i have 1 - x sell orders.

Thx Wegi

wegi
Posts: 124
Joined: 02 Jun 2009
Has thanked: 5 times
Been thanked: 13 times

Re: Help with multiple orders

Postby wegi » 10 Dec 2014

i found the solution, i have set up an exit label like this:

Code: Select all

//not a good one, but it works :-)
sell (NumToStr(time,0)) 25 contracts total this bar on close;
But an other question.
The print command in my last example shows me 4 output lines for each bar.
Why 4 and not 1?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Help with multiple orders

Postby Henry MultiСharts » 10 Dec 2014

But an other question.
The print command in my last example shows me 4 output lines for each bar.
Why 4 and not 1?
Hello wegi,

It means you have IOG enabled for your signal.
Please see How Signals are Calculated for more information.


Return to “MultiCharts”