- ago
I would like an 80 Day EMA as a indicator in my 1-minute script. What number should replace the 80 in my script to make it so that it is 80 day?

CODE:
EMA(bars.Close,80);


Thanks!
0
679
Solved
4 Replies

Reply

Bookmark

Sort
Cone8
 ( 6.61% )
- ago
#1
There' are a few ways to go about it, but multiplying the period isn't one of them.
Answer these to see which way would be most appropriate for you.

1. Which provider do you use for 1-min bars?
2. Do you use Building Blocks or C# Code?
0
- ago
#2
Hi Cone, I’m using TDAmeritrade as my provider and it is in a C# script
0
Cone8
 ( 6.61% )
- ago
#3
Great, C#-code will give you the best result for this one. You can create the daily indicator with a lot of lead bars so that it's synchronized with the intraday bars - even on the first bar of the chart.

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript5 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) {          // request the daily bars with a lot of lead time because EMA is a IIR (unstable) indicator          BarHistory _dailyBH = WLHost.Instance.GetHistory(bars.Symbol, HistoryScale.Daily, bars.DateTimes[0].Date.AddDays(-360), bars.DateTimes[bars.Count - 1].Date, Int32.MaxValue, null);          // create the daily indicator          _ema80day = EMA.Series(_dailyBH.Close, 80);          // synchronize it with the [intraday] bars          _ema80day = TimeSeriesSynchronizer.Synchronize(_ema80day, bars);          // let's see how it looks!          PlotTimeSeriesLine(_ema80day, "EMA(80-Day)", "Price", WLColor.NeonBlue);           } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { if (!HasOpenPosition(bars, PositionType.Long)) { //code your buy conditions here } else { //code your sell conditions here } }       //declare private variables below       BarHistory _dailyBH;       TimeSeries _ema80day; } }
0
Best Answer

Reply

Bookmark

Sort