Nija

NIJA Apex Strategy v7.1

Overview

The NIJA Apex Strategy v7.1 is a sophisticated, high-probability trading strategy designed for professional-grade automated trading. It combines market filters, precise entry triggers, dynamic risk management, and intelligent exit logic to maximize profits while protecting capital.

Key Features

1. Market Filter

Only trades when market conditions are favorable:

2. High-Probability Entry Triggers

Long Entry (requires 4 out of 5 conditions):

  1. Price pulls back to EMA21 or VWAP (within 0.5%)
  2. RSI in bullish zone (40-70)
  3. Bullish reversal candle pattern
  4. MACD histogram uptick (growing)
  5. Volume confirmation (>50% average)

Short Entry (mirror of long):

  1. Price pulls back to EMA21 or VWAP (within 0.5%)
  2. RSI in bearish zone (30-60)
  3. Bearish reversal candle pattern
  4. MACD histogram downtick (shrinking)
  5. Volume confirmation (>50% average)

Entry Execution: Only on candle close (no mid-candle entries)

3. Dynamic Position Sizing

Position size adapts to trend strength (based on ADX):

Trend Quality ADX Range Position Size
Weak 20-25 2% of account
Good 25-30 5% of account
Strong 30-40 7% of account
Very Strong 40+ 10% of account

4. Stop Loss System

5. Multi-Stage Take Profit

Progressive profit-taking with trailing:

Stage Profit (R) Exit % Action
TP1 1R 33% Move stop to break-even
TP2 2R 33% Activate trailing stop
TP3 3R 34% Final exit or continue trailing

6. Trailing Stop System

7. Exit Logic

Positions close on:

8. Smart Filters

Trading blocked when:

9. AI Momentum Engine (Optional)

Architecture

Core Modules

bot/
├── apex_strategy_v7.py      # Main strategy implementation
├── apex_indicators.py        # Technical indicators (ADX, ATR, MACD, etc.)
├── apex_config.py           # Configuration parameters
├── apex_risk_manager.py     # Position sizing and risk management
├── apex_filters.py          # Smart filters
├── apex_trailing_system.py  # Trailing stop logic
├── apex_ai_engine.py        # Optional AI scoring
└── apex_backtest.py         # Backtesting engine

Broker Support

Implemented:

Placeholders:

Installation

Requirements

pip install pandas numpy
pip install coinbase-advanced-py  # For Coinbase
pip install alpaca-py            # For Alpaca (optional)

Environment Variables

For Coinbase (primary):

export COINBASE_API_KEY="your_api_key"
export COINBASE_API_SECRET="your_api_secret"
export COINBASE_PEM_CONTENT="your_base64_pem"

For Alpaca (optional):

export ALPACA_API_KEY="your_api_key"
export ALPACA_API_SECRET="your_api_secret"
export ALPACA_PAPER="true"  # true for paper trading

Usage

Basic Example

from apex_strategy_v7 import ApexStrategyV7
import pandas as pd

# Initialize strategy
strategy = ApexStrategyV7(account_balance=10000.0, enable_ai=False)

# Analyze entry opportunity
df = pd.DataFrame(...)  # Your OHLCV data
analysis = strategy.analyze_entry_opportunity(df, symbol="BTC-USD")

if analysis['should_enter']:
    print(f"Entry Signal: {analysis['side']}")
    print(f"Entry Price: ${analysis['entry_price']:.2f}")
    print(f"Stop Loss: ${analysis['stop_loss']:.2f}")
    print(f"Position Size: ${analysis['position_size_usd']:.2f}")
    print(f"Trend Quality: {analysis['trend_quality']}")

Backtesting

from apex_backtest import ApexBacktest
import pandas as pd

# Load historical data
df = pd.read_csv('historical_data.csv')  # OHLCV format

# Initialize backtest
backtest = ApexBacktest(initial_balance=10000.0, enable_ai=False)

# Run backtest
results = backtest.run_backtest(df, symbol="BTC-USD", commission=0.001)

# Print results
backtest.print_results(results)

Live Trading Integration

from apex_strategy_v7 import ApexStrategyV7
from broker_manager import BrokerManager, CoinbaseBroker

# Setup broker
broker_manager = BrokerManager()
coinbase = CoinbaseBroker()
coinbase.connect()
broker_manager.add_broker(coinbase)

# Get balance
balance = broker_manager.get_total_balance()

# Initialize strategy
strategy = ApexStrategyV7(account_balance=balance, enable_ai=False)

# Main trading loop
while True:
    for symbol in ['BTC-USD', 'ETH-USD', 'SOL-USD']:
        # Fetch candles
        candles = coinbase.get_candles(symbol, '5m', 100)
        df = pd.DataFrame(candles)

        # Analyze entry
        analysis = strategy.analyze_entry_opportunity(df, symbol)

        if analysis['should_enter']:
            # Place order
            broker_manager.place_order(
                symbol,
                analysis['side'],
                analysis['position_size_usd']
            )

    time.sleep(300)  # Wait 5 minutes

Configuration

All parameters can be customized in apex_config.py:

Market Filter

MARKET_FILTER = {
    'adx_threshold': 20,
    'volume_threshold': 0.5,
    # ...
}

Position Sizing

POSITION_SIZING = {
    'trend_quality': {
        'weak': {'position_size': 0.02},
        'strong': {'position_size': 0.07},
        # ...
    }
}

Risk Limits

RISK_LIMITS = {
    'max_daily_loss': 0.025,  # 2.5%
    'max_exposure': 0.30,     # 30%
    'max_positions': 5,
    # ...
}

Performance Expectations

Realistic Targets

Risk Factors

Backtest vs Live Trading

The strategy is designed to be modular for both:

Backtest Mode:

Live Mode:

Safety Features

  1. Risk Limits: Max exposure, daily loss, position count
  2. Smart Filters: Block trades in unfavorable conditions
  3. Stop Losses: Always set before entry
  4. Break-Even: After TP1, stop moves to entry price
  5. Trailing Stops: Protect profits as they grow

Disclaimer

⚠️ TRADING RISK WARNING

This strategy involves real financial risk. You can lose your entire account balance. This is not financial advice. Use at your own risk. Always:

License

MIT License - Free to use and modify

Support

For issues, questions, or contributions, please refer to the main NIJA repository documentation.

🚀 Production-Ready Trading System

NIJA Apex Strategy v7.1 is a unified, production-ready trading system designed for high-probability, multi-confirmation trade execution with aggressive capital protection.


✨ Key Features

1. Strict Market-State Filtering

Only trades in clean, strong trends with favorable conditions:

2. Multi-Confirmation Entry Logic

Requires 4 out of 6 confirmations for trade entry:

  1. ✅ VWAP alignment (price position)
  2. ✅ EMA alignment (trend structure)
  3. ✅ RSI favorable (30-70 range, not extreme)
  4. ✅ MACD histogram increasing/decreasing
  5. ✅ Volume confirmation (>1.5x average)
  6. ✅ Momentum candle OR pullback setup (VWAP/EMA21)

3. Dynamic ADX-Weighted Position Sizing

Position size adapts to trend strength:

Signal quality also affects size:

4. ATR-Based Stop-Loss with Buffer

5. Tiered Take-Profit System

6. Trailing Stop Post-TP1

7. Aggressive Capital Protection

8. Smart Filters

9. Extensible Architecture


📁 Module Structure

bot/
├── nija_apex_strategy.py      # Core strategy class
├── indicators_apex.py          # Enhanced indicators (ADX, ATR, MACD, momentum)
├── risk_management.py          # Position sizing, stops, take-profits
├── market_filters.py           # Chop detection, volume, news, timing filters
├── broker_integration.py       # Multi-broker adapter framework
├── ai_momentum.py              # AI momentum scoring (skeleton)
└── apex_config.py              # Configuration (no secrets!)

🔧 Configuration

All parameters are centralized in apex_config.py:

Market Filtering

MARKET_FILTERING = {
    'min_adx': 20,              # Minimum trend strength
    'min_volume_multiplier': 1.5,  # Min volume vs average
}

Entry Requirements

ENTRY_CONFIG = {
    'min_signal_score': 4,      # Min confirmations (out of 6)
    'require_ema_alignment': True,
    'require_vwap_alignment': True,
}

Risk Management

RISK_CONFIG = {
    'max_risk_per_trade': 0.02,  # 2% per trade
    'max_daily_loss': 0.025,     # 2.5% daily limit
    'max_total_exposure': 0.30,  # 30% max exposure
    'max_drawdown': 0.10,        # 10% max drawdown
}

Position Sizing

POSITION_SIZING = {
    'base_position_size': 0.03,  # 3% base
    'min_position_size': 0.01,   # 1% minimum
    'max_position_size': 0.10,   # 10% maximum
    'use_adx_weighting': True,
}

Stop-Loss & Take-Profit

STOP_LOSS_CONFIG = {
    'atr_stop_multiplier': 1.5,
    'min_stop_pct': 0.003,
}

TAKE_PROFIT_CONFIG = {
    'tp1': {'pct': 0.008, 'exit_size': 0.50},
    'tp2': {'pct': 0.015, 'exit_size': 0.30},
    'tp3': {'pct': 0.025, 'exit_size': 0.20},
}

🚦 Usage Example

from nija_apex_strategy import NijaApexStrategyV71
import pandas as pd

# Initialize strategy with account balance
strategy = NijaApexStrategyV71(account_balance=10000.0)

# Get market data (OHLCV DataFrame)
df = get_market_data('BTC-USD', timeframe='5m', limit=100)

# Check if we should enter a trade
should_enter, trade_plan = strategy.should_enter_trade(df)

if should_enter:
    print(f"✅ TRADE SIGNAL: {trade_plan['signal'].upper()}")
    print(f"   Score: {trade_plan['score']}/6")
    print(f"   Entry: ${trade_plan['entry_price']:.2f}")
    print(f"   Size: ${trade_plan['position_size_usd']:.2f} ({trade_plan['position_size_pct']*100:.1f}%)")
    print(f"   Stop: ${trade_plan['stop_loss']:.2f}")
    print(f"   TP1: ${trade_plan['take_profits']['tp1']['price']:.2f}")
    print(f"   TP2: ${trade_plan['take_profits']['tp2']['price']:.2f}")
    print(f"   TP3: ${trade_plan['take_profits']['tp3']['price']:.2f}")
else:
    print("❌ No trade signal")

🔐 Security Best Practices

✅ DO:

❌ DON’T:

Environment Variables Required:

COINBASE_API_KEY=your_api_key
COINBASE_API_SECRET=your_api_secret
COINBASE_PEM_CONTENT=your_base64_encoded_pem
LIVE_MODE=true  # Set to "false" for paper trading

# Optional for other brokers
BINANCE_API_KEY=your_binance_key
BINANCE_API_SECRET=your_binance_secret
ALPACA_API_KEY=your_alpaca_key
ALPACA_API_SECRET=your_alpaca_secret

🎯 Multi-Broker Support

The strategy supports multiple brokers through a unified interface:

Coinbase (Implemented)

from broker_integration import BrokerFactory

broker = BrokerFactory.create_broker('coinbase')
broker.connect()
balance = broker.get_account_balance()

Binance (Skeleton)

broker = BrokerFactory.create_broker('binance', testnet=True)
# TODO: Implement full Binance integration

Alpaca (Skeleton)

broker = BrokerFactory.create_broker('alpaca', paper=True)
# TODO: Implement full Alpaca integration

🤖 AI Momentum Scoring (Future)

Framework in place for ML integration:

from ai_momentum import MomentumScorer, AIRegimedDetector

# Market regime detection
regime_detector = AIRegimedDetector()
regime = regime_detector.detect_regime(df, adx, atr_pct)

# Momentum scoring (currently rule-based)
scorer = MomentumScorer(use_ml=False)
score = scorer.calculate_momentum_score(indicators, market_data)

Future capabilities:


📊 Performance Expectations

Realistic Targets

Risk Factors


🛠️ Development Roadmap

Completed ✅

In Progress 🚧

Future 🔮


📝 License

MIT License - Use freely, no warranty provided.


⚠️ Disclaimer

LIVE TRADING RISK: This bot executes REAL trades with REAL money. You can lose your entire account balance.

USE AT YOUR OWN RISK


🏆 NIJA Apex Philosophy

“Discipline, precision, and protection generate consistent profits.”

Core principles:

  1. Quality over Quantity: 4/6 confirmations ensure high-probability setups
  2. Risk-First Approach: Every trade has defined stop-loss and take-profit
  3. Let Winners Run: Trailing system captures extended moves
  4. Cut Losers Fast: ATR-based stops prevent small losses from becoming large
  5. Adapt to Conditions: Chop detection, regime adaptation, drawdown protection
  6. Systematic Execution: No emotions, no FOMO, no revenge trading

Version: 7.1 Last Updated: December 2024 Status: Production Ready (Coinbase), Placeholder (Binance) Last Updated: December 12, 2025 Status: Production-Ready Architecture