little problem with stoploss..
little problem with stoploss..
30 Oct 2018, 12:05
hello, i'm trying to make a stoploss that is been placed likt this:
buy: stoploss below MarketSeries.Low.Last(1)
sell: stoploss above MarketSeries.High.Last(1)
the stoploss on the buy part works perfect buy i have an issue with the stoploss for sell
the stoploss for a sell trade is not placed ABOVE MarketSeries.High.Last(1).. but BELOW MarketSeries.High.Last(1)
can someone fix this for me?
protected override void OnBar()
{
var stopLossBuy = MarketSeries.Low.Last(1) - Symbol.PipSize * SL;
var SLBuy = Math.Round((Symbol.Ask - stopLossBuy) / Symbol.PipSize);
var stopLossSell = MarketSeries.High.Last(1) - Symbol.PipSize * SL;
var SLSell = Math.Round((Symbol.Bid - stopLossSell) / Symbol.PipSize);
{
if (................................)
{
ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, label, SLBuy, null);
}
else if (..............................)
{
ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, label, SLSell, null);
}
Replies
jelle2500
30 Oct 2018, 12:15
RE:
Panagiotis Charalampous said:
Hi jelle2500,
Try this line of code
var SLSell = Math.Round((stopLossSell - Symbol.Bid) / Symbol.PipSize);Best Regards,
Panagiotis
hero!
thank!
@jelle2500
jelle2500
30 Oct 2018, 12:19
RE:
Panagiotis Charalampous said:
Hi jelle2500,
Try this line of code
var SLSell = Math.Round((stopLossSell - Symbol.Bid) / Symbol.PipSize);Best Regards,
Panagiotis
i did celebrate to soon.. the stoploss still is below the high instead of above the high..
@jelle2500
PanagiotisCharalampous
30 Oct 2018, 12:23
Change this one as well
var stopLossSell = MarketSeries.High.Last(1) + Symbol.PipSize * SL;
Best Regards,
Panagiotis
@PanagiotisCharalampous
jelle2500
30 Oct 2018, 12:27
RE:
Panagiotis Charalampous said:
Hi jelle2500,
Try this line of code
var SLSell = Math.Round((stopLossSell - Symbol.Bid) / Symbol.PipSize);Best Regards,
Panagiotis
got another sollution..
i'm making 2 different types of stoploss parameters..
for example:
BuyStopLoss: 10 pips
SellStopLoss: -10 pips
@jelle2500
jelle2500
30 Oct 2018, 12:33
RE:
Panagiotis Charalampous said:
Change this one as well
var stopLossSell = MarketSeries.High.Last(1) + Symbol.PipSize * SL;Best Regards,
Panagiotis
oh didn't see thisone yet..
works perfect! thanks Panagiotis!!
@jelle2500
PanagiotisCharalampous
30 Oct 2018, 12:11
Hi jelle2500,
Try this line of code
Best Regards,
Panagiotis
@PanagiotisCharalampous