Stop-loss for leveraged position

Questions about MultiCharts .NET and user contributed studies.
et1hugo
Posts: 6
Joined: 25 Oct 2017
Has thanked: 3 times
Been thanked: 1 time

Stop-loss for leveraged position

Postby et1hugo » 28 May 2018

Hi guys

I'm trying to use the GenerateStopLoss(double amount) method to generate a percentage stop-loss on a Forex account. The problem is that since Forex accounts can use leverage you need to use the cost-basis of the position as apposed to the EntryPrice. I've seen code here on the forum along the lines of:

GenerateStopLoss(this.EntryPrice() * _stopLossPercent * Bars.Info.BigPointValue);

This will not work for a leveraged position because the above code assumes that your position is tied 1-to-1 with the price scale. You'd need to somehow reference the cost-basis of the position, e.g.:

GenerateStopLoss(<<position-cost-basis>> * _stopLossPercent * Bars.Info.BigPointValue);

Any idea's on how to do this? I've looked at the Positions array and there doesn't seem to be any notion of what a position is costing you. I've seen that Portfolio Trader does get the cost basis right, so it is somewhere in MutliCharts just not sure how to get it through the API. Additionally, it would be nice if the proposed code would work in backtesting as well, I know there's some features like the TradeManager's unmanaged orders that do not work in backtesting mode which is unfortunate.

Thank you in advance for any feedback.

Kind regards
Ettienne

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2944 times

Re: Stop-loss for leveraged position

Postby Henry MultiСharts » 29 May 2018

Hello Ettienne,

Chart's price * BigPointValue = money cost of 1 contract.
You need to set the BigPointValue of the symbol in QuoteManager to meet your leverage.
After that is done re-open the chart for this symbol and re-do the symbol mapping (either delete and add anew the lines for the symbol or just re-select the instruments in both data feed and broker columns).

et1hugo
Posts: 6
Joined: 25 Oct 2017
Has thanked: 3 times
Been thanked: 1 time

Re: Stop-loss for leveraged position

Postby et1hugo » 13 Jun 2018

Hello Henry

Thank you for the prompt reply, I'll look into this and adjust the symbol in the QuoteManager to incorporate the leverage used.

Kind regards
Ettienne


Return to “MultiCharts .NET”