public override void OnUpdate(TickStatus args) { if (args != TickStatus.IsQuote) { C.GetValue(HistoryDataSeries.GetValue(PriceType.Close)); H.GetValue(HistoryDataSeries.GetValue(PriceType.High)); L.GetValue(HistoryDataSeries.GetValue(PriceType.Low));; var WH = ValueWhen(1, NW, Ref(HighestSince(1, NW, H), -1)); var WL = ValueWhen(1, NW, Ref(LowestSince(1, NW, L), -1)); var WCL = ValueWhen(1, NW, Ref(C, -1)); var BP = (WH + WL + WCL) / 3; var D = ((WH - WL) / 2) + BP; var B = BP - ((WH - WL) / 2); var D1 = (WH - WL) + BP; var B1 = BP - (WH - WL); var SB1 = BP - ((WH - WL) * 1.0618); var SB2 = BP - ((WH - WL) * 0.98382); var RB1 = ((WH - WL) * 1.0618) + BP; var RB2 = ((WH - WL) * 0.98382) + BP; Lines["RB2"].SetValue(RB2); Lines["RB1"].SetValue(RB1); Lines["D1"].SetValue(D1); Lines["D"].SetValue(D); Lines["BP"].SetValue(BP); Lines["B"].SetValue(B); Lines["B1"].SetValue(B1); Lines["SB1"].SetValue(SB1); Lines["SB2"].SetValue(SB2); } }
public override void OnUpdate(TickStatus args) { /*if (HistoryDataSeries.Count - 1 < period) * return;*/ a1 = Mov(PriceType.Close, period, MAMode.EMA); a2 = a1.GetValueByIndex(0) - (a1.GetValueByIndex(0) * percentage / 100); a3 = a1.GetValueByIndex(0) + (a1.GetValueByIndex(0) * percentage / 100); // Both custom series is required to be supplied by value for the algorithm b1.GetValue(a1.GetValueByIndex(0)); b2.GetValue(a1.GetValueByIndex(0)); var k1 = Cross(a1, Ref(b2, 1)); var k2 = Cross(Ref(b1, 1), a1); //Search index example of a logical cross over condition based on operation input and variable relations //BarsSince(a1, InstrumentsManager.Current.DayInfo.PrevClose, Operation.Less<double>()); var s1 = BarsSince(k1) < BarsSince(k2); var s2 = s1 ? b1 : b2; Lines["a1"].SetValue(a1.GetValueByIndex(0)); Lines["s2"].SetValue(s2.GetValueByIndex(0)); }
public override void OnUpdate(TickStatus args) { //using generic custom entity, which could be used for any build-in TE indicator with proper dataseries synchronization MTST_momentum.GetValue(momentum.GetValue()); var ema = Mov(MTST_momentum.GetValueByIndex(0) - Ref(MTST_momentum, 1).Value, 66, MAMode.EMA); var sma = Mov(ema.GetValueByIndex(0), 3, MAMode.SMA); Lines["momentum1"].SetValue(sma.GetValueByIndex(0)); //using Mom class, only for momentum calculation var newMomentum = Mom(momPeriod); ema = Mov(newMomentum.GetValueByIndex(0) - Ref(newMomentum, 1).Value, 66, MAMode.EMA); sma = Mov(ema.GetValueByIndex(0), 3, MAMode.SMA); Lines["momentum2"].SetValue(sma.GetValueByIndex(0)); }