- ago
Hi, I am looking to implement a hybrid trading approach with manual entries via broker, and automated exists via Wealth-Labs. I am using Interactive Brokers and TradeStation and have added the brokerage extensions to WL.

In it's most basic form, the automated exit strategy should implement a stop loss rule as a percentage below my entry price. If the price drops below the stop loss level, WL should first cancel any potentially outstanding orders at the broker for that symbol, and then issue an order to close the position.

I am thinking of a custom C# coded script which I can run in Strategy Monitor and enable//disable on a per-account basis. I also noted the Max Risk feature, which seems to be related and perhaps can be used to implement a basic stop loss rule - but not sure it works on live positions.

Can the above be implemented in WL? What is the best appraich? Any guidance will be appreciated!
0
240
13 Replies

Reply

Bookmark

Sort
Cone8
 ( 9.83% )
- ago
#1
"Max Risk" (sizing logic) wouldn't have anything to do with this because you've entered the trade manually with some arbitrary size.

Your exit strategy depends on an ad-hoc basis price (not from a strategy), so this requires a bit of custom programming to get the price of a position from the broker and implement it with your exit logic. Use the Concierge Service for custom programming jobs and consulting.
0
- ago
#2
Hi Cone

Thanks for offering your concierge services.

I do see my brokerage accounts and positions in the WL Accounts window, including all data points which I think we'd need: symbol, quantity, basis price and last price. WL is syncing my account portfolio just fine.

Also the WL framework seems to have relevant components BrokerAccount/BrokerPosition which I was hoping I can leverage in this context.

Would it not be possible to access the required datapoints within a C# strategy script? When you say custom programming, do you suggest the service for the development of the strategy itself or some additional extension to enable me to program my C# strategy?


0
- ago
#3
intrepitrade, this might help get you started. For example, I use Schwab with one account...
CODE:
var myAccount = SchwabBroker.Instance.Accounts[0]; var myPositions = myAccount.Positions; // dump the positions using WriteToDebugLog foreach (var position in myPositions) { WriteToDebugLog($"Position: {position.Symbol} - Entry Price: {position.BasisPrice} - " + $"Profit %: {position.ProfitPct}"); }
0
- ago
#4
WL is a backtesting simulation tool, and one principle purpose of a backtesting tool is to look for good "value" opportunities to buy undervalued stocks that are ripe to go up. Are you saying you're not a value trader?

If you're an investor instead, WL can monitor fundamentals and economic data as well, although setting that up is a bit more involved.
0
- ago
#5
@paul1986 - thank you, that has been helpful.
I managed to build on your code and my script can succesfully detect my account's open positions. The debug log outputs my positions, symbols and other required parameters.

However, when I try to run the strategy in Strategy Monitor I need to specify a single symbol or DataSet before I can get going. When I then activate and run the strategy, it only works on the single symbol or the symbols in the DataSet, which are not necessarily the same as the positions in my account.

What I really need is the ability to run the strategy on the symbols in my account. On each run of the strategy, it should look up the currently existing positions. The goal is to combine discretionary entries with automated exits in WL, so I do not need any backtesting capability for this particular strategy.

Can anyone think of a way to achieve this with out-of-the-box functionality?
0
- ago
#6
One way you could do this is to create a data set with a set of symbols you would expect to trade. It would probably be a superset of the symbols you currently have in your account. In the Execute method you could create some logic that checks if your account has the symbol currently being executed (e.g. bars.Symbol). If its not in your account then just return from Execute.
1
Glitch8
 ( 11.02% )
- ago
#7
What is your Broker? Most Broker extensions in WL8 have built in dynamic DataSets that already contain the symbols open in your account.
0
- ago
#8
Thank you both. The dynamic dataset path sounds most promising to me. I was testing with Interactive Brokers and TradeStation. I've noticed that in the DataSet, an entry for Interactive Brokers was popping up and it was listing my account number and the positions within the account.

However I am unable to apply the IB dynamic dataset to the strategy - there seems to be a weird glitch in the software which causes the OK button to become grayed out shortly after selecting that dataset.

I did not see that kind of dataset for TradeStation. Which broker extensions support the dynamic dataset? I might try using Tradier or Alpaca if that helps.

0
- ago
#9
I am now testing dynamic datasets with Alpaca, IB and Tradestation.
IB and Alpaca: the dynamic datasets are displayed, but not for Tradestation.

In case of Alpaca, I can select the dynamic dataset for my strategy. It does not work in case of IB because the OK button is greyed out.



Are these dynamic datasets automatically updated and if so, what triggers the update? can the strategy take these updates into account while it's running?
0
Glitch8
 ( 11.02% )
- ago
#10
I can see the dynamic DataSet but did you actually select it (click on it?)
0
- ago
#11
yes I selected the dataset shown in the screenshot, then the OK button shows up normally for a sec before turning dark.
0
Glitch8
 ( 11.02% )
- ago
#12
It looks like it might be automatically getting de-deselected for some reason. It looks like it's not selected in the UI because it doesn't have a lighter grey rectangle as a background. When the OK button becomes disabled can you select it again? I'll investigate why this might be happening for IB.
0
- ago
#13
I've emailed your support with a screen recording. Let me know if that helps.
0

Reply

Bookmark

Sort