What happen when......?

Questions about MultiCharts and user contributed studies.
RedBerlin
Posts: 81
Joined: 05 Dec 2014

What happen when......?

Postby RedBerlin » 26 Jul 2017

hi leute
I d be know what happen in autotreding when: example
\\\\buy 5000shares
profit 5 tiks...stoploss 5 tiks
market goes up and reach my target but I sell only 3000 shares and market goes down.\\\\\\
maybe is a silly question but in autotrading what happen to others shares?
touch stoploss and close position or what?
danke sehr

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: What happen when......?

Postby wilkinsw » 26 Jul 2017

SA mode:

Default: you are long 2000 shares until either:

a) your target gets completely filled. You are flat.

or

b) your stoploss gets hit..... note that your stoploss size will be amended following your partfill, to 2000 shares. Therefore you're now flat.

Specify to convert to market unfilled orders after x seconds (applies to both SA and AA modes):

a) You are long 2000 shares

b) After x seconds or bar close, if sooner, you sell the balance. You are now flat.

In AA mode I believe all of the above holds true but not 100%

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: What happen when......?

Postby RedBerlin » 26 Jul 2017

SA mode:

Default: you are long 2000 shares until either:

a) your target gets completely filled. You are flat.

or

b) your stoploss gets hit..... note that your stoploss size will be amended following your partfill, to 2000 shares. Therefore you're now flat.

Specify to convert to market unfilled orders after x seconds (applies to both SA and AA modes):

a) You are long 2000 shares

b) After x seconds or bar close, if sooner, you sell the balance. You are now flat.

In AA mode I believe all of the above holds true but not 100%
Thank you for help.
but "convert unexected limit\stop entry orders to market orders after 1 second for instance"
means that the other shares will be sell at market?
I hope I have understood wrong because my broker doesnt accept order at market.

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: What happen when......?

Postby wilkinsw » 26 Jul 2017

yep , market.

Get a new broker. Otherwise IOG may be your only option.

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: What happen when......?

Postby RedBerlin » 27 Jul 2017

yep , market.

Get a new broker. Otherwise IOG may be your only option.
THAnks Wilk
but in strategy how to do IOG ?

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: What happen when......?

Postby wilkinsw » 27 Jul 2017

Wow massive questions there buddy.

To be honest I'd rather not advise you on IOG (intrabarordergeneration) as you really have to get stuck in and learn it yourself as it is full of nuances.

If you've got a realtime data provider then setup the "Paper Trader" broker profile and get busy printing to output and visualising what you code is doing.

In a nutshell:

IOG allows events outside of the default barstatus(1)=2 to a) trigger signal script calculation and b) allow the generation of orders (which normally happens only on barstatus(1)=2 events.

With IOG enabled:
- "close" = tick.
- close[1] = last barstatus(1)=2 close value.
- To reference the tick before current you need to declare an intrabarpersist variable (e.g. var: intrabarpersist c2(0) ). and at the bottom of your script save the current tick to this var (c2=close). Next time the script runs any code above this that uses "c2" will be referring to the tick before current.
- To flag an intrabar event and keep it flagged (else it will revert to last barstatus(1)=2 value, next tick) always use intrabarpersist.
- open, high, low, close all refer to the current incomplete bars values. Open stays the same from the first tick of the current bar, obviously.
- you can preserve parts of your code to be calculated the default way by keeping it in a "barstatus(1)=2" if/then statement.

It is a delicate process, but when you understand it, you can do almost anything.

BUT....ALWAYS avoid using it unless you have to as mistakes can be costly and CPU loads can be much higher...especially if you don't understand how to code efficiently.

Seriously though. You're telling me you can't send a market order? I would sort that out first. Else you will have to code everything with marketable limit orders (if you don't know what that means... please don't ask) and can't use in built market order functionality. Also have a search on using marketposition and marketposition_at_broker keywords to check for position mismatches vs ideal. You could simply have one chart which is sim only that plots i_marketposition and sets it as a GV (Global Variable). On your live chart you could add a signal that gets the GV and compares is to marketposition_at_broker. If mismatches then buy/sell the mismatch. Next bar, that signal would fire off a corrective orders. Still a pigs ear. Change broker! Or except that you will miss fills sometimes (i do).


Return to “MultiCharts”