NinjaTrader 8 Expert Strategy v1.00

SevenBullishPatterns

A sophisticated pattern recognition strategy that identifies 7 powerful bullish candlestick formations with Darvas Box-based targets and dynamic risk management.

7 Patterns Trading Style
Multi-TF Timeframes
Moderate Risk Level
All Markets Instruments

Overview

What It Does

SevenBullishPatterns is a comprehensive pattern recognition strategy designed for NinjaTrader 8 that automatically identifies and trades seven of the most reliable bullish candlestick formations. The strategy combines classical technical analysis with modern Darvas Box theory to identify optimal entry points with calculated profit targets.

Each pattern is independently configurable with its own position size and risk ratio, allowing traders to customize their exposure based on pattern reliability and market conditions. The strategy supports concurrent positions (up to 50 entries per direction) and features both ATM Strategy integration for live trading and standard managed orders for backtesting.

  • Multi-pattern recognition with independent configuration
  • Darvas Box-based profit target calculation
  • Dynamic 1:2 or 1:3 risk-reward ratios per pattern
  • Disparity Index momentum confirmation
  • Visual pattern highlighting with custom colors

Key Highlights

[+]

Pattern Detection

Recognizes 7 distinct bullish candlestick patterns with precise algorithmic detection

[/]

Smart Targets

Uses Darvas Box upper levels as dynamic profit targets based on market structure

[*]

Flexible Risk

Choose between 1:2 or 1:3 risk-reward ratio per pattern for customized exposure

[o]

Visual Feedback

Real-time pattern highlighting with unique colors and momentum indicators

Methodology and Core Logic

[+]

Entry Strategy

Signal Generation

The strategy scans for seven distinct bullish candlestick patterns: Hammer, Inverted Hammer, Morning Star, Rising Three Methods, Stick Sandwich, Three White Soldiers, and Upside Tasuki Gap. Each pattern has specific criteria that must be met for signal generation.

Confirmation Methods

  • Darvas Box upper level validation for target placement
  • Disparity Index (14) cross above zero for momentum confirmation
  • Pattern length validation (1-5 bars depending on pattern)

Filtering Mechanism

Trades are only initiated when the calculated Darvas Box target is above the entry price, ensuring positive risk-reward ratios. Invalid targets (zero or negative distance) are automatically rejected.

[-]

Exit Strategy

Profit Taking

Take profit is automatically set at the Darvas Box upper level, which represents a structural resistance point identified by the Darvas indicator. This adapts to market conditions dynamically.

Loss Limitation

Stop loss is calculated as a fraction of the distance to target. With 1:2 risk ratio, stop is placed at 50% of the target distance below entry. With 1:3 ratio, stop is at 33% of target distance.

ATM Integration

In live trading, ATM Strategy templates allow manual modification of stop and target levels via mouse drag, providing flexibility for experienced traders.

[#]

Risk Management

Position Sizing

Each pattern has an independent order quantity parameter, allowing traders to allocate more capital to higher-probability patterns and less to experimental ones.

Risk Per Trade

The boolean risk parameter determines whether a pattern uses 1:2 (checked) or 1:3 (unchecked) risk-reward ratio, giving precise control over risk exposure per pattern type.

Concurrent Positions

Supports up to 50 concurrent entries per direction, allowing multiple pattern signals to be active simultaneously without conflict.

[*]

Advanced Features

Visual System

Comprehensive visual feedback includes pattern-specific bar coloring (retroactive for multi-bar patterns), text labels below bars, and momentum dots with vertical lines when Disparity Index crosses above zero.

Hybrid Execution

Automatically switches between ATM Strategy execution (live trading with manual modification capability) and standard managed orders (backtesting mode) based on current state.

Debug Logging

Extensive Print statements provide real-time logging of pattern detection, entry calculations, and order execution for troubleshooting and optimization.

Logic Flow Diagrams

Visual representation of the strategy's decision-making process

Complete Trading Logic Flow

This flowchart illustrates the entire decision-making process from strategy initialization through pattern detection, trade execution, and position management.

flowchart TD Start([Strategy Start]) --> Init{Initialize
Indicators?} Init -->|No| Error[Display Error
and Exit] Init -->|Yes| LoadIndicators[Load Darvas Box
Disparity Index
7 Pattern Indicators] LoadIndicators --> OnBarUpdate[OnBarUpdate
Event] OnBarUpdate --> CheckBar{CurrentBar >
20?} CheckBar -->|No| Wait[Wait for
More Data] Wait --> OnBarUpdate CheckBar -->|Yes| ResetCounter[Reset Pattern
Counter] ResetCounter --> CheckDisparity{Disparity Index
Cross Above 0?} CheckDisparity -->|Yes| DrawMomentum[Draw Green Dot
Vertical Line
Bullish Momentum Text] CheckDisparity -->|No| ScanPatterns[Scan All 7
Patterns] DrawMomentum --> ScanPatterns ScanPatterns --> CheckHammer{Hammer
Detected?} CheckHammer -->|Yes| ExecuteHammer[Execute Hammer
Trade Logic] CheckHammer -->|No| CheckInverted{Inverted Hammer
Detected?} ExecuteHammer --> IncrementCount[Increment Pattern
Counter] IncrementCount --> CheckInverted CheckInverted -->|Yes| ExecuteInverted[Execute Inverted Hammer
Trade Logic] CheckInverted -->|No| CheckMorning{Morning Star
Detected?} ExecuteInverted --> IncrementCount2[Increment Counter] IncrementCount2 --> CheckMorning CheckMorning -->|Yes| ExecuteMorning[Execute Morning Star
Trade Logic] CheckMorning -->|No| CheckRising{Rising Threes
Detected?} ExecuteMorning --> IncrementCount3[Increment Counter] IncrementCount3 --> CheckRising CheckRising -->|Yes| ExecuteRising[Execute Rising Threes
Trade Logic] CheckRising -->|No| CheckStick{Stick Sandwich
Detected?} ExecuteRising --> IncrementCount4[Increment Counter] IncrementCount4 --> CheckStick CheckStick -->|Yes| ExecuteStick[Execute Stick Sandwich
Trade Logic] CheckStick -->|No| CheckSoldiers{3 White Soldiers
Detected?} ExecuteStick --> IncrementCount5[Increment Counter] IncrementCount5 --> CheckSoldiers CheckSoldiers -->|Yes| ExecuteSoldiers[Execute 3 White Soldiers
Trade Logic] CheckSoldiers -->|No| CheckTasuki{Upside Tasuki
Detected?} ExecuteSoldiers --> IncrementCount6[Increment Counter] IncrementCount6 --> CheckTasuki CheckTasuki -->|Yes| ExecuteTasuki[Execute Upside Tasuki
Trade Logic] CheckTasuki -->|No| WaitNextBar[Wait for
Next Bar] ExecuteTasuki --> IncrementCount7[Increment Counter] IncrementCount7 --> WaitNextBar WaitNextBar --> OnBarUpdate style Start fill:#00d4ff,stroke:#00d4ff,stroke-width:3px,color:#000 style LoadIndicators fill:#7b2cbf,stroke:#7b2cbf,stroke-width:2px,color:#fff style Error fill:#ff0055,stroke:#ff0055,stroke-width:2px,color:#fff style ExecuteHammer fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style ExecuteInverted fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style ExecuteMorning fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style ExecuteRising fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style ExecuteStick fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style ExecuteSoldiers fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style ExecuteTasuki fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000

Pattern Detection and Execution Flow

Detailed breakdown of how each pattern is detected, validated, and executed.

flowchart TD Start([Pattern Signal
Detected]) --> Increment[Increment Pattern
Counter] Increment --> ColorBars[Apply Retroactive
Bar Coloring] ColorBars --> DrawLabel[Draw Pattern
Name Label] DrawLabel --> LogPattern[Log Pattern
to Output] LogPattern --> GetEntry[Get Entry Price
= Close 0] GetEntry --> GetDarvas[Get Darvas Box
Upper Level] GetDarvas --> CalcDistance[Calculate Distance
= Upper - Entry] CalcDistance --> ValidateDistance{Distance >
0?} ValidateDistance -->|No| Reject[Skip Trade
Invalid Target] ValidateDistance -->|Yes| CheckRisk{Risk Parameter
Checked?} CheckRisk -->|Yes| Calc12[Calculate Stop Loss
Entry - Distance/2] CheckRisk -->|No| Calc13[Calculate Stop Loss
Entry - Distance/3] Calc12 --> CheckState{State ==
Realtime?} Calc13 --> CheckState CheckState -->|Yes| CreateATM[Create ATM Strategy
Order Market Buy] CheckState -->|No| SetManaged[Set Stop Loss
Set Profit Target
Enter Long] CreateATM --> CheckATMError{ATM
Error?} CheckATMError -->|Yes| LogError[Log Error
Message] CheckATMError -->|No| TradeActive[Trade Active
ATM Template] SetManaged --> BacktestTrade[Backtest Trade
Active] LogError --> End([End]) TradeActive --> End BacktestTrade --> End Reject --> End style Start fill:#00d4ff,stroke:#00d4ff,stroke-width:2px,color:#000 style CreateATM fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style SetManaged fill:#7b2cbf,stroke:#7b2cbf,stroke-width:2px,color:#fff style TradeActive fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style BacktestTrade fill:#7b2cbf,stroke:#7b2cbf,stroke-width:2px,color:#fff style Reject fill:#ff0055,stroke:#ff0055,stroke-width:2px,color:#fff style End fill:#00d4ff,stroke:#00d4ff,stroke-width:2px,color:#000

Risk Management and Position Sizing

How the strategy calculates risk parameters and manages position sizing for each pattern.

flowchart LR Start([Pattern
Detected]) --> GetParams[Get Pattern
Parameters] GetParams --> ReadQty[Read OrderQty
Parameter] ReadQty --> ReadRisk[Read Risk
Boolean] ReadRisk --> CalcTarget[Calculate Target
= Darvas Upper] CalcTarget --> CalcEntry[Get Entry
= Close 0] CalcEntry --> CalcDist[Distance =
Target - Entry] CalcDist --> CheckDist{Distance
Valid?} CheckDist -->|No| Reject[Reject Trade] CheckDist -->|Yes| RiskDecision{Risk =
True?} RiskDecision -->|1:2 Ratio| CalcStop12[Stop = Entry
- Distance/2] RiskDecision -->|1:3 Ratio| CalcStop13[Stop = Entry
- Distance/3] CalcStop12 --> ValidateStop{Stop >
0?} CalcStop13 --> ValidateStop ValidateStop -->|No| Reject ValidateStop -->|Yes| SetOrders[Set SL and TP
Orders] SetOrders --> Execute[Execute Trade
with Qty] Execute --> Monitor[Monitor Position
Until Exit] Monitor --> ExitType{Exit
Type} ExitType -->|Stop Loss| Loss[Close at
Stop Loss] ExitType -->|Take Profit| Profit[Close at
Take Profit] Loss --> End([Position
Closed]) Profit --> End Reject --> End style Start fill:#00d4ff,stroke:#00d4ff,stroke-width:2px,color:#000 style Execute fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style Profit fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style Loss fill:#ff0055,stroke:#ff0055,stroke-width:2px,color:#fff style Reject fill:#ffaa00,stroke:#ffaa00,stroke-width:2px,color:#000 style End fill:#7b2cbf,stroke:#7b2cbf,stroke-width:2px,color:#fff

Visual System Architecture

Overview of the visual feedback system and how indicators interact with chart elements.

graph TB subgraph "Data Sources" Price[Price Data
OHLC] Darvas[Darvas Box
Indicator] Disparity[Disparity Index
14 Period] Patterns[7 Candlestick
Patterns] end subgraph "Signal Processing" Processor[Pattern
Processor] Validator[Target
Validator] Calculator[Risk
Calculator] end subgraph "Visual Output" Momentum[Momentum Visuals
Green Dot + Line + Text] Bars[Bar Coloring
Retroactive] Labels[Pattern Labels
Below Bars] Chart[Chart Display] end subgraph "Order Execution" ATM[ATM Strategy
Realtime] Managed[Managed Orders
Backtest] end Price --> Processor Darvas --> Validator Disparity --> Momentum Patterns --> Processor Processor --> Validator Validator --> Calculator Calculator --> ATM Calculator --> Managed Processor --> Bars Processor --> Labels Momentum --> Chart Bars --> Chart Labels --> Chart style Processor fill:#00d4ff,stroke:#00d4ff,stroke-width:2px,color:#000 style Validator fill:#7b2cbf,stroke:#7b2cbf,stroke-width:2px,color:#fff style Calculator fill:#ffaa00,stroke:#ffaa00,stroke-width:2px,color:#000 style ATM fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style Managed fill:#7b2cbf,stroke:#7b2cbf,stroke-width:2px,color:#fff style Chart fill:#0a0e27,stroke:#00d4ff,stroke-width:2px,color:#fff

Key Features and Capabilities

[*]

Seven Pattern Recognition

Detects Hammer, Inverted Hammer, Morning Star, Rising Three Methods, Stick Sandwich, Three White Soldiers, and Upside Tasuki Gap patterns.

  • Pattern-specific sensitivity (4-bar lookback)
  • Independent configuration per pattern
  • Unique color coding for each type
[+]

Darvas Box Targets

Uses the Darvas Box indicator to determine dynamic profit targets based on market structure and resistance levels.

  • Automatic target calculation
  • Structure-based exits
  • Adapts to market volatility
[/]

Flexible Risk Ratios

Choose between 1:2 or 1:3 risk-reward ratio for each pattern independently, allowing customized risk management.

  • 1:2 ratio: Stop = Distance/2
  • 1:3 ratio: Stop = Distance/3
  • Per-pattern customization
[o]

Disparity Index Momentum

Integrates Disparity Index (14) to identify momentum shifts with visual confirmation when crossing above zero.

  • Green dot below bar
  • Dodger blue vertical line
  • Bullish momentum text label
[#]

Concurrent Position Support

Supports up to 50 concurrent entries per direction, enabling multiple pattern signals to be active simultaneously.

  • EntriesPerDirection = 50
  • AllEntries handling mode
  • Independent signal tracking
[%]

ATM Strategy Integration

Live trading uses ATM Strategy templates allowing manual modification of stop and target levels via mouse drag.

  • Draggable SL/TP lines
  • Template-based execution
  • Real-time adjustment
[!]

Visual Pattern Highlighting

Comprehensive visual feedback with retroactive bar coloring for multi-bar patterns and unique colors per pattern type.

  • Gold: Hammer
  • Magenta: Morning Star
  • Spring Green: 3 White Soldiers
[?]

Hybrid Execution Mode

Automatically switches between ATM Strategy (live) and managed orders (backtest) based on current trading state.

  • Realtime: ATM Strategy
  • Backtest: SetStopLoss/SetProfitTarget
  • Automatic detection
[=]

Debug Logging System

Extensive logging for troubleshooting and optimization with pattern detection and order execution details.

  • Pattern detection timestamps
  • Entry/Stop/Target values
  • Error message tracking

Input Parameters and Configuration

Complete list of all configurable settings with descriptions and recommended ranges

Parameter Name Type Default Range Description Category
HammerPatternsOrderQty int 1 1 - 10000 Position size (contracts/shares) for Hammer pattern trades. Trading
HammerPatternsRisk bool true true / false If checked: 1:2 risk-reward ratio. If unchecked: 1:3 ratio. Risk
InvertedHammerPatternsOrderQty int 1 1 - 10000 Position size for Inverted Hammer pattern trades. Trading
InvertedHammerPatternsRisk bool true true / false Risk-reward ratio toggle for Inverted Hammer pattern. Risk
MorningStarPatternsOrderQty int 1 1 - 10000 Position size for Morning Star pattern trades. Trading
MorningStarPatternsRisk bool true true / false Risk-reward ratio toggle for Morning Star pattern. Risk
RisingThreesOrderQty int 1 1 - 10000 Position size for Rising Three Methods pattern trades. Trading
RisingThreesOrderRisk bool true true / false Risk-reward ratio toggle for Rising Three Methods pattern. Risk
StickSandwichPatternsOrderQty int 1 1 - 10000 Position size for Stick Sandwich pattern trades. Trading
StickSandwichPatternsRisk bool true true / false Risk-reward ratio toggle for Stick Sandwich pattern. Risk
ThreeWhiteSoldiersPatternsOrderQty int 1 1 - 10000 Position size for Three White Soldiers pattern trades. Trading
ThreeWhiteSoldiersPatternsRisk bool true true / false Risk-reward ratio toggle for Three White Soldiers pattern. Risk
UpsideTasukiGapOrderQty int 1 1 - 10000 Position size for Upside Tasuki Gap pattern trades. Trading
UpsideTasukiGapOrderRisk bool true true / false Risk-reward ratio toggle for Upside Tasuki Gap pattern. Risk

Performance Analytics

Comprehensive backtesting and live trading results

[*]

Performance Data Placeholder

Strategy performance metrics will be added here in tabulated form

Suggested Metrics to Include:

  • Overall Performance: Total Trades, Winning Trades, Losing Trades, Win Rate per Pattern
  • Profitability: Net Profit, Gross Profit, Gross Loss, Profit Factor
  • Risk Metrics: Max Drawdown, Max Drawdown %, Recovery Factor
  • Trade Analysis: Average Win, Average Loss, Largest Win, Largest Loss
  • Pattern Breakdown: Performance statistics by individual pattern type
  • Timeframe Data: Results by session, day of week, and market conditions

Usage and Implementation Guide

1

Installation

File Placement

Copy the strategy file to your NinjaTrader installation:

Documents\NinjaTrader 8\bin\Strategies\SevenBullishPatterns.cs

Compilation

  1. Open NinjaTrader 8
  2. Press F4 to open NinjaScript Editor
  3. Locate the strategy file in the Solutions Explorer
  4. Right-click and select "Compile" or press F5
  5. Check for errors in the Output window
2

Chart Setup

Attach to Chart

  1. Open a chart for your desired instrument
  2. Set the appropriate timeframe (H1 or H4 recommended)
  3. Right-click the chart and select "Strategies"
  4. Select "SevenBullishPatterns" from the list
  5. Click "New" to add a new instance

Enable Strategy

Click the "Enable Strategy" button in the Strategies panel. The strategy will begin scanning for patterns immediately.

3

Parameter Configuration

Recommended Settings

Parameter Conservative Moderate Aggressive
OrderQty 1 contract 2-3 contracts 5+ contracts
Risk (all patterns) false (1:3 ratio) false (1:3 ratio) true (1:2 ratio)

Pattern-Specific Tips

  • Three White Soldiers: Higher reliability, consider larger position size
  • Morning Star: Strong reversal signal, good for trending markets
  • Hammer/Inverted Hammer: Single-bar patterns, more frequent signals
4

ATM Strategy Template

Creating ATM Template

  1. Open ATM Strategy panel from the Control Center
  2. Create a new template named "AtmStrategyTemplate"
  3. Set default stop loss and profit target values
  4. Save the template

Important Notes

  • ATM Strategy templates allow manual modification of SL/TP via mouse drag
  • Backtesting uses managed orders automatically
  • The template name must match exactly: "AtmStrategyTemplate"
  • Without ATM template, live trades will still execute with calculated levels
5

Live Trading Checklist

Pre-Launch Verification

  • Strategy tested on demo account for minimum 2 weeks
  • ATM Strategy template configured and tested
  • Order quantities appropriate for account size
  • Risk ratios set according to risk tolerance
  • Stable internet connection or VPS configured
  • NinjaTrader auto-logon enabled if using VPS

Monitoring Requirements

  • Daily: Check Output window for pattern detection logs
  • Daily: Verify strategy is still enabled and running
  • Weekly: Review trade performance by pattern type
  • Monthly: Analyze win rate per pattern and adjust settings

Technical Specifications

Platform Requirements

Platform NinjaTrader 8
Language C# / NinjaScript
Type Strategy
Calculation Mode OnBarClose

Trading Specifications

Timeframes All timeframes supported
Recommended TF H1, H4, Daily
Instruments All NinjaTrader instruments
Max Concurrent 50 per direction

Indicators Used

Darvas Box Target calculation
Disparity Index 14 period, momentum
Candlestick Pattern 7 patterns, 4-bar lookback
Bars Required 20 minimum

Order Settings

Entry Handling AllEntries
Time in Force GTC (Good Till Cancel)
Exit on Session 30 seconds delay
Start Behavior WaitUntilFlat

Features Checklist

Compatibility

[+]

Live Trading

Full ATM Strategy integration with manual modification support

[+]

Backtesting

Standard managed orders for Strategy Analyzer compatibility

[+]

Multi-Instrument

Works with futures, forex, stocks, and crypto instruments

[!]

VPS Recommended

For 24/7 operation, VPS hosting is recommended

[!]

IMPORTANT RISK DISCLOSURE

Trading involves substantial risk of loss and may not be suitable for all investors.

Trading foreign exchange, stocks, futures, options, and cryptocurrencies on margin carries a high level of risk and may not be suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to trade, you should carefully consider your investment objectives, level of experience, and risk appetite. There is a possibility that you could sustain a loss of some or all of your initial investment.

About This Trading Strategy

This Strategy is a software tool designed to assist in analyzing market conditions and executing trades based on predefined algorithms. It does not guarantee profits or success. Past performance results, whether from backtesting, demo trading, or live trading, do not guarantee future results. Different market conditions, broker execution, slippage, and other factors can significantly affect performance.

User Responsibility

You are fully responsible for all trading decisions made using this Strategy, including:

  • Parameter configuration and optimization
  • Risk management and position sizing
  • Monitoring and maintaining the strategy
  • Understanding the trading logic and risks involved
  • Ensuring compatibility with your broker and account type

No Warranties

KeyAlgos provides this Strategy "as is" without any warranties, express or implied. We do not guarantee that the strategy will be error-free, uninterrupted, or that it will meet your requirements.

Get in Touch

Have questions about SevenBullishPatterns or interested in custom NinjaTrader development? KeyAlgos provides professional algorithmic trading solutions tailored to your specific needs.

Services Offered

  • Custom NinjaTrader Strategy Development
  • Pattern Recognition Systems
  • Risk Management Solutions
  • Strategy Optimization Services
  • Backtesting and Analysis
  • Indicator Development