Hi everyone,
I’ve been working on a custom strategy using the Volume Area Breakout method in NinjaScript. The idea is to take trades only when price breaks out of the previous session’s Value Area High or Low (VAH/VAL), ideally confirmed with a volume surge or a strong directional candle.
However, the strategy is currently taking far too many trades, and many of them don’t align with what I’d consider a true breakout. It seems to be triggering on minor price movements rather than clean breaks of VAH or VAL.
What I’m trying to achieve:
- Buy when price breaks above the previous session’s VAH with conviction.
- Sell when price breaks below the previous session’s VAL.
I’ve checked that I’m calculating VAH/VAL using the VolumeProfile
indicator correctly, and I’m using High[0] > vah
or Low[0] < val
as basic triggers, but the execution seems off.
Has anyone run into similar issues or have suggestions on refining the breakout logic? Would love any insights or code snippets you’ve found effective.
Thanks in advance!
Are you using OnBarUpdate calculations of OnBarClose or something else? What else are you using for the logic? You say you want it to break with conviction. Where is the code for that part?
That portion depends on what you would view as conviction. Some wait for a candle close, depending on the timeframe. Some add volume on the candle in question.
It’s doing exactly what you tell it to do. Since your trigger is High[0] > vah
or Low[0] < val
then every time it goes over or under it’ll trigger. You’ll need to consider additional filtering based on your definition of conviction. If you want to get more fancy, you can create your own machine learning model and let it tell you the most important features you have for your strategy. For example, what I like to do is this. I have a strategy that have a bunch of calculations to produce some metrics I want. I run the strategy in the strategy analyzer for x amount of historical data. The strategy only does the calculations for each bar in that historical range, so it doesn’t actually enter trades. It saves every bar into a local SQLite database. I then can use those saved data in a machine learning model that I create and have it trained on the data itself. It then lets me know what were the top features it used to make it’s decision. This is an example. Now, I can use those features for the strategy itself or just rely on the trained model for decisions.
Top 10 features for strong trend:
Close_lag0: 5977.6006
TrendStrength_lag0: 2713.8914
ReturnOnVolatility_lag0: 2162.0530
IsHigherHigh_lag1: 1105.6960
LogReturnClose_lag0: 959.9912
AtrZScore_lag1: 257.2226
DeltaRocStd_lag2: 232.4423
CloseRocStd_lag6: 219.6402
MaxDelta_lag2: 205.5814
PocZScore_lag3: 195.5316
I just thought about your far too many trades comment. Initially, I thought that it was just entering normally every time it hit. So, maybe 10 within a few minutes. Then I thought more about it and maybe your far too many trades is entering 1000 times within a few minutes. If that’s the case, what you need to do is keep track of the entry bar. You need to put a guard in so that it doesn’t enter again within the same entry bar. You can use whatever guard you want, but I usually just keep track of the entry and exit bars and don’t allow re-entries within the both bars.