RightEdge Usage
Watchlists
RightEdge simulations are performed against watchlists. Watchlists can be created and managed in NDU or directly within RightEdge through the Watchlist Library.
Indicators, Dividends and Security Information
Making use of Historical Index Constituents
In the declaration area of the derived class of MySymbolScriptBase, add the following code:
// Define class for index constituents NorgateData.Integration.RightEdge.IndexConstituentTimeSeries indexConstituent;
In the Startup() method override, you need to instantiate the IndexConstituentTimeSeries indicator class as follows:
indexConstituent = new NorgateData.Integration.RightEdge.IndexConstituentTimeSeries("Russell 3000");
Either the index name (eg. "Russell 3000") or the index symbol ("$RUA") can be specified.
Details of the Historical Index Constituent coverage can be found in the Data Content
Tables.
In the NewBar method, you can check to see whether the stock was in the index on the current bar, by incorporating a very
simple condition into your buy signal:
&& indexConstituent.Current == 1
Determining when a US stock was listed on a major exchange
Some US stocks have had periods where they were not listed by a major exchange and only tradeable as OTC/Pink Sheet stocks.
In backtesting, you can elect to only trigger a trade if the stock was listed on a major exchange (NYSE, Nasdaq, NYSE American, NYSE Arca, Cboe BZX, IEX) on the signal date by using the class NorgateMajorExchangeListedTimeSeries as follows:
In the declaration area of the derived class of MySymbolScriptBase, add the following code:
// Define class for index constituents NorgateData.Integration.RightEdge.NorgateMajorExchangeListedTimeSeries majorExchangeListed;
In the Startup() method override, you need to instantiate the IndexConstituentTimeSeries indicator class as follows:
majorExchangeListed = new NorgateData.Integration.RightEdge.NorgateMajorExchangeListedTimeSeries();
In the NewBar method, you can check to see whether the stock was in the index on the current bar, by incorporating a very
simple condition into your buy signal:
&& majorExchangeListed.Current == 1
Referencing Distributions/Dividends
In your "Price & Volume Adjustment" settings, you can remove the effect of any distributions/dividends received by
adjusting the price and volume on a proportional basis. This methodology simulates re-investing the dividend on the day
prior to the ex-date and mirrors the methodology used in Total Return indices. To change this setting, click Tools >
Options > Data Store > Setup and select "Capital reconstructions, special distributions and ordinary cash dividends".
If you would prefer to track the dividends separately or use a different adjustment method, you can use the following Indicators -
In the declaration area of the derived class of MySymbolScriptBase, add the following code:
NorgateData.Integration.RightEdge.DividendTimeSeries dividends; NorgateData.Integration.RightEdge.PortfolioFunctions portfolioFunctions;
In the Startup() method override, you need to instantiate the DividendTimeSeries indicator class as follows:
dividends = new NorgateData.Integration.RightEdge.DividendTimeSeries(); portfolioFunctions = new NorgateData.Integration.RightEdge.PortfolioFunctions();
In the NewBar method, you can incorporate a dividend entitlement into your account with:
#region addDividendsToAccount portfolioFunctions.AddDividendToAccount(dividends.Current, SystemData, PositionManager, OpenPositions); #endregion
Your portfilio will be adjusted according to the dividend received. This will show as an Interest trade in your Trade
List:
To adjust your stops by the amount of the dividend entitlement, add the following code:
#region adjustTargetAndStopForDividend // If the price data is not adjusted for all types of dividends then you may want to adjust your price target/stop loss levels // to take into account any dividend received. // Note: This is unable to adjust Ratios (%) trailing profit targets/stops. If you use Ratios targets/stops // we suggest that you convert Ratios to a specific price target, and recalculate it each day, then use // these routines afterwards to adjust the stops. if (dividends.Current > 0) { foreach(Position pos in OpenPositions) { int direction; if (pos.Type == PositionType.Long) direction = 1; else direction = -1; // Adjust target price if set if (pos.ProfitTargetType == TargetPriceType.AbsolutePrice || pos.ProfitTargetType == TargetPriceType.RelativePrice) pos.SetProfitTargetPrice(pos.ProfitTarget - (direction*dividends.Current)); // Adjust stop loss price if set if (pos.StopLossType == TargetPriceType.AbsolutePrice || pos.StopLossType == TargetPriceType.RelativePrice) pos.SetStopLoss(pos.StopLoss - (direction*dividends.Current),pos.StopLossType); } } #endregion
Referencing Security Information
The following Symbol properties are built into RightEdge and automatically populated by the Norgate Data plugin, and can be queried within your code using:
Symbol.<property>
Property | C# Type | Description |
---|---|---|
AssetClass | AssetClass enum | Type of Security (Stock, Future, Index etc.) |
Exchange | String | The Exchange where the security trades |
Currency | Currency Enum | Currency used to quote the security |
ExpirationDate | DateTime | Final day of trading for an expired/delisted stock |
Sector | String | Level 1 (Economic Sector) for stocks |
Industry | String | Level 4 (Industry) for stocks |
ContractType | ContractType enum | For options, defines whether the contract is a call or a put |
TickSize | Double | The mininum tick increment for a futures contract |
TickValue | Double | The value of each tick in terms of the Profit/Loss that occurs when you trade one contract |
Margin | Double | For futures, the initial margin required to open a position of 1 contract. For spot FX, this is shown by default as a 2% leverage. |
ShortMargin | Double | Same as Margin |
For additional metadata for each security, add the following code to the declaration area of the derived class of MySymbolScriptBase, :
NorgateData.Integration.RightEdge.SecurityInfo norgateSecurityInfo;
Then, in the Startup method override, you need to instantiate the Security Information class as follows:
norgateSecurityInfo = new NorgateData.Integration.RightEdge.SecurityInfo();
The following Security Information methods are available for querying:
Method | C# Type | Description |
---|---|---|
SecondLastQuotedDate | DateTime | Second last bar of trading for any delisted/expired security For example usage see Note (1) |
BusinessSummary | String | Summary of the company's operations |
BusinessSummaryLastUpdate | String | Date when the Business Summary was last updated |
FinancialSummary | String | Summary of the company's most recent reported financials |
WebSite | String | Web site of company |
Domicile | String | Country of Domicile |
AssetId | Integer | Unique identifier of securities |
Classification | String | Returns the classification for the given classification scheme |
ClassificationAtLevel | String | Returns the classification and level for the given classification scheme |
ClassificationName | String | Returns the classification name for the given classification scheme |
ClassificationNameAtLevel | String | Returns the classification name and level for the given classification scheme |
ClassificationDescription | String | Returns the detailed description of the classification, given a classification scheme |
ClassificationDescriptionAtLevel | String | Returns the detailed description and level of the classification, given a classification scheme |
CurrentIndustryIndexSymbol | String | Returns the symbol for the industry index applicable to the given security For example usage see Note (2) |
Notes:
(1) To obtain the SecondLastQuotedDate, you would use the following:
DateTime slqd = norgateSecurityInfo.SecondLastQuotedDate(Symbol.Name);
Supported classification schemes include ThomsonReutersBusinessClassification, GICS, NorgateDataFuturesClassification and NorgateDataCashCommoditiesClassification.
(2) To retrieve the industry index symbol for the current security (for instance, to find other stocks with the same industry classification), you can use the CurrentIndustryIndexSymbol method as follows:
string indexsymbol = norgateSecurityInfo.CurrentIndustryIndexSymbol(Symbol.Name," < index family > ", < level > ,"< index type >");where:
- < index family > can be $SPX, $SP1500, $XJO or $XKO
- < level > is an integer from 1 to 4
- < indextype > is either PR (price return) or TR (total return)
string indexsymbol = norgateSecurityInfo.CurrentIndustryIndexSymbol(Symbol.Name,"$SP1500",4,"PR");If the current symbol has no applicable classification or there is no industry index present at the given level, then indexsymbol in the example above will be empty.
Referencing Fundamental Data
A method is provided in norgateSecurityInfo to query the most recently reported fundamental data.double? a = norgateSecurityInfo.Fundamentals(Symbol.Name,"<fundamentalfield>");
Further information on the fundamental fields are shown here.
Referencing the Original Unadjusted Close
If your trading system needs to reference the original unadjusted closing price of a security, you can use the following -
In the declaration area of the derived class of MySymbolScriptBase, add the following code:
NorgateData.Integration.RightEdge.OriginalCloseTimeSeries originalClose;
In the Startup() method override, you need to instantiate the DividendTimeSeries indicator class as follows:
originalClose = new NorgateData.Integration.RightEdge.OriginalCloseTimeSeries();
In the NewBar method, you can reference the original unadjusted close with:
originalClose.CurrentFor example, you could add a condition into your buy formula to only trade stocks that close above $2 with:
&& originalClose.Current > 2
Referencing the AUX1 Field
For stocks, the AUX1 field contains the Turnover (i.e. the total $ amount traded).
For continuous futures, the AUX1 field contains a number (format "YYYYMM") that indicates the underlying contract that was used for the prices on that date.
In the declaration area of the derived class of MySymbolScriptBase, add the following code:
NorgateData.Integration.RightEdge.Aux1TimeSeries aux1;In the Startup() method override, you need to instantiate the Aux1TimeSeries indicator class as follows:
aux1= new NorgateData.Integration.RightEdge.Aux1TimeSeries();In the NewBar method, you can reference aux1 with:
aux1.Current