I'm debugging as to why my intraday trading script isn't generating any signals in live-trading and I have the following code as a test:
clearly, after every time the strategy is called an order signal should be generated, yet none are. I'm running in the strategy monitor with 5-minutes bars in the dummy broker with IQ-Feed real time data - for what reason would a signal not be generated? The strategy is activated in the strategy monitor.
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript9 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { if (!HasOpenPosition(bars, PositionType.Long)) { PlaceTrade(bars, TransactionType.Buy, OrderType.Market); } else { //code your sell conditions here } } //declare private variables below } }
clearly, after every time the strategy is called an order signal should be generated, yet none are. I'm running in the strategy monitor with 5-minutes bars in the dummy broker with IQ-Feed real time data - for what reason would a signal not be generated? The strategy is activated in the strategy monitor.
Rename
can you show us the strategy monitor log?
QUOTE:Actually, that will "never" generate a signal because it will have bought a position on bar #1 (and held it).
clearly, after every time the strategy is called an order signal should be generated, yet none are.
Add this to Initialize, then you'll always get a signal -
CODE:
StartIndex = bars.Count - 1;
Yep, I realised this after I posted. Ultimately the problem in my actual script lies in the StartIndex, I guess the required “burnin” of the StartIndex is longer than what is being loaded in initially by the strategy monitor. Is there any intuition as to how to manage this in live-trading?
Add more bars of data in the Strategy Monitor data range.
This was just a problem with what you posted. It's unlikely to be the problem in the S. Monitor. (If it is, the solution is simple: Make sure you load at least enough data so that the BarHistory has more bars than the StartIndex.)
Probably you need to start with what Glitch asked. For example, if you're using delayed data, we'd be able to see evidence of that in the log, and that's one reason why you'll never get signals in the S. Monitor.
---
Aside:
To be clear, you should never assign StartIndex = bars.Count - 1; in a trading strategy!
This is only a trick to make the strategy process ONLY the last bar and nothing else.
Probably you need to start with what Glitch asked. For example, if you're using delayed data, we'd be able to see evidence of that in the log, and that's one reason why you'll never get signals in the S. Monitor.
---
Aside:
To be clear, you should never assign StartIndex = bars.Count - 1; in a trading strategy!
This is only a trick to make the strategy process ONLY the last bar and nothing else.
Thanks guys, long day and I kept misreading the data range option in strategy monitor as something else… all sorted!
Your Response
Post
Edit Post
Login is required