- ago
I'm trying to get data for the same instrument on a larger scale.

For example: I need to look at the indicator values on a scale of 1 minute and 1 hour.

The code I'm trying gives "Not a number".

CODE:
BarHistory qqq = new BarHistory(bars.Symbol,HistoryScale.Minute10);          WriteToDebugLog(qqq.Close[5]);
0
475
Solved
3 Replies

Reply

Bookmark

Sort
Cone8
 ( 28.32% )
- ago
#1
You created a "new BarHistory" but didn't assign anything to it.

See the QuickRef examples for the Classes:
- BarHistoryCompressor
- BarHistorySynchronize
- TimeSeriesCompressor
- TimeSeriesSynchronize

Also, if you're really looking for a "different instrument" (not just the scale), see GetHistory() method in the UserStrategyBase class.
0
- ago
#2
I can't create an indicator using this technology. In strategy, this technology works. I've also noticed that when I make some kind of error while creating the indicators, no obvious compilation error is output. However, it is not possible to compile. My goal is to create an indicator that would show the value of the EMA on a larger time frame.

Please explain to me how to write this indicator and tell me how I can understand (except in practice) which technologies work in indicators and which only in strategies, since this is not the first time I have encountered a difference in the availability of functionality in indicators and strategies.

A more general idea is to write an indicator that could show the values ​​of any other indicators on a different time scale. And so that it can be used in the strategy builder.


CODE:
using WealthLab.Core; using System; using System.Drawing; using WealthLab.Indicators; namespace WealthLab.MyIndicators { public class Ema_greater_scale : IndicatorBase { //parameterless constructor public Ema_greater_scale() : base() { } //for code based construction public Ema_greater_scale(BarHistory source, Int32 compressionperiod, Int32 emaperiod) : base() {          Parameters[0].Value = source;          Parameters[1].Value = compressionperiod;          Parameters[2].Value = emaperiod; Populate(); }       //static Series method       public static Ema_greater_scale Series(BarHistory source, Int32 compressionperiod, Int32 emaperiod)       {          return new Ema_greater_scale(source, compressionperiod, emaperiod);       } //name public override string Name { get { return "EMA_Greater_Scale"; } } //abbreviation public override string Abbreviation { get { return "Ema_greater_scale"; } } //description public override string HelpDescription { get { return ""; } } //price pane public override string PaneTag { get { return "Greater_Scale_Pane"; } }       //default color       public override WLColor DefaultColor       {          get          {             return WLColor.FromArgb(255,0,0,255);          }       }       //default plot style       public override PlotStyle DefaultPlotStyle       {          get          {             return PlotStyle.Line;          }       } //populate public override void Populate() {          BarHistory source = Parameters[0].AsBarHistory;          Int32 compressionperiod = Parameters[1].AsInt;          Int32 period=Parameters[2].AsInt;          TimeSeries EMACompressedBars;                   //Compress to ...-hour bars          BarHistory CompressedBars = BarHistoryCompressor.ToHour(source, compressionperiod);          //Get a RSI(14) of the ...-hour low series          EMACompressedBars = EMA.Series(CompressedBars.Close, 14);          //synchronize the rsi          EMACompressedBars = TimeSeriesSynchronizer.Synchronize(EMACompressedBars, source.Close); DateTimes = source.Close.DateTimes;          //modify the code below to implement your own indicator calculation for (int n = 0; n < source.Close.Count; n++)          { Values[n] = EMACompressedBars[n];          } } //generate parameters protected override void GenerateParameters() {          AddParameter("Source", ParameterType.BarHistory, null);          AddParameter("CompressionPeriod", ParameterType.Int32, 1);          AddParameter("EMAPeriod", ParameterType.Int32, 20); } } }
0
- ago
#3
QUOTE:
My goal is to create an indicator that would show the value of the EMA on a larger time frame.

Why not simply use the built-in ScaleInd indicator which does exactly that?



Denis, I understand that more features are being added to Wealth-Lab every other week so it's not easy to keep up with the pace. But you can learn more in the change log and our Youtube channel:
https://www.wealth-lab.com/Software/ChangeLog
2
Best Answer

Reply

Bookmark

Sort