AA mode and setstoploss order  [SOLVED]

Questions about MultiCharts and user contributed studies.
wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

AA mode and setstoploss order

Postby wilkinsw » 25 Apr 2013

If I'm trading in AA mode and for whatever reason my stop entry order isn't filled at the broker, will my setstoploss order still be active?

Ie if my long order is not filled but my chart thinks I'm long, will the broker still execute as per my chart triggered setstoploss rules leaving me incorrectly short?

Thanks!

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

Re: AA mode and setstoploss order

Postby wilkinsw » 25 Apr 2013

Also:

If IOG mode is off:

In the space of one 60min bar (intrabar) is it possible to enter long on a stop, get stopped out on a setstoploss order, then reenter at the original stop long entry? Or will it only attempt the long once?

escamillo
Posts: 203
Joined: 25 Mar 2011
Has thanked: 23 times
Been thanked: 56 times

Re: AA mode and setstoploss order

Postby escamillo » 25 Apr 2013

You can learn a lot by searching the forums and looking at other peoples code and questions that others have had that might be similar to yours, and then perhaps you can ask better questions and develop your own code that you can post such that more people can and will be willing to help. There are also pretty good basic reference manuals available. You will need to carefully proof any code that consider using in SIM mode prior to using coded entries, exits and stops in a live money account.

For order entry, the following code will limit your number of entries to one per bar, which is a good idea in general, and you can re-issue a strategy order by turning a triggered strategy off and then back on (where Buy_Condition is a True/False Variable [based on your entry criteria] and Size_Entry is an Input):

Code: Select all

If LastBarOnChart AND EntriesToday(Date) = 0 AND Buy_Condition then
Buy ("LongEntry") Size_Entry Contracts Next Bar Market ;
To have a protective stop become active on an entry bar one tick after your order has been entered, the following code should work (you will need a separate protective stop strategy for bars after the entry bar):

Code: Select all

[IntraBarOrderGeneration = TRUE]
Input: StopAmount(250) ;
SetStopContract ;
if MarketPosition [1] = 0 and MarketPosition [0] <> 0 then SetStopLoss(StopAmount) ;
Protective stop behavior can be a big issue - where will your stop reside? - at the exchange? - at your broker? - on your computer? [which means at some time it possibly/likely will be impacted by data connectivity and your own computer issues.] Different brokers can handle stops differently, and if you trade electronic futures, some of the exchanges have implemented rules such that in a fast market, even if your stop is residing on their server, you are not guaranteed execution (see page 14):
Attachments
CME Globex Reference Guide.pdf
(345.27 KiB) Downloaded 528 times

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

Re: AA mode and setstoploss order

Postby wilkinsw » 25 Apr 2013

Hi thanks for the reply.

I've had a good look for the answers to my questions and haven't found the conclusive answers I'm after. Not saying they are not there, just haven't found them. As you say an option is just trial and error execution on a sim.

Re your reply. I don't want to limit number of entries per day. My question was simply whether the stated scenario is possible. Also it is my understanding that IOG is not necessary for setstoploss.

My other question was regarding a scenario analysis of whether or not setstoploss can be triggered if I'm flat at the broker.

Trivial questions I'm sure. Would be very grateful for a trivial answer.

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: AA mode and setstoploss order  [SOLVED]

Postby TJ » 25 Apr 2013

Hi thanks for the reply.
...
My other question was regarding a scenario analysis of whether or not setstoploss can be triggered if I'm flat at the broker.

Trivial questions I'm sure. Would be very grateful for a trivial answer.
see post #5
[FAQ] OCO Orders
viewtopic.php?f=16&t=10811

the short answer is NO.
setstoploss is automatic when there is a position.


Return to “MultiCharts”