The request
Sometimes, we get requests like
this or
that where you ask to code an indicator that is built on intraday data but the strategy should be executed on daily data.
Although the request is somewhat backwards from the traditional way of mixing scales, it's still possible as the following solution by Robert Sucher illustrates:
The solution
Normally, as the WealthScript Programming Guide instructs to in
Multi-Time Frame Analysis, one starts with an intraday chart (the base time frame), create intraday and Daily indicators, and program it such that it trades EOD only. There are more possibilities in Version 6 for accessing data for the same symbol in different scales.
Below is an example of how to calculate and access a 30-min
StochD in a Daily chart. As can be seen, the key is to use a
GetExternalSymbol overload (
QuickRef for more: hit F11) that allows to specify the DataSet with
intraday data that will be searched when an external symbol is requested.
Code
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
protected override void Execute()
{
// Access the symbol from a DataSet whose base scale is intraday. Do not synch yet!
Bars intra30 = GetExternalSymbol("Dow 30_30", Bars.Symbol, false);
// Apply the indicator in the intraday scale
DataSeries sto_intra30 = StochD.Series(intra30, 15, 3);
// Synchronize to the chart scale (Daily)
sto_intra30 = Synchronize(sto_intra30);
// Plot the result.
// You'll see the last value of the day for the 30-minute indicator for each day
ChartPane stoPane = CreatePane(40, true, true);
PlotSeries(stoPane, sto_intra30, Color.Green, LineStyle.Solid, 2);
}
}
}