Questions about MultiCharts .NET and user contributed studies.
Posts: 81
Joined: 29 Apr 2013
Has thanked: 12 times
Been thanked: 16 times


Postby tradetree » 10 Jan 2014

I thought the following code would work for long and short entries. Right now I have a short entry in YG at 1220, and this code created a stop loss entry at 1201.7, where stop_loss_max is 8. This is clearly incorrect. The stop loss for a short position should be above the entry price, not below it. I checked the programming documentation and there is no indication regarding doing something special for a short position.

Code: Select all

if( StrategyInfo.MarketPosition != 0 ){
CurSpecOrdersMode = ESpecOrdersMode.PerContract;
GenerateStopLoss( stop_loss_max*100 );

User avatar
Alex MultiCharts
Posts: 194
Joined: 09 Aug 2013
Has thanked: 43 times
Been thanked: 76 times

Re: GenerateStopLoss

Postby Alex MultiCharts » 10 Jan 2014


Please try to exclude the conditions for GenerateStopLoss, as it is working only when there is an open position.

You can also use the pre-built Stop Loss signal script as the example.

Return to “MultiCharts .NET”