- ago
I set position size as 10% of equity. However, the order manager appears to be using % equity for setting sell size instead of selling entire position.
CODE:
Signal   Quantity   Symbol   "Security Name"   "Order Type"   "Order Price"   Status   "Fill Qty"   "Fill Price"   Timestamp    Sell   750   QQQ   INVESCO QQQ TRUST SERIES 1   Market   0   Filled   750   318.82   4/28/2022 07:03:04       Buy   762   QQQ   INVESCO QQQ TRUST SERIES 1   Market   0   Filled   762   323.41   4/28/2022 06:31:02      


I created this simple test strategy using Building Blocks.
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript4 { public class MyStrategy : UserStrategyBase {     public MyStrategy() : base() { } public override void Initialize(BarHistory bars) {          indicator1 = new EMA(bars.Close,5);          PlotIndicator(indicator1,new WLColor(0,0,0));          indicator1.MassageColors = true;          indicator2 = new EMA(bars.Close,60);          PlotIndicator(indicator2,new WLColor(0,0,255));          indicator2.MassageColors = true;          indicator12 = new EMA(bars.Close,5);          indicator22 = new EMA(bars.Close,60);          StartIndex = 60; } public override void Execute(BarHistory bars, int idx) {          int index = idx;          Position foundPosition0 = FindOpenPosition(0);          bool condition0;          if (foundPosition0 == null)          {             condition0 = false;             {                if (indicator1.CrossesOver(indicator2, index))                {                   condition0 = true;                }             }             if (condition0)             {                _transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, 0, "Buy At Market (1)");             }          }          else          {             condition0 = false;             {                if (indicator12.CrossesUnder(indicator22, index))                {                   condition0 = true;                }             }             if (condition0)             {                ClosePosition(foundPosition0, OrderType.Market, 0, "Sell At Market (1)");             }          } }       private IndicatorBase indicator1;       private IndicatorBase indicator2;       private IndicatorBase indicator12;       private IndicatorBase indicator22;       private Transaction _transaction; } }

Is there something in the auto-generated code that needs to be changed?

0
1,018
Solved
7 Replies

Reply

Bookmark

Sort
- ago
#1
In Preferences > Trading, you can enable "Always set Exit Order Quantity to full Position Quantity".
0
Best Answer
- ago
#2
Thank you. I now see another trading preference checkbox option "Use Broker-reported Account Value...."

How does this work? Is it an API feature that became available when I installed IB extension?
0
Cone8
 ( 4.83% )
- ago
#3
While viewing that page, just strike F1 and it's explained in the Help ;)
1
- ago
#4
Thank you. My question is whether the broker (IB) API is enabling this feature.
0
Cone8
 ( 4.83% )
- ago
#5
It's a Wealth-Lab function.
Wealth-Lab gets the account value via broker APIs and uses it as the total Equity value for Pct of Equity sizing for new signals.
1
- ago
#6
Wow. That's fantastic!!! I was going to write up a feature request for that!

Just curious.... If I did not have the IB broker extension installed, would this preference still be displayed, or inactivated / greyed out?
0
Glitch8
 ( 11.08% )
- ago
#7
It would still be displayed, it can be used with any Broker, even the "Dummy Broker" that comes with WL8.
1

Reply

Bookmark

Sort