- ago
Since WL does not allow for tick processing of strategies, I'd like to see a Limit On Close order implemented.

Use case is running daily bars and want to exit at end of day, only if price has reached a specified level. If price is moving favorably, I want to let it run to end of bar, or end of day in this case. As it is now, I close the position with market the open of the next bar, not ideal, often leading to a reduction in profit.

WL would submit limit based on a minutes before close preference.



1
191
8 Answers

Reply

Bookmark

Sort
- ago
#1
Use OrderType.MarketClose.

Under Trading Preference you’ll find the setting for number of minutes before close to submit that order.
0
- ago
#2
I’ll post an example tomorrow 🙂
0
- ago
#3
Market on Close is not what I'm looking for.

I don't want to close the position unless a certain amount of profit has been achieved.

And I don't want to close the order as soon as the desired profit has been hit. I want it to run for the day, and only close at EOD if profit >= target

Another option is a limit order with a submit time parameter.

0
- ago
#4
I understand. You can certainly backtest this strategy. However you won’t be able to auto trade this since it relies on looking at the data for the next bar. We can add the additional desired feature to the request list!
0
- ago
#5
Sorry, I'm not getting across my ask very well.

It does not need to look at the next bar. I trade like this now, live, on another platform, daily bars, but process by tick.

Works as follows:
I have an open a position
At 3:58 I check my PnL on that position. If it's greater than 5%, exit, else do nothing.

Since I can't check my real time PnL within a bar with WL, A limit order with a 5% PT fired at 3:58 accomplishes the same thing - assuming I know my entry price.

Providing I'm not exiting on the same bar, I will. Or, if same bar, I can assume entry price = my entry limit order, knowing it will not be higher than that but may be lower.
0
Cone7
- ago
#6
Added OrderType.LOC to the Wish List.
1
- ago
#7
Thanks. And yes, this can be back-tested today by peeking ahead.
0
- ago
#8
I think I was the one who wasn't getting my idea across :)

Since WL7 is primarily a backtesting platform, I always think in those terms. In order to backtest your rule, you do need to look at the next bar of data. For example, here's a basic RSI entry, which exits at close, but only if the position closes with at least a 5% profit.

CODE:
using WealthLab.Backtest; using WealthLab.Core; using WealthLab.Indicators; namespace WealthScript1 { public class MyStrategy : UserStrategyBase { //Initialize public override void Initialize(BarHistory bars) {          rsi14 = RSI.Series(bars.Close, 14);          PlotIndicator(rsi14); } //Execute public override void Execute(BarHistory bars, int idx) { if (OpenPositions.Count == 0) { if (rsi14[idx] < 40)                PlaceTrade(bars, TransactionType.Buy, OrderType.Market); } else {             //we need to look at the next future bar to determine if we close at a 5% or more profit     //note that for this reason, we can't execute it on the last bar of data, thus it won't trigger a signal     //it's for backtesting only             if (idx < bars.Count - 1)             {                double nextBarClose = bars.Close[idx + 1];                double gain = nextBarClose - LastPosition.EntryPrice;                gain = (gain * 100) / LastPosition.EntryPrice;                if (gain >= 5.0)                   PlaceTrade(bars, TransactionType.Sell, OrderType.MarketClose);             } } }       //private members       private RSI rsi14; } }
0

Reply

Bookmark

Sort