Support Board
Date/Time: Sun, 22 Dec 2024 15:53:32 +0000
Post From: ACSIL SCT_ORDERTYPE_TRAILING_STOP example needs updating
[2015-08-11 03:15:16] |
bjohnson777 (Brett Johnson) - Posts: 284 |
My ACSIL program will wait for an active order and then add a trailing stop and a possible price target order (among other features still being programmed). I guess these can never be attached because the original order to start all this off will be entered by a human. Example being a market order when trade conditions are favorable. When I use sc.BuyOrder/sc.SellOrder in the above code to add a trailing stop to a newly filled order (the only order that was active), I kept getting order failures. When I swapped to sc.BuyExit/sc.SellExit, the trailing stop entry worked the first time. Since a trailing stop is used to exit a position when things go unfavorable, this notation does make sense to me. My trade environment variables: sc.AllowOnlyOneTradePerBar = true;
sc.AllowMultipleEntriesInSameDirection = false; //one trade managed at a time. sc.AllowEntryWithWorkingOrders = false; //one trade managed at a time. sc.SupportReversals = false; sc.AllowOppositeEntryWithOpposingPositionOrOrders = false; //don't trade against yourself on the same chart. sc.SupportAttachedOrdersForTrading = false; //don't use attached orders from the chart Trading Window. sc.CancelAllOrdersOnEntriesAndReversals = true; //start fresh going in. sc.CancelAllWorkingOrdersOnExit = true; //allows for exits with attached orders. I chose these to make sure the ACSIL program would behave itself if something went wrong. I don't want it to make a trade even larger when it is supposed to be closed out. Did I miss something in my comment descriptions? Elsewhere in the program I use sc.FlattenAndCancelAllOrders() as an "exit all" when certain events are met. That has always worked fine. What I want is the SC controlled trailing stop at a larger price distance away as a safety stop in case something goes wrong. At the very least, a plain stop order will exist on the trade server if the connection is lost. I want the SC controlled price target as a generic exit if a profit target is met. This will be a stop or limit order a distance away from the entry price. In the code, the price target order is created first. But now I have a new problem. Price target in a long position will give this error with sc.SellOrder: SellEntry signal is ignored because Long position quantity or working Buy order exists. "Long position quantity" exists. A "working Buy order" does not exist. The trailing stop code is executed after this and enters the order fine. Isn't a "Long position quantity" existing exactly what I want when I create a limit sell order above the entry price? If the price target is set up as sc.BuyExit for a long position, it will enter but block the trailing stop with: Order Action is ignored because sc.AllowOnlyOneTradePerBar is TRUE and a signal for the same Order Action (BuyExit) was already given on the bar. I put an order in that wasn't going to result in a trade yet. Shouldn't sc.AllowOnlyOneTradePerBar allow that? An s_SCOrderFillData object wasn't created by the previous order entry. Or should "sc.AllowOnlyOneTradePerBar" really be called "sc.AllowOnlyOneOrderPerBar"? All this is making me a bit confused. I need some help, please. Date Time Of Last Edit: 2015-08-11 03:20:00
|