Risk Disclosure

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View full risk disclosure.

BloodHound Simple Strategy Example 1

By using the information contained in the pages below, you understand and agree with the following terms:

  1. I AGREE that SharkIndicators does not warrant the functionality contained in the provided software code will meet your requirements or the operation of the software in conjunction with BloodHound will be uninterrupted or error-free
  2. I AGREE that using any of the information, including software code samples, are at my own risk. I shall defend, indemnify and hold SharkIndicator, its employees
    and associates harmless from any and all claims, damages, or losses resulting from its use.
  3. I AGREE that SharkIndicators is not under any obligation to provide support for the operation of any code derived from these examples and that I assume all associated risks of operation.
  4. I AGREE that in no event will SharkIndicators or its distributors be liable to you or others for any damages, including any lost profit, savings, lost patience or other incidental, or consequential damage.


This example illustrates the bare minimum BloodHound strategy implementation. It mimics the functionality already accomplished by the base class SiBloodHoundStrategy but overrides the  OnBarUpdate method which can be extended with your code.

Entry signals are taken when BloodHound has a signal in that direction. This is governed  by the active logic template.

Example Code

#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Strategy;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace NinjaTrader.Strategy
    public class SiBloodHoundStrategyExample : SiBloodHoundStrategy
        #region Fields
        private double _StopLoss;
        private double _ProfitTarget;
        private CalculationMode _MeasurementUnit;

        #region Properties
        [GridCategory("Trade Management")]
        [Gui.Design.DisplayName("Measurement Unit")]
        [Description("The unit of measurement for the Profit Target and Stop Loss")]
        public CalculationMode MeasurementUnit
            get { return _MeasurementUnit; }
            set { _MeasurementUnit = value; }

        [GridCategory("Trade Management")]
        [Gui.Design.DisplayName("Profit Target")]
        [Description("The profit target measured in the units specified by Measurement Unit")]
        public double ProfitTarget
            get { return _ProfitTarget; }
            set { _ProfitTarget = value; }

        [GridCategory("Trade Management")]
        [Gui.Design.DisplayName("Stop Loss")]
        [Description("The stop loss measured in the units specified by Measurement Unit")]
        public double StopLoss
            get { return _StopLoss; }
            set { _StopLoss = value; }

        #region Methods
        protected override void Initialize()
            base.Initialize(); // this is necessary to initialize the 
                               // BloodHound Template
            // Trade Management
            SetProfitTarget(MeasurementUnit, ProfitTarget);
            SetStopLoss(MeasurementUnit, StopLoss);

            // Add your Initialize code here

        protected override void OnStartUp()
            base.OnStartUp(); // this is necessary to startup the 
                              // BloodHound Template
            // Add your startup code below

        protected override void OnBarUpdate()
            // Do not call this because the base class' default 
            // implementation is to handle entry signals exactly 
            // like below - but we are overriding it to illustrate
            // how the code works.
            // base.OnBarUpdate();

             * EXAMPLE - this mimics the entries performed by the 
             * base class: SiBloodHoundStrategy you can now add 
             * additional program logic to the lines below if desired.

            // Ensure that we aren't long already
            if (Position.MarketPosition != MarketPosition.Long)
                // see if BloodHound has produced a long signal 
                // (on the selected logic template)
                if (BloodHound.LongSignals[0])
            // check to see if we aren't short already
            if (Position.MarketPosition != MarketPosition.Short)
                // see if BloodHound has produced a short signal 
                // (on the selected logic template)
                if (BloodHound.ShortSignals[0])



To begin with a BloodHound strategy, derive your Strategy class with SiBloodHoundStrategy instead of the usual Strategy class as illustrated in line 18above.

Also note that if you override the Initialize() or OnStartUp() methods, you must call thebase.Initialize(); and base.OnStartUp() respectively as shown on line 58 and 71.

Finally you can see that the entry code uses the BloodHound indicator on line 97 and 107. BloodHound is an accessible property from the SiBloodHoundStrategy class, and LongSignalsand ShortSignals are BoolSeries representing signals computed from BloodHound.

Example File

You must have ‘Developer Extensions’ checked when you ran the SharkIndicators Installer before you can import these strategies.

Download the raw .cs example code using the link below:
Download example code file (.cs)

Place it the following directory:

…/My Documents/NinjaTrader 7/bin/Custom/Strategy


Download the import file below and import it into NinjaTrader using File » Utilities » Import NinjaScript.
Download import file (.zip)