NIJA Apex Strategy v7.1 is a unified algorithmic trading strategy designed for systematic market entry, risk management, and position management across multiple asset classes.
The strategy only allows trades when clear trend conditions are met:
Required Conditions (all must be true):
Example:
allow_trade, direction, reason = strategy.check_market_filter(df, indicators)
# Returns: (True, 'uptrend', 'Uptrend confirmed (ADX=32.5, Vol=120%)')
Entry occurs at candle close to confirm the pattern.
Example:
signal, score, reason = strategy.check_long_entry(df, indicators)
# Returns: (True, 4, 'Long score: 4/5 (pullback, rsi_pullback, candlestick, volume)')
Position size adjusts based on trend strength:
| ADX Range | Position Size | Trend Strength |
|---|---|---|
| < 20 | 0% (No trade) | Weak/No trend |
| 20-25 | 2% | Weak trending |
| 25-30 | 4% | Moderate trending |
| 30-40 | 6% | Strong trending |
| 40-50 | 8% | Very strong trending |
| > 50 | 10% | Extremely strong trending |
Signal strength (1-5 score) can further adjust by 80-100% multiplier.
Example:
position_size = risk_manager.calculate_position_size(
account_balance=10000,
adx=35.0,
signal_strength=4
)
# Returns: $600 (6% of $10,000 for ADX=35, score=4)
Stop loss = Swing low/high + ATR(14) * 0.5 buffer
This provides:
Example:
stop_loss = risk_manager.calculate_stop_loss(
entry_price=100.00,
side='long',
swing_level=98.50,
atr=1.20
)
# Returns: $97.90 (swing_low $98.50 - 0.5*ATR $0.60)
Trailing stop after TP1: ATR(14) * 1.5 from current price
Example: If entry = $100, stop = $98 (risk = $2):
Positions are exited when any of these conditions occur:
Example:
should_exit, reason = strategy.check_exit_conditions(symbol, df, indicators, current_price)
# Returns: (True, 'Trend break: EMA9 crossed below EMA21')
Three additional filters prevent bad trades:
Volume Filter - No trades if volume < 30% of average
Example:
allowed, reason = strategy.check_smart_filters(df, current_time)
# Returns: (False, 'Volume too low (25% of avg)')
Placeholder for future machine learning integration:
momentum_score = strategy.calculate_ai_momentum_score(df, indicators)
# Returns: 0.0-1.0 score (currently simple weighted average)
Future implementation ideas:
BaseBroker interfaceBaseBrokerconnect()get_account_balance()place_market_order()get_positions()get_candles()supports_asset_class()BrokerManagerExample:
from broker_manager import BaseBroker, BrokerType
class MyBroker(BaseBroker):
def __init__(self):
super().__init__(BrokerType.MY_BROKER)
def connect(self):
# Implementation
pass
# ... implement other methods
from nija_apex_strategy_v71 import NIJAApexStrategyV71
import pandas as pd
# Initialize strategy
strategy = NIJAApexStrategyV71(broker_client=None)
# Load market data
df = get_price_data() # Your data source
# Analyze market
analysis = strategy.analyze_market(
df=df,
symbol='BTC-USD',
account_balance=10000.0
)
# Check result
if analysis['action'] == 'enter_long':
print(f"Long entry at ${analysis['entry_price']}")
print(f"Position size: ${analysis['position_size']}")
print(f"Stop: ${analysis['stop_loss']}")
from broker_manager import CoinbaseBroker
from nija_apex_strategy_v71 import NIJAApexStrategyV71
# Initialize broker
broker = CoinbaseBroker()
broker.connect()
# Initialize strategy with broker
strategy = NIJAApexStrategyV71(broker_client=broker)
# Analyze and execute
analysis = strategy.analyze_market(df, 'BTC-USD', 10000.0)
success = strategy.execute_action(analysis, 'BTC-USD')
config = {
'min_adx': 25, # Require stronger trends
'volume_threshold': 0.7, # 70% volume requirement
'volume_min_threshold': 0.4, # 40% minimum
'candle_exclusion_seconds': 10, # Wait 10 seconds
'min_position_pct': 0.03, # 3% min position
'max_position_pct': 0.08, # 8% max position
'ai_momentum_enabled': True # Enable AI scoring
}
strategy = NIJAApexStrategyV71(broker_client=broker, config=config)
| Parameter | Default | Description |
|---|---|---|
min_adx |
20 | Minimum ADX for trade entry |
volume_threshold |
0.5 | Volume must be 50% of 5-candle avg |
volume_min_threshold |
0.3 | Absolute minimum volume (30% avg) |
candle_exclusion_seconds |
6 | Wait time after new candle |
news_buffer_minutes |
5 | Minutes before/after news to avoid |
min_position_pct |
0.02 | Minimum position size (2%) |
max_position_pct |
0.10 | Maximum position size (10%) |
ai_momentum_enabled |
False | Enable AI momentum scoring |
Run the example script:
python example_apex_v71.py
This demonstrates:
The v7.1 strategy can be integrated alongside existing NIJA strategies:
# In your main trading loop
from nija_apex_strategy_v71 import NIJAApexStrategyV71
# Initialize
apex_strategy = NIJAApexStrategyV71(broker_client=your_broker)
# In trading loop
for symbol in trading_pairs:
df = get_candles(symbol)
# Option 1: Use v7.1 exclusively
analysis = apex_strategy.analyze_market(df, symbol, balance)
apex_strategy.execute_action(analysis, symbol)
# Option 2: Use v7.1 as confirmation
# Run both old and new strategy, only trade on agreement
Win Rate: 45-55% (typical for trend-following) Risk/Reward: 1:2 to 1:3 average (via R-multiples) Max Drawdown: Depends on ADX filtering and position sizing Best Markets: Strongly trending markets (ADX > 30) Avoid: Choppy, low-volume, news-driven markets
For questions or issues:
Same as NIJA project (MIT License)
Version: 7.1 Last Updated: December 2025 Author: NIJA Trading Systems