Confused about built-in EntryBar_*_Stop strategies

Questions about MultiCharts .NET and user contributed studies.
MidKnight
Posts: 343
Joined: 12 Aug 2012
Has thanked: 123 times
Been thanked: 56 times

Confused about built-in EntryBar_*_Stop strategies

Postby MidKnight » 11 Dec 2012

Hi there,

Looking at the code of some built-in strategies looks wrong to me or I'm not understanding whats going on there properly. For example, I'll use the EntryBar__Stop_LX.

A stop loss exit is put BELOW the entry price, but the code from CalcBar() is:

Code: Select all

if ((StrategyInfo.MarketPosition >= 0)){
m_Order.Send((Bars.Close[0] + m_bigpointrisk));
}
This is putting the stop loss ABOVE the bar close. Furthermore, this will adjust the stop to every bar after the trade regardless if it was the entry bar or not - no? If that is true, then the name of the strategy is misleading.

With kind regards,
MK

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Confused about built-in EntryBar_*_Stop strategies

Postby JoshM » 12 Dec 2012

(1) This is putting the stop loss ABOVE the bar close.

(2) Furthermore, this will adjust the stop to every bar after the trade regardless if it was the entry bar or not - no?
The first point depends on the value of 'm_bigpointrisk', which is defined as:

Code: Select all

protected override void StartCalc(){
m_bigpointrisk = (dollarrisk/((Bars.Info.BigPointValue)));
}
and 'dollarrisk' being

Code: Select all

[Input]
public double dollarrisk{
get { return m_dollarrisk; }
set { m_dollarrisk = value; }
}
So, I suspect that one should enter a negative value in the Input section to get the stop-loss below the bar close. This is indeed somewhat confusing, since for some people "dollar risk" means a negative value, while others see this a positive value.

The second point: as I read it, yes, the stop-loss order is send every bar after the trade. But this is a good thing! Because pending orders aren't "persistent" in MultiCharts, meaning you have to keep re-submitting them to prevent them from being cancelled. With intrabarordergeneration turned off, this has to be done once per bar (at close), and with that setting on, on every tick.

I couldn't find a good Wiki link for this, but on the page of SellShort, it says for example:
An order is executed at the point specified by the parameters; if the order is not filled within the specified bar, the order is cancelled.
Also see How Signals are Calculated.

MidKnight
Posts: 343
Joined: 12 Aug 2012
Has thanked: 123 times
Been thanked: 56 times

Re: Confused about built-in EntryBar_*_Stop strategies

Postby MidKnight » 12 Dec 2012

Hi JoshM, thanks for the reply.

I don't think one should be thinking they have to enter a negative value for the built-in strategy as there is both a LX and SX for this strategy. Each strategy should apply the appropriate offsetting based on the market position (the LX should apply negative offset, SX a positive offset). This really looks wrong the way it is - unless I'm not understanding enough.

Regarding the point about the stop order being submitted every bar. I have no problems with that concept (and I'd expect it) but again, look at the code. Its going to submit the order and apply the offset based on the close every new bar - not just the entry bar. Basically this means that if the closes are rising, its acting like a trailing stop. If the closes are falling (but not enough to hit the stop), then the stop will actually widen on each subsequently lower close. I had assumed from strategy name that it was going to strictly apply a stop loss based upon the entry bar, but this strategy does not do that despite being named as such.

This strategy should be renamed to something more meaningful to what it actually does - I have no idea what to name it to though because I don't see its current logic very useful. OR it should be coded to do what the strategy name suggests. I prefer the later :)

All my best,
MK

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Confused about built-in EntryBar_*_Stop strategies

Postby JoshM » 12 Dec 2012

I don't think one should be thinking they have to enter a negative value for the built-in strategy as there is both a LX and SX for this strategy.
Oh I see. But you can change the code of the LX and SX stop-loss strategy to reflect that (i.e. change "+" to "-" in the code).
I have no problems with that concept (and I'd expect it) but again, look at the code. Its going to submit the order and apply the offset based on the close every new bar - not just the entry bar. Basically this means that if the closes are rising, its acting like a trailing stop.
I missed that point. :) But again, the code can be changed to work as you wish. Untested:

Code: Select all

if ((StrategyInfo.MarketPosition >= 0)){
m_Order.Send((StrategyInfo.AvgEntryPrice - m_bigpointrisk));
}


Return to “MultiCharts .NET”