Login Page - Create Account

Support Board


Date/Time: Mon, 06 May 2024 21:54:39 +0000



Simple trailing stop doesn't work for me

View Count: 1335

[2016-12-07 13:53:50]
User788673 - Posts: 2
I'm trying an indicator based system with a trailing stop which seemed to be working just fine when I only made long positions. When I added the option to go short, the system refuses to go short, and instead only keeps going long during backtesting. In fact I get "Sell Entry signal is ignored because maximum short position allowed has been reached or would be exceeded with the new order.Max positon allowed: 20. Resulting position with working orders: -21. Resulting position with Market working orders: 0" message from the message log.

The problem is that even if I increase the maximum position allowed, the program still only goes long. So I know you don't help with programming, I just want to ask if the following lines might ellicit an error, otherwise I'll figure it out on my own.

In the sc.SetDefaults I am seting these variables to true:


sc.AllowMultipleEntriesInSameDirection = true;
    sc.AllowEntryWithWorkingOrders = true;
    sc.MaximumPositionAllowed = 20;


And when I make an order (either for BuyEntry or SellEntry) I do this:



s_SCNewOrder NewOrder;
  NewOrder.OrderQuantity = 1;
  NewOrder.OrderType = SCT_ORDERTYPE_TRAILING_STOP;
  NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;
  NewOrder.Target1Offset = 10*sc.TickSize;
  NewOrder.StopAllOffset = 21*sc.TickSize;
  NewOrder.AttachedOrderStopAllType = SCT_ORDERTYPE_TRAILING_STOP;
Date Time Of Last Edit: 2016-12-07 13:54:06
[2016-12-07 21:43:09]
Sierra Chart Engineering - Posts: 104368
We do not see any obvious problem with that code.

Refer to the instructions here to determine the problem:
http://www.sierrachart.com/index.php?page=doc/ACSILTrading.html#DebuggingTradingSystems

From our perspective it is hard to tell what the problem is without knowing all that is going on.

Are you using sc.SupportReversals?
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2016-12-08 10:33:55]
User788673 - Posts: 2
I have used sc.SupportReversals both as true and as false. I followed this suggestion to make it work: http://www.sierrachart.com/index.php?page=doc/AutoTradeManagment.php#UnmanagedAutomatedTrading

So basically in the sc.SetDefaults, I have these variables now:

sc.AllowMultipleEntriesInSameDirection = true;
    sc.AllowOppositeEntryWithOpposingPositionOrOrders = true;
    sc.AllowEntryWithWorkingOrders = true;
    sc.MaximumPositionAllowed = 1200;
    sc.SupportReversals = true;
    sc.CancelAllOrdersOnEntriesAndReversals = false;
    sc.AllowOnlyOneTradePerBar = false;



and I make an order exactly like in the first post, one with a trailing stop. Lastly, I use sc.BuyOrder(NewOrder) and sc.SellOrder(NewOrder), but the system still only goes long.

The first messages of the message log are: "SellEntry reversal order processed." The messages after a bit become: "SellEntry reversal ignored. Position with exit working orders quantity:" and a negative number that keeps increasing. -76, -78, etc.


Finally, the last messages of the log are: "Order cancellation failed | The order is no longer working and cannot be canceled"

All these problems then come from any attempt to initiate a short position I think.
[2016-12-08 19:27:53]
Sierra Chart Engineering - Posts: 104368
None of this is making any sense to us and it seems as though there is something seriously wrong with your trading system. It is going to be your responsibility to debug and resolve this.

For a proper functioning example, refer to the scsf_TradingExampleUsingReversals function in the /ACS_Source/TradingSystem CPP file provided with Sierra Chart.

Another thing, if you are using a trailing stop to enter the market, then that order is not going to fill right away. There will be no Position to reverse until such time that there is a Position established.

When using unmanaged automated trading, you are going to have a problem with a lot of accumulating orders. Inherently what you are doing is complicated.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2016-12-08 19:29:35

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account