combination of limit and stop

Questions about MultiCharts and user contributed studies.
auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

combination of limit and stop

Postby auato » 18 Feb 2017

Hi,

in my backtest desiring to have precise entries at precise pivot values and accordingly desiring to avoid the variations due to the nature of limit and stop orders for the better price, I found out I can obtain it using simultaneously in the same line of code both limit and stop commands like this example below:

Code: Select all

IF ...<some conditions are true>... then buy 1 contracts next bar at pivotlong stop pivotlong limit;

In the reality, using this code in the real time with my broker (webank) I get every time that it fills two orders for 2 contracts while I want it operates only with 1 contract as specified in my statement.... but why? Why does this statement allow me to enter at a precise value I want (pivotlong) in the backtest phase but when I turns it on in the real word with "automate order execution" it sends orders for two contracts?

Thank you,
auato

User avatar
bensat
Posts: 331
Joined: 04 Oct 2014
Has thanked: 46 times
Been thanked: 104 times

Re: combination of limit and stop

Postby bensat » 19 Feb 2017

Because you tell it to do ....

Code: Select all

... buy 1 contracts next bar at pivotlong stop pivotlong limit;
You have to be specific which order type to use regarding the location of the price when the signal will be generated.

like :

Code: Select all

if marketposition = 0 then
begin
if price > pivotlong then buy 1 contract next bar at pivotlong limit;
end
else
if price <= pivotlong then buy 1 contract next bar at pivotlong stop;
It's just an example. May someone has a more elegant solution ...

Regards

Ben

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: combination of limit and stop

Postby auato » 19 Feb 2017

Thank you very much @Ben!

I have another question regarding the same topic and I can better explain why I used that code.
As I wrote, I adopted the previous solution (with stop and limit simultaneously) to be sure to enter at a precise price because my idea is to enter only and whether the price of the next bar firstly touches the pivoltlong level, otherwise I wouldn't want it enters. I realised those limit/stop orders can allow you to get a better condition to enter, and this is a really good feature, but at the same time I am afraid this limit or stop command can invalidate my aim which is to enter as soon as the next bar reaches the pivotlong level.
So my question is: when I use a limit or stop order specifying a precise value/price,
  • 1) is the entering condition triggered when the next bar first touches the limit/stop value?

  • 2) or can it choose a better condition even if the limit/stop price has not been really reached?


In my case if the answer will be #1 it is not important to adopt any particular workaround and a normal limit order can be a great solution for me.

Thank you,
auato

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: combination of limit and stop

Postby auato » 20 Feb 2017

Ok, I presume I can answer my question. This morning I was "live" and I verified the behavior: the response is #2... so I need to find a workaround to implement my idea.
My idea is: when my conditions are verified, it can enter only if the next bar firstly reaches the pivotlong level. I am thinking that in my case I can use only stop orders... is this my solution?

Thanks,
auato


Return to “MultiCharts”