My back test says my strategy is off the charts in profit.
However, in practice during live trading my position does not get filled. I have tried a few work arounds with varying success.
I trade 5 min bars and use limit orders. Is it possible to access 1min data. while running 5min bars. The idea is the ATR for 1min is lower than 5min and with the higher sample rate the probability of getting filled during a 5min interval will be higher.
Any other ideas? Gemini 3 is failing with its approach which suggested this.
However, in practice during live trading my position does not get filled. I have tried a few work arounds with varying success.
I trade 5 min bars and use limit orders. Is it possible to access 1min data. while running 5min bars. The idea is the ATR for 1min is lower than 5min and with the higher sample rate the probability of getting filled during a 5min interval will be higher.
Any other ideas? Gemini 3 is failing with its approach which suggested this.
CODE:
using System; using WealthLab.Core; using WealthLab.Indicators; using WealthLab.Backtest; // Retained for type definitions // --- FIELD DECLARATION --- // Add this field declaration at the top of your strategy class private BarHistory _oneMinBars; public override void Initialize(BarHistory bars) { // ... Existing initialization code for 5-minute bars ... // 1. Get the current symbol (e.g., MNQH25, which you determine with your helper function) DateTime startDate = bars.DateTimes[0]; string activeSymbol = DetermineFuturesSymbol(startDate); // FIX: Removing 'base.StrategyData' and 'base.Log' which were causing compilation errors. // We are trying to call AddSymbol directly, relying on implicit inheritance/access. // Attempting to access AddSymbol directly. _oneMinBars = AddSymbol(activeSymbol, 1, 1); // The check for null _oneMinBars will now be handled in the Execute method. // ... Rest of your initialization ... } public override void Execute(BarHistory bars, int idx) { // --- Bar Alignment Check (MANDATORY for multi-timeframe) --- // Check for null just in case AddSymbol failed if (_oneMinBars == null || bars.DateTimes[idx] < _oneMinBars.DateTimes[0] || _oneMinBars.Count == 0) { return; } // --- Entry Logic: Using 1-Minute Bars for Better Limit Price --- // The entry logic is now wrapped in a function and called only if we don't have a position. if (Position == null) { // Replace 'Your long entry signal is true' with your actual condition if (/* Your long entry signal is true */) { HandleLimitEntry(bars, idx); } } // --- Position Management: Sticking to 5-Minute Bars --- if (Position.IsLong) { // You manage your stops/limits using the current 5-minute bar price data (bars.Close[idx], etc.) // Example: Place a profit target (limit order) based on the 5-min data double profitTarget = Position.EntryPrice + 5.0; // 5 points profit // Use the SellLimit/SellStop functions which will be evaluated on the 5-minute interval SellLimit(idx + 1, profitTarget, "5-Min Exit Target"); // You are now back to the 5-minute strategy logic for management. } // ... rest of your Execute method logic ... } // --- NEW FUNCTION: Encapsulates the multi-timeframe limit entry logic --- private void HandleLimitEntry(BarHistory bars, int idx) { // 1. Define the time window of the current 5-minute bar DateTime currentBarStart = bars.DateTimes[idx].AddMinutes(-bars.Interval); DateTime currentBarEnd = bars.DateTimes[idx]; // 2. Find the low price during this 5-minute interval using the 1-minute bars. // We look for the lowest low price observed during the 5-minute bar. // This method finds the lowest price within the 1-minute history // that corresponds to the time range of the current 5-minute bar. double lowestPriceIn5MinBar = _oneMinBars.GetLow(currentBarStart, currentBarEnd); // 3. Calculate your limit price based on the lowest observed price // Example: Set the limit price a small amount (e.g., 0.5 points) above the lowest 1-min low double entryLimitPrice = lowestPriceIn5MinBar + 0.5; // 4. Place the order using the calculated limit price // Note: This order will only be active for the NEXT bar (idx + 1) BuyLimit(idx + 1, entryLimitPrice, "Limit Entry (1-Min Price)"); } // ... rest of your strategy class methods ...
Rename
I'm over thinking it. I suggested the following.
That's an insightful question. Running the strategy on the 1-minute bar interval but executing the core logic only every 5 bars (mod(5)) is a smart technique that can simplify your code and still achieve the desired results, especially in environments where multi-data stream loading (AddSymbol) is difficult.
The Solution: Using idx % 5 == 0 for 5-Minute Logic
If you switch your primary strategy interval to 1-Minute and then use a modulus check (%) in your Execute method, you can effectively recreate the 5-minute logic cadence.
This approach eliminates the need for the complex and error-prone AddSymbol call and the auxiliary _oneMinBars history. The bars object passed to Execute becomes your 1-minute data source.
I will update the Canvas to reflect this simplified and more robust approach.
That's an insightful question. Running the strategy on the 1-minute bar interval but executing the core logic only every 5 bars (mod(5)) is a smart technique that can simplify your code and still achieve the desired results, especially in environments where multi-data stream loading (AddSymbol) is difficult.
The Solution: Using idx % 5 == 0 for 5-Minute Logic
If you switch your primary strategy interval to 1-Minute and then use a modulus check (%) in your Execute method, you can effectively recreate the 5-minute logic cadence.
This approach eliminates the need for the complex and error-prone AddSymbol call and the auxiliary _oneMinBars history. The bars object passed to Execute becomes your 1-minute data source.
I will update the Canvas to reflect this simplified and more robust approach.
Can you let me know the general rules, dataset, and time frame? accounting for slippage especially for illiquid markets is crucial.
I'm NMQ live. My current setup has the account live on 5min bars with IQFeed.
I have a total of 3 charts open.
One the left is a daily chart, in the center is the trading strategy with 5 min bars, and on the right is a 1min chart running the same strategy but sending signals to a dummy account.
In general, the daily bars overlap every day. If they don't then they tend to fill the gap eventually.
Additionally, viewing stats such as Open Above Previous Days Close and trade Down to Todays Close or Open Below Previous Days Close and trade Up to Todays Close can help with setups. The same can be extend for Low and High.
The idea is to scr[pe futures on a daily scale while understanding the daily trend and not holding over-night as even daily news can cause fast moves.
In general, the market on 1 minute scale is rather well behaved and controlling profit/loss by sizing the number of contracts will limit the daily risk as long as stops are kept in place.
The back test gives the following, but in real trading I don't get filled with auto-trading and have to use the buy/sell/short/cover buttons on the live chart and manually adjust on the Interactive Broker trading window. Once I do that, then I"m manually trading and the limit/stop algorithm will not reflect the correct entry. Also, sometimes the position size gets out of sync if there are partial trades.
I have a total of 3 charts open.
One the left is a daily chart, in the center is the trading strategy with 5 min bars, and on the right is a 1min chart running the same strategy but sending signals to a dummy account.
In general, the daily bars overlap every day. If they don't then they tend to fill the gap eventually.
Additionally, viewing stats such as Open Above Previous Days Close and trade Down to Todays Close or Open Below Previous Days Close and trade Up to Todays Close can help with setups. The same can be extend for Low and High.
The idea is to scr[pe futures on a daily scale while understanding the daily trend and not holding over-night as even daily news can cause fast moves.
In general, the market on 1 minute scale is rather well behaved and controlling profit/loss by sizing the number of contracts will limit the daily risk as long as stops are kept in place.
The back test gives the following, but in real trading I don't get filled with auto-trading and have to use the buy/sell/short/cover buttons on the live chart and manually adjust on the Interactive Broker trading window. Once I do that, then I"m manually trading and the limit/stop algorithm will not reflect the correct entry. Also, sometimes the position size gets out of sync if there are partial trades.
200% APR and you're not getting signals to AutoTrade?
The strategy is peeking (or it's overoptimized on the 60 or 70 days of data in that backtest).
The strategy is peeking (or it's overoptimized on the 60 or 70 days of data in that backtest).
I get signals, but the limit order updates every 5 min.
Anyway. I’ll build up some 5 min bars. I have code to do it. I thought maybe there is an easier way to do it.
I’ve used the Heiken Ashi bar generation before.
I’m going to try both a rolling average and a true 5 min.
Anyway. I’ll build up some 5 min bars. I have code to do it. I thought maybe there is an easier way to do it.
I’ve used the Heiken Ashi bar generation before.
I’m going to try both a rolling average and a true 5 min.
QUOTE:
The strategy is peeking (or it's over optimized on the 60 or 70 days of data in that backtest).
I agree. No strategy based strictly on historical behavior can predict the future that accurately. Not possible. Something is amiss.
Your Response
Post
Edit Post
Login is required