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 SharkIndicators, 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 and costs.
  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.

-- I AGREE --

Build Your Own Customizable BloodHound Strategy or Indicator


Please note, SharkIndicators does not provide any NinjaScript, programming, or coding support.  This information is provided as-is and for knowledgeable programmers.

Overview


BloodHound's 'Developer Extensions' come with a base Strategy class of its own called 'SiBloodHoundStrategy' which is designed specifically for strategy developers who want to take advantage of BloodHound’s extreme speed and flexibility but require a custom solution for managing the trade once a position is taken.

Start by inheriting the SiBloodHoundStrategy class to create your strategy (instead of using the typical Strategy class). SiBloodHoundStrategy already works by using your BloodHound template’s active logic template as entry signals, but you can extend this class and augment the entry logic and most importantly incorporate trade management code to complete a full-blown robotic trading system.

SiBloodHoundStrategy defines an instance of the BloodHound indicator. While it is possible to have multiple instances of the BloodHound indicator included in one strategy, the best practice is to use only one instance per strategy. In the cases where you need multiple logic constructs to accomplish different tasks, simply use BloodHound’s logic template system. See the BloodHound Strategy Example 2 for information on how to do this.

To access the instance of the BloodHound indicator within SiBloodHoundStrategy, use the following property:

public SiBloodHound BloodHound { get;}

Dll References


If you attempt to compile your strategy and see a series of errors in the SharkIndicators.BloodHound.cs file depicting undefined classes you most likely need to add the proper DLL references to our software. To accomplish this, simply right click the NinjaScript Editor window and select "References...", click add and select the following Dll's:

  • SharkIndicators.Common.dll
  • SharkIndicators.BloodHound.dll

BloodHound Output


BloodHound exposes several methods to help you obtain signal and confidence value data. All outputs are computed for both the long and short side evaluations for each bar. For every logic template defined in the BloodHound template, BloodHound will compute:

  • Long Confidence Value
  • Short Confidence Value
  • Long Signal Value
  • Short Signal Value

The signal values are determined by taking the confidence values and applying the user settings: ConfidenceCompareRatio, LongThreshold and ShortThreshold from the logic template.

A valid signal for the long side is generated if the ratio between the long confidence and the short confidence is greater than the ConfidenceCompareRatio AND the long confidence is greater than the LongThreshold setting. The same holds true for the short side except that the ratio calculation is inverted and the short confidence is compared to the ShortThreshold instead.

BloodHound also defines a default output based on the active logic template, which is the currently selected logic template. The active logic template can be selected by:

  • interactively selecting the logic template in the Logic tab in the BloodHound template configuration dialog
  • selecting a logic template using the the drop down at top of a chart where BloodHound has been activated
  • programmatically setting the CurrentSelectedLogicID property on the BloodHound indicator instance to a known logic template ID

The default output is also expressed as a confidence value and a signal value (again for both the long and short evaluations). In the case when there is no active logic template, BloodHound will simply combine all the values from the confidence solvers using a Ratio logic node. The signal for the default output is determined by the settings defined by the BloodHound indicator properties: ConfidenceCompareRatio, LongThreshold and ShortThreshold.

Methods and Properties


The output methods provide means to extract data from each stage of the calculation made by BloodHound. List below are the 3 main calculations BloodHound performs when arriving at a final output:

  1. Raw confidence solver values
  2. Logic template confidence values
  3. Logic template signal values

In general you will most likely be using the (3) logic template signal values to use as your buy and sell signals. All of the methods below reference either a solver or logic template using a unique identifier key (ID number). Each solver and logic template is uniquely identified by this number and can be retrieved using various methods described below.

Raw Confidence Solver Values


The raw solver values will give you the output of a specified solver before any logic has been applied to it. These are the actual values used as inputs to your logic templates and fed into the logic nodes, and they range from 0 to 1.0. A value is generated for long side and for the short side for each solver.

Type Parameter Description
EMarketPosition direction Long or short evaluation
int iSolverID The confidence solver
int iBarsAgo How many bars ago
public double GetSolverValue(
                             MarketPosition direction,
                             int iSolverID,
                             int iBarsAgo);

Logic Template Confidence Values


The logic template confidence values are the final computed outputs after BloodHound has performed the logic calculation specified by the logic template. Raw solver values range from 0 to 1.0 for each of the long and short side.

Type Parameter Description
EMarketPosition direction Long or short evaluation
int iLogicTemplateID The logic template
int iBarsAgo How many bars ago
public double GetLogicConfidenceValue(
                                      MarketPosition direction,
                                      int iLogicTemplateID,
                                      int iBarsAgo);

Logic Template Signal Values


The logic template signal values are derived from the logic template confidence values and the ConfidenceCompareRatioLongThreshold and ShortThreshold settings of the logic template. Note: the logic template’s settings override these similar values set by the BloodHound indicator. A value of true for a particular direction means that that all the criteria has been met for a signal in that direction. Under certain settings, it is possible for both the long and short side to both have signals on the same bar.

Type Parameter Description
EMarketPosition direction Long or short evaluation
int iLogicTemplateID The logic template
int iBarsAgo How many bars ago
public bool GetLogicSignalValue(
                                MarketPosition direction,
                                int iLogicTemplateID,
                                int iBarsAgo);

Default Values


The default confidence and signal values are simply the active logic template confidence and signal values respectively. These values can be obtained by the properties outlined below.

Default Confidence Values

public Series<double> ConfidenceLong {get;}
public Series<double> ConfidenceShort {get;}

Default Signal Values

public Series<bool> LongSignals {get;}
public Series<bool> LongSignals {get;}

Default Values


Individual solvers and logic templates are each described by a unique ID key expressed as a positive integer (int). These can be obtained by explicitly iterating over the collections of these items or by allowing exposing public properties to allow your user to select them at run-time.

The SiBloodHound indicator contains an instance of type BloodHoundTemplate, which contains all data including the confidence solvers and logic templates. To iterate over the confidence solvers and logic templates use the following two collections respectively:

public class BloodHoundTemplate
{
    public ConfidenceSolverList Solvers {get;}
    public IEnumerable LogicTemplates {get;}
}

Both the ConfidenceSolver and LogicTemplate classes have a Name and Description property which will help you identify the instance you are interested in. Most importantly, however, is the ID property which is the number you pass to the above methods to reference the solver or logic template you are interested in.

public int ID {get; set;}
public string Name {get; set;}
public string Description {get; set;}

Logic Template as Strategy Property


Allowing your users to select the logic template using a public property in your strategy is the preferred method of retrieving a logic template ID. To do this, add a public integer (int) property to your strategy class and use the BloodHoundLogicDropDownSelectorTypeConverter.

[TypeConverter(typeof(BloodHoundLogicDropDownSelectorTypeConverter2))]
 public int MySelectedLogicTemplate
 {
      get;
      set;
 }

Example Code