Defining last price TP/SL

Created at 20 May 2019, 04:59
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ZE

zedodia

Joined 30.05.2018

Defining last price TP/SL
20 May 2019, 04:59


Another simple one i cant figure out.

When my bot crosses EMA's i am trying to set the SL at the price of one of the EMA's.

        private ExponentialMovingAverage _ema2;

        _ema2 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 200);

var _sl = _ema2.Result.LastValue;

( i have also tried _ema2.Result.Last(0);)

ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, null, _sl, 3.0)

 

it places the trade, but the SL is not at the EMA.

 


@zedodia
Replies

PanagiotisCharalampous
20 May 2019, 10:33

Hi zedodia,

The stop loss should be set in pips but you pass a price instead. You need to convert it into pips or use ModifyStopLossPrice after the position is opened.

Best Regards,

Panagiotis


@PanagiotisCharalampous

zedodia
21 May 2019, 00:22

RE:

Thankyou. Problem solved.


@zedodia