Hi,
I have a strategy that is running in the Strategy Monitor. When an alert happens I have it "Auto-Place" so that it will go the orders page. On the orders page I have set it up so that the order is "Auto-Trading" for a paper account.
My question is I see that when a BuyAtLimit or ShortAtLimit is called that an order does indeed show up in the orders page, however, the script doesn't see any entries in the ActivePositions array. Even when status of the order goes from "Active" to "Filled". When or how does a position end up in the ActivePositions array?
Thanks,
-Frank
Size:
Color:
QUOTE:
Even when status of the order goes from "Active" to "Filled".
Active order != active position. It's just a live alert that has yet to come to fruition (or not).
QUOTE:
When or how does a position end up in the ActivePositions array?
Speaking without regard to your complicated and specific strategy, this happens after the current partial bar finishes i.e. on the next bar. Quoting the
Wiki FAQ:
* A complete bar updates (can be 1-minute, 1-day, etc.)
* Your strategy executes over all the bars in the chart and determines if it wants to trade on the next bar.
** If it doesn't, you don't do anything.
** If it does, you place orders for the next bar and they're worked by your broker. (Process complete).
When the current bar is complete (i.e. when the next interval starts), new Positions (and not orders) end up in the ActivePositions list.
Size:
Color:
Eugene,
Thank you for the answer. My concern is that I am seeing ActivePositions.Count increase when I run my script in a Strategy Window using historical data. However, when I run my strategy in the Strategy Monitor during market hours using real-time data, I see Alerts showing in the Alerts window then (auto-stage) to the Orders windows. In the Orders window I have set it to Auto-Trade in a paper account. However when an order shows up in the order window and/or goes from Active to Filled, my Strategy code doesn't see ActivePositions.Count go above 0. I don't know if I am missing a configuration item or something else. Should the ActivePosiitons.Count be greater than zero when an order shows up in the orders window and has an Active status? Or does the ActivePositions.Count only increase when an order arrives in the order window and has a status of filled? Without the ActivePostions array containing the position that is active/filled my strategy assumes that the position was never filled and on the next bar calls BuyAtLimit or SellAtLimit until a position shows up in ActivePositions or after trying 5 times.
Thanks again for your time and help.
-Frank
Size:
Color:
Frank,
If your script is programmed correctly, you should expect the ActivePositions.Count to increase on the next bar if a matching order has been Filled (not Active or Submitted). WealthScript gives enough rope to shoot yourself in the foot flexibility to get out of sync in the SM.
Another possible reason is that Strategies run in theoretical mode. Please review Orders > Portfolio Synch (esp. AtLimit Entries) in the Wealth-Lab User Guide.
Size:
Color:
Eugene,
I think I'm doing something wrong. I may have a configuration wrong or something. Attached you will find a screen shot of my setup of the Strategy Monitor and the Orders Window. I have configured the Strategy Monitor to "Auto-Place" the alerts to the Orders Window. In the Orders Window I have it configured to "Auto-Trade" for the PaperAccount1.
As shown in the Orders Window, at 12:44 PM an order comes in to BuyAtLimit BREW. In the Order Messages of the Order Window it can be seen that at 12:44:29 PM the order is Active and at 12:44:37 PM it is Filled. At no point during this time, or any minute after this, does my strategy register any change in the ActivePositions array or the Positions array. This is very confusion to me. What my strategy assumes when there is no change in these arrays is that the order was never filled and therefore tries to do another BuyAtLimit on the next bar. This results in another order entry showing a BuyAtLimit for BREW a second, third and fourth time.
I am printing the contents of both the ActivePositions and Positions array outside the bar for loop in the WealthScript.Execute member function as shown here:
CODE:
Please log in to see this code.
I don't understand what I am doing wrong during the day using real-time streaming data. If I do this in a historical run in the Strategy Window the ActivePositions and Positions array do change and I get the expected results.
Is there a piece of data that I can gather for you that will help me understand what I am doing wrong. Or maybe I have mis-configured something. Any help that you can give me would be greatly appreciated.
Thanks,
-Frank
Size:
Color:
Frank, I didn't read your code past this line:
CODE:
Please log in to see this code.
In the SM, you cannot just execute on the last bar; the historical trades must be preserved if you care about the ActivePositions. Starting over breaks this link and is the culprit.
Size:
Color: