TRADING_BAD_STOPS
TRADING_BAD_STOPS
21 Jul 2017, 16:19
Hello,
I have a bot running where a position should be closed on SMA signals.For some reason I get the error as below and the postion is not closed when i should be. In the screenshot you can see where the cyan coloured sma closed above the purple sma line but I only got the error and the position wasnt closed. Sometimes it works but alot of the time it doesnt. In this instance I closed the position manually.
For some reason it wouldnt let me upload the screenshot so I uploaded to imgur: http://imgur.com/a/wqBwJ
I had a look at this thread /forum/cbot-support/2837?page=2 but I'm not sure it applies since my bot is meant to close it without using a set target.
Can you help me understand this error message and what I can do to ensure my position is closed every time its meant to?
Thanks
Replies
Spotware
21 Jul 2017, 16:55
Dear MagicTurtle,
Thanks for posting your issue. TRADING_BAD_STOPS error message occurs when your stop loss is set at a price not valid for a stop loss at the moment of execution. Also from your screenshot it seems that you are getting the error when amending the position and not when closing it. Is it possible to share with us the part of the code where these actions happen? This way we will be able give a more specific advice.
Best Regards,
cTrader Team
@Spotware
MagicTurtle
21 Jul 2017, 17:13
RE:
Thanks,
Here is part of the code which should be closing the position:
thanks
private bool IsShortCloseSignal() { if (_sma7.Result.HasCrossedAbove(_sma8.Result.LastValue, 0)) { return true; } else { return false; } } #endregion #region Position management /// <summary> /// /// </summary> /// <param name="tradeDirection"></param> private void ManagePositions() { // Open short if (IsShortOpenSignal()) { // make sure there is not a short already open if (!IsPositionOpenByType(TradeType.Sell)) { OpenPosition(TradeType.Sell); } } // Close short if (IsShortCloseSignal()) { ClosePosition(TradeType.Sell); } } /// <summary> /// Closes a single position for this unique cBot instance /// </summary> /// <param name="type"></param> private void ClosePosition(TradeType type) { var p = Positions.Find(InstanceName, this.Symbol, type); if (p != null) { ClosePosition(p); } }
@MagicTurtle
Spotware
26 Jul 2017, 09:41
Dear MagicTurtle,
We cannot see anything wrong in the provided code sample. Can we have a sample cBot as well trading conditions (Symbol, Timeframe) that we can use to reproduce the message? If we can reproduce the message we would be able to give you some advice. It doesn't need to be your cBot but just a cBot that reproduces the message.
Best Regards,
cTrader Team
@Spotware
MagicTurtle
27 Jul 2017, 06:08
Hello,
It keeps happening and with a number of my trades as well so I can send you my code.
Can you please provide me with an email address where I can send my code? In this instance which is separate from the AUD?JPY example I have a position in USD/CAD which gives the same message
Thanks
@MagicTurtle
MagicTurtle
27 Jul 2017, 10:44
Thank you,
I have sent that through, also I am using windows 10 64 bit with Calgo 2.01
@MagicTurtle
MagicTurtle
14 Aug 2017, 04:52
Hello,
Any updates? I asked your colleague at community 10 days ago for an update but he hasnt replied.
thanks
@MagicTurtle
MagicTurtle
07 Sep 2017, 13:03
Hello,
Has there been any updates?
Can you let me know the progress? I'm starting to lose confidence here.
thanks
@MagicTurtle
Spotware
07 Sep 2017, 14:04
RE:
Dear MagicTurtle,
Our team ran your algorithm for several days but we could not reproduce the message. We have explained in this discussion the reason that this message occurs, therefore this should help you troubleshoot your algorithm. If there is no easy way to reproduce the problem, there is no easy way to assist further. You are probably requesting a Stop Loss for a position that falls within the margin. You need to carefully log all the related information and check if this happens when you receive the TRADING_BAD_STOPS message.
Best Regards,
cTrader Team
@Spotware
MagicTurtle
07 Sep 2017, 16:13
Thank you for the update,
So I can understand a bit better, could you please clarify what 'requesting a Stop Loss for a position that falls within the margin' entails and how I can avoid this,
cheers
@MagicTurtle
Spotware
07 Sep 2017, 16:25
Hi MagicTurtle,
Suppose the below scenario
EURUSD Ask Price: 1.20290 EURUSD Bid Price: 1.20270.
If you place a Buy Order with a SL of 1 pip it means that the SL is at 1.20280 which is already higher than the Bid Price. In this case the SL cannot be placed. When placing Buy orders SL should always be lower than the Bid price and placing Sell orders SL should always be higher than the Ask price.
Best Regards,
cTrader Team
@Spotware
MagicTurtle
21 Jul 2017, 16:21
RE:
MagicTurtle said:
Here is one of the error messages: "21/07/2017 13:00:01.417 | → Request to amend position PID1447744 (SL: 0.792) is REJECTED with error "TRADING_BAD_STOPS""
and I've sent the troubleshooting info through to the support team referencing this thread,
@MagicTurtle