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.


You must have ‘Developer Extensions’ checked when you ran the SharkIndicators Installer.

This example file is included in the ‘Developer Extensions’ and can be found in the ‘MyDocuments\NinjaTrader 8\bin\Custom\Strategies’ folder as ‘SiBloodHoundStrategExample.cs’. You can safely delete this file when you are done with it.

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.ComponentModel.DataAnnotations;
using NinjaTrader.Cbi;

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

        #region Properties
        [Display(Name = "Measurement Unit", GroupName = "Trade Management", Order = 0, 
            Description= "The unit of measurement for the Profit Target and Stop Loss")]
        public CalculationMode MeasurementUnit
            get { return _MeasurementUnit; }
            set { _MeasurementUnit = value; }
        [Display(Name = "Profit Target", GroupName = "Trade Management", Order =2, 
            Description = "The profit target measured in the units specified by Measurement Unit")]
        public double ProfitTarget
            get { return _ProfitTarget; }
            set { _ProfitTarget = value; }

        [Display(Name = "Stop Loss", GroupName = "Trade Management", Order = 3, 
            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 OnStateChange()
            base.OnStateChange(); // this is necessary to initialize the 
                                  // BloodHound Template

            if (State == State.Configure)
                // Trade Management
                SetProfitTarget(MeasurementUnit, ProfitTarget);
                SetStopLoss(MeasurementUnit, StopLoss);
                if (BloodHoundTemplate != null && !BloodHoundTemplate.IsEmpty)

        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
8 above.

Also note that if you override the OnStateChange() method, you must call thebase.OnStateChange(); method as shown on line 45.

Finally you can see that the entry code uses the BloodHound indicator on line 82 and 92. BloodHound is an accessible property from the SiBloodHoundStrategy class, and LongSignals and ShortSignals are Series<bool> representing signals computed from BloodHound.