How to Issue a Strategy Alert on an Intrabar Stop Loss Trade Exit

Questions about MultiCharts and user contributed studies.
eegroup
Posts: 78
Joined: 04 Aug 2008
Has thanked: 11 times
Been thanked: 9 times

How to Issue a Strategy Alert on an Intrabar Stop Loss Trade Exit

Postby eegroup » 17 May 2017

We want to display an Alert window whenever a Strategy order is taken on a chart (all entries and exits).
The chart has a one day bar resolution.
Trades might exist for several days to several weeks.
The Alerts function works correctly for the normal trade entries and exits, which are issued as market orders when the BarStatus = 2 (end of bar forming).
The Stop Loss Exit orders are issued to exit at a specific price [SELL "SL" NEXT BAR AT xx.xx STOP, or as SETSTOPLOSS_PT(SLTicks)].
Obviously, these Stop Loss Exits can occur intrabar.
The strategy is not an Intrabar Order Generation (IOG) strategy.
How can we capture in the strategy, when a Stop Loss Exit has been executed intrabar, without IOG turned on, so that we can issue an Alert based upon this condition (when the SL exit has taken place, not at the end of the bar upon which the SL exit has occurred)?
We could change the strategy over to IOG, but that seems to be excessive, especially when the normal trades occur so infrequently.
Any ideas would be appreciated.

Many thanks.

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: How to Issue a Strategy Alert on an Intrabar Stop Loss Trade Exit

Postby Angelina MultiСharts » 18 May 2017

Hello eegroup,

I think the easiest solution here would be monitoring position change with a separate indicator using the following keywords:
i_CurrentContracts
i_MarketPosition
i_MarketPosition_at_Broker_for_The_Strategy

eegroup
Posts: 78
Joined: 04 Aug 2008
Has thanked: 11 times
Been thanked: 9 times

Re: How to Issue a Strategy Alert on an Intrabar Stop Loss Trade Exit

Postby eegroup » 22 May 2017

Hi Angelina,

Thank you for your recommendations. We wrote an indicator to accomplish what you have suggested and applied it to our daily chart. Unfortunately, the indicator is only active at the end of each daily bar. Therefore the test of the market position using the i_MarketPosition command keyword in the indicator is only executed at the end of the bar, not intrabar. This defeats the purpose of being able to check if a stop loss order was executed intrabar and triggering an Alert condition close to when the Stop Loss order occurred. Even when the "Update on Every Tick" option is selected in the indicator, on a daily chart it only fires off the check for the market position at the end of a bar.

Also, we attempted to use IOG on the daily chart, but that also allows bar conditions only to be tested at the end of a bar on a daily chart.

Still searching for a viable solution.

Thanks,
eegroup

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: How to Issue a Strategy Alert on an Intrabar Stop Loss Trade Exit

Postby Angelina MultiСharts » 22 May 2017

eegroup,

For this indicator in Format Study window -> Properties tab -> is box "Update in Every tick" checked?

eegroup
Posts: 78
Joined: 04 Aug 2008
Has thanked: 11 times
Been thanked: 9 times

Re: How to Issue a Strategy Alert on an Intrabar Stop Loss Trade Exit

Postby eegroup » 22 May 2017

Hi Angelina,

Yes, "Update on Every Tick" was checked on the Indicator. It appears that this option on a Daily chart does not feed tick data to the chart (intrabar). But we were doing our testing over the weekend, so that might have been the issue, not sure.

We will do some additional testing today to see if ticks are being provided in real time to the Alert Indicator. We will report the results of our tests later today.

Thank you.


Return to “MultiCharts”