Problem setting a stoploss too small

Created at 13 Sep 2015, 06:31
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!
andresort28's avatar

andresort28

Joined 13.09.2015

Problem setting a stoploss too small
13 Sep 2015, 06:31


I would like to know, why i can not set a stop loss like 0.5, 0.23 or 0,9 at time to create an ExecuteOrder.

In my case, I am just opening positions like this:

ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, Label, 0.53, 0);

Because I really need to set a stoploss with that kind of size.

Sometimes cAlgo create the position and with that stoploss and sometimes it does not.

I do not know why, but I would like to know if cAlgo have an specific small limit for stoploss. 

 

Thank you for your answer as soon as posible.


@andresort28
Replies

ClickAlgo
13 Sep 2015, 09:58

My wild guess is that the Spread from your broker is larger then your stop-loss.


@ClickAlgo

moneybiz
13 Sep 2015, 19:58

RE:

1906442735 said:

I would like to know, why i can not set a stop loss like 0.5, 0.23 or 0,9 at time to create an ExecuteOrder.

In my case, I am just opening positions like this:

ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, Label, 0.53, 0);

Because I really need to set a stoploss with that kind of size.

Sometimes cAlgo create the position and with that stoploss and sometimes it does not.

I do not know why, but I would like to know if cAlgo have an specific small limit for stoploss. 

 

Thank you for your answer as soon as posible.

Place the order without stop loss/take profit then when the order result is returned add the stop loss/take profit pips to the entry price of the returned order and use ModifyPosition/Async to update to the exact positions you want.

I do it this way:

        public void EnsurePositionRangesSet(Position position, double? stopLossPips, double? takeProfitPips, double pipSize)
        {
            var update = false;

            double? stopLossPrice = null;
            double? takeProfitPrice = null;

            if (stopLossPips.HasValue && !position.StopLoss.HasValue)
            {
                stopLossPrice = position.TradeType == TradeType.Buy
                                    ? position.EntryPrice - stopLossPips.Value*pipSize
                                    : position.EntryPrice + stopLossPips.Value*pipSize;
                update = true;
            }

            if (takeProfitPips.HasValue && !position.TakeProfit.HasValue)
            {
                takeProfitPrice = position.TradeType == TradeType.Buy
                                      ? position.EntryPrice + takeProfitPips.Value*pipSize
                                      : position.EntryPrice - takeProfitPips.Value*pipSize;
                update = true;
            }

            if (!update)
            {
                return;
            }

            if (!IsBacktesting)
            {
                LogEvent(TraceEventType.Verbose, 0, "Updating position ranges. EP: {0}, SL: {1}, TP: {2}", position.EntryPrice, stopLossPrice, takeProfitPrice);
            }

            UpdatePositionSafeAsync(position, stopLossPrice, takeProfitPrice, null, UpdatePositionRetryErrorCodes);
        }

 


@moneybiz

moneybiz
13 Sep 2015, 20:03

RE:

1906442735 said:

I would like to know, why i can not set a stop loss like 0.5, 0.23 or 0,9 at time to create an ExecuteOrder.

 ExecuteMarketOrder/Async converts entered pips to integer values. That's why you can't set real numbers like 0.53, 0.23, 0.9.

Set them according to the code above, that's how I do it for the same reason as yours.

 


@moneybiz