Hey everyone,
A bit new to C# and Wealth Lab - I'm working on a simple SMA strategy for TQQQ and can't get all of my orders to place.
All of my code blocks are triggering sales and purchases, but they don't always seem to be working. I added some debugging to make sure that the logical statements were being evaluated as true, which they are.
Cody example:
Trade gap:

From the Debug Log:
You can see in the debug log that it's writing "bull Long Order Placed after March 2, 2017 for a TQQQ order, but no TQQQ order is placed in the screenshot of the Positions list.
However, you can see in the positions list that TQQQ orders have been placed before (and are placed throughout the years), just not here specifically.
Any ideas? It's implicit that most of my code is accurate, given the Debug Log is being updated correctly - I'm just not sure why the orders aren't getting placed all the time.
Is there another way to debug PlaceTrade() to see what's going on?
Thanks in advance.
A bit new to C# and Wealth Lab - I'm working on a simple SMA strategy for TQQQ and can't get all of my orders to place.
All of my code blocks are triggering sales and purchases, but they don't always seem to be working. I added some debugging to make sure that the logical statements were being evaluated as true, which they are.
Cody example:
CODE:
else if ((_rsiStatus == rsiMode.Oversold & !_rsiOverride) | _smaStatus == smaMode.Bull) { WriteToDebugLog($"{bars.DateTimes[idx]:yyyy-MM-dd} Bull RSI: {rsi} Thresh: {_oversold} SPY: {spyClose} SMA: {sma}"); foreach (var p in OpenPositionsAllSymbols) if (p.Bars.Symbol != _tqqq.Symbol) { ClosePosition(p, OrderType.Market, 0, "SMA Bull or RSI Oversold Flatten"); WriteToDebugLog("Orders Cleared for Bull"); } if (!HasOpenPosition(_tqqq, PositionType.Long)) { PlaceTrade(_tqqq, TransactionType.Buy, OrderType.Market, 0, "SMA Bull or RSI Oversold Long"); WriteToDebugLog("Bull Long Order Placed"); } _rsiStatus = rsiMode.Neutral; _smaStatus = smaMode.Neutral; return; }
Trade gap:
From the Debug Log:
CODE:
2017-01-27 RSI OB RSI: 82.79 Thresh: 79 2017-01-30 Bull RSI: 67.02 Thresh: 31 SPY: 227.55 SMA: 215.65 Orders Cleared for Bull Bull Long Order Placed 2017-01-31 Bull RSI: 63.58 Thresh: 31 SPY: 227.53 SMA: 215.75 2017-02-01 Bull RSI: 69.55 Thresh: 31 SPY: 227.62 SMA: 215.84 2017-02-02 Bull RSI: 67.97 Thresh: 31 SPY: 227.77 SMA: 215.93 2017-02-03 Bull RSI: 70.41 Thresh: 31 SPY: 229.34 SMA: 216.03 2017-02-06 Bull RSI: 71.42 Thresh: 31 SPY: 228.93 SMA: 216.13 2017-02-07 Bull RSI: 74.4 Thresh: 31 SPY: 228.94 SMA: 216.23 2017-02-08 Bull RSI: 75.69 Thresh: 31 SPY: 229.24 SMA: 216.33 2017-02-09 Bull RSI: 78.34 Thresh: 31 SPY: 230.6 SMA: 216.44 2017-02-10 RSI OB RSI: 80.49 Thresh: 79 Orders Cleared for Overbought Overbought Long Order Placed 2017-02-13 RSI OB RSI: 83.6 Thresh: 79 2017-02-14 RSI OB RSI: 85.17 Thresh: 79 2017-02-15 RSI OB RSI: 87.51 Thresh: 79 2017-02-16 RSI OB RSI: 86.71 Thresh: 79 2017-02-17 RSI OB RSI: 88.37 Thresh: 79 2017-02-21 RSI OB RSI: 89.96 Thresh: 79 2017-02-22 RSI OB RSI: 90.08 Thresh: 79 2017-02-23 RSI OB RSI: 79.88 Thresh: 79 2017-02-24 RSI OB RSI: 81.09 Thresh: 79 2017-02-27 RSI OB RSI: 81.87 Thresh: 79 2017-02-28 Bull RSI: 73.47 Thresh: 31 SPY: 236.47 SMA: 218.15 Orders Cleared for Bull Bull Long Order Placed 2017-03-01 RSI OB RSI: 81.11 Thresh: 79 Orders Cleared for Overbought Overbought Long Order Placed 2017-03-02 Bull RSI: 70.61 Thresh: 31 SPY: 238.27 SMA: 218.48 Orders Cleared for Bull Bull Long Order Placed 2017-03-03 Bull RSI: 72.07 Thresh: 31 SPY: 238.42 SMA: 218.65 2017-03-06 Bull RSI: 67.56 Thresh: 31 SPY: 237.71 SMA: 218.81
You can see in the debug log that it's writing "bull Long Order Placed after March 2, 2017 for a TQQQ order, but no TQQQ order is placed in the screenshot of the Positions list.
However, you can see in the positions list that TQQQ orders have been placed before (and are placed throughout the years), just not here specifically.
Any ideas? It's implicit that most of my code is accurate, given the Debug Log is being updated correctly - I'm just not sure why the orders aren't getting placed all the time.
Is there another way to debug PlaceTrade() to see what's going on?
Thanks in advance.
Rename
What is your position sizing? It's possible there was not enough simulated capital to take all of the positions. You can verify this by looking at the Metrics Report. Are there NSF Positions?
Thanks Glitch!
I didn't notice/know about that - it looks like there are 105 NSF Positions, so that's probably where they all are.
My position sizing is Percent of Equity: 100%
I didn't think this would be an issue beacuse each of my regime handlers will exit all other positions before placing trades - you can see in the code I shared the loop statement. But now I can tell from the debug details that the close position logic is only passed through once, and the place trades logic is also only passed through once:
Which is strange because the criteria should continually be true? Do NSF trades still count towards open positions? That's the only check I have before placing orders:
Otherwise I would expect to see these clause be true each day until the order is placed, though it only seems to be true the first day (and then .. likely the original positions haven't been closed/sold yet, so the long position would be NSF on the first day).
Any thoughts on how to deal with that?
I didn't notice/know about that - it looks like there are 105 NSF Positions, so that's probably where they all are.
My position sizing is Percent of Equity: 100%
I didn't think this would be an issue beacuse each of my regime handlers will exit all other positions before placing trades - you can see in the code I shared the loop statement. But now I can tell from the debug details that the close position logic is only passed through once, and the place trades logic is also only passed through once:
CODE:
Bull Long Order Placed 2017-03-01 RSI OB RSI: 81.11 Thresh: 79 Orders Cleared for Overbought Overbought Long Order Placed 2017-03-02 Bull RSI: 70.61 Thresh: 31 SPY: 238.27 SMA: 218.48 Orders Cleared for Bull Bull Long Order Placed 2017-03-03 Bull RSI: 72.07 Thresh: 31 SPY: 238.42 SMA: 218.65 2017-03-06 Bull RSI: 67.56 Thresh: 31 SPY: 237.71 SMA: 218.81 2017-03-07 Bull RSI: 64.18 Thresh: 31 SPY: 237 SMA: 218.97
Which is strange because the criteria should continually be true? Do NSF trades still count towards open positions? That's the only check I have before placing orders:
CODE:
if (!HasOpenPosition(_tqqq, PositionType.Long)) { PlaceTrade(_tqqq, TransactionType.Buy, OrderType.Market, 0, "SMA Bull or RSI Oversold Long"); WriteToDebugLog("Bull Long Order Placed"); }
Otherwise I would expect to see these clause be true each day until the order is placed, though it only seems to be true the first day (and then .. likely the original positions haven't been closed/sold yet, so the long position would be NSF on the first day).
Any thoughts on how to deal with that?
Got myself sorted! Thank for the help - just had to release NSF positions, which you were alluding to.
Your Response
Post
Edit Post
Login is required