Extension Signals and Sinks
Extension objects can register interest in certain
alerts and other events that may be generated by a chart (or portfolio) that are not directly related to an Equilla script evaluation. These
signals are broken down into four main categories that can be independently hooked by the extension object: Equilla script alerts, tool alerts, strategy events and instrument events.
To register interest in a specific class of signals, the extension object must implements a
Sink interface of the corresponding type:
interface IScriptSignal
{
void ScriptSignalRaised( IScriptSignal Signal, bool MoreToFollow );
}
interface IStrategySignalSink
{
void StrategySignalRaised( IStrategySignal Signal, bool MoreToFollow );
}
interface IToolSignalSink
{
void ToolSignalRaised( IToolSignal Signal, bool MoreToFollow );
}
In each of the above cases, the implemented method will be called when a signal is raised, containing an interface to an object the contains details of that signal (see below), the
MoreToFollow flag will indicate if more signals are pending, so that the signals may be queued and processed in a batch when
MoreToFollow is set to
false (this is of special importance with strategy orders).
interface ISymbolStateChangedSink
{
SymbolStateChanged( string Symbol, string DisplayName, bool Active );
}
Implementation of the
ISymbolStateChangedSink allows an extension object to respond when instruments transition from an active to an inactive state (inactive can mean the instrument is stale, or that the data connection has been lost).
IScriptSignal
Contains details about an Equilla alert that has occurred as the result of calling the Equilla
Alert() function, or clicking on a chart hyperlink generated by
DrawText() using the
signal protocol.
Please refer to the sample project
RSSExtension and the corresponding indicator
RSS for how to hook and generate script alerts.
interface IScriptSignal
{
string SourcePath { get; }
string DisplaySource { get; }
string ScriptName { get; }
string SignalName { get; }
string AlertText { get; }
string ParentSymbolName { get; }
DateTime BarTimestamp { get; }
double BarPrice { get; }
DateTime TimestampUTC { get; }
string ParentDisplayName { get; }
}
A simple way to generate an alert would be to use the following Equilla code:
If IsLastBar Then
Alert( "It is the last bar: " + CStr( CurrentBar ) );
To generate script alerts from a user clicking on a hyperlink in the chart, do the following:
If IsLastBar Then
DrawText( High, "LinkTest", "Click 4 Alert", Default, Default, AlignTop,
"signal:It is the last bar: " + CStr( CurrentBar ) );
IStrategySignal
Contains details about a strategy event that has occurred. Strategy events are generated when a chart is running Equilla strategies that use the Buy, Sell, Short, Cover and ExitPosition functions to build and backtest a trading system.
Please refer to the sample project
ExcelOrderTracker and the corresponding indicator
OrderTracker for how to hook generated strategy alerts.
interface IStrategySignal
{
EStrategySignalType SignalType { get; }
string SourcePath { get; }
string DisplaySource { get; }
string ScriptName { get; }
string SignalName { get; }
string OrderId { get; }
EStrategySignalOrderType OrderType { get; }
double OrderPrice { get; }
double OrderQuantity { get; }
string ParentSymbolName { get; }
DateTime BarTimestamp { get; }
double BarPrice { get; }
DateTime TimestampUTC { get; }
string RelatedOrders { get; }
string ParentDisplayName { get; }
}
enum EStrategySignalType
{
eqSignalTypeLongEntryPlaced,
eqSignalTypeLongExitPlaced,
eqSignalTypeShortEntryPlaced,
eqSignalTypeShortExitPlaced,
eqSignalTypeOrderCancelled,
eqSignalTypeOrderFilled,
eqSignalTypeOrderModified,
eqSignalTypeOrderModifiedTrailing,
}
enum EStrategySignalOrderType
{
eqSignalTypeMarketLongEntry,
eqSignalTypeMarketLongExit,
eqSignalTypeMarketShortEntry,
eqSignalTypeMarketShortExit,
eqSignalTypeStopLongEntry,
eqSignalTypeStopLongExit,
eqSignalTypeStopShortEntry,
eqSignalTypeStopShortExit,
eqSignalTypeLimitLongEntry,
eqSignalTypeLimitLongExit,
eqSignalTypeLimitShortEntry,
eqSignalTypeLimitShortExit
}
Contains details about a tool alert that has occurred.
interface IToolSignal
{
EToolSignalType SignalType { get; }
string SourcePath { get; }
string DisplaySource { get; }
string ScriptName { get; }
string SignalName { get; }
string ParentSymbolName { get; }
DateTime BarTimestamp { get; }
double BarPrice { get; }
EToolSignalToolType ToolType { get; }
EToolSignalLine Line { get; }
EToolSignalPriceDirection PriceDirection { get; }
string ToolText { get; }
DateTime TimestampUTC { get; }
string ParentDisplayName { get; }
}
enum EToolSignalType
{
eqSignalTypeCrossed,
eqSignalTypeBreakIn,
eqSignalTypeBreakOut,
}
enum EToolSignalLine
{
eqToolLine,
eqToolUpperLine,
eqToolMiddleLine,
eqToolLowerLine,
eqToolLineChannel,
eqToolLineFibo1,
eqToolLineFibo2,
eqToolLineFibo3,
eqToolLineFibo4,
eqToolLineFibo5,
eqToolLineFibo6,
eqToolLineFibo7,
eqToolLineFibo8,
eqToolLineFibo9,
eqToolLineFibo10,
eqToolLineFibo11,
eqToolLineFibo12,
eqToolLineFibo13,
eqToolLineFibo14,
eqToolLineFibo15,
eqToolLineFibo16,
};
enum EToolSignalToolType
{
eqToolTypeTrendLine,
eqToolTypeFiboRetracement,
eqToolTypeStopLine,
eqToolTypeTrendChannel,
eqToolTypePitchfork,
eqToolTypeRegressionChannel,
};
enum EToolSignalPriceDirection
{
eqDirectionUpwards,
eqDirectionDownwards,
eqDirectionSideways,
};