Author |
Topic: Custom Indicators not updating when called in Strategies (6 messages, Page 1 of 1) |
||||
---|---|---|---|---|---|
Moderators: VPfau | |||||
MWadel3496 Posts: 3 Joined: Apr 14, 2014 |
I have customer indicators that I have created that I reference in my custom strategies but the indicator calculations are not updating as the strategy runs.
I log of the indicator values from the strategy that is referencing the same indicator that is displayed on the chart. The values are changing on the chart (the indicator works) but the log is showing that the indicator values are not updating in the strategy from the first bar when it is turned on. When I back test, the strategy works fine but when I turn it on and let it run live the values do not update so the strategy does not work correctly. Am I calling the indicator correctly or is there a method that I need to call to get it to update? Thanks // #link BMDS1.ind using System; using System.Collections.Generic; using System.ComponentModel; using OEC.UI; using OEC.Chart; using OEC.Chart.Indicators; using OEC.Chart.Details; using OEC.Chart.BaseSeries; using OEC.EL.Runtime; using System.Runtime.InteropServices; using System.Drawing.Drawing2D; using OEC.Chart.Custom.Strategy; using OEC.Data; namespace OEC.Chart.Custom.Sandbox { [Strategy("CustomCrossOverStrat")] public sealed class CustomCrossOverStrat : OEC.Chart.Custom.Strategy.CustomStrategy { #region Variables private int TrendPeriod = 27; private int _Period = 5; private int _Smooth = 1; private int iWait = 1; int iBuy=0; int iSell=0; Series Upper; Series Lower; #endregion #region Properties [Description("Smooth Period for Indicator"), DisplayName("Smooth Period"), Category("Parameters"), XmlSerializable] public int Smooth { get { return this._Smooth; } set { if (this._Smooth != value) { this._Smooth = value; base.OnChanged(DataChangedMode.Insert); } } } [Description("Period Length"), DisplayName("Period"), Category("Parameters"), XmlSerializable] public int Period { get { return this.TrendPeriod; } set { if (this.TrendPeriod != value) { this.TrendPeriod = value; base.OnChanged(DataChangedMode.Insert); } } } [Description("Bars to wait"), DisplayName("Wait"), Category("Parameters"), XmlSerializable] public int Wait { get { return this.iWait; } set { if (this.iWait != value) { this.iWait = value; base.OnChanged(DataChangedMode.Insert); } } } #endregion protected override void Process() { Log.WriteLine("Time: " + Time + " BMDS1 Upper: " + MyIndicators.BMDS1(_Smooth,_Period)["UpperBand"][0].Value + " BMDS1 Lower: " + MyIndicators.BMDS1(_Smooth,_Period)["LowerBand"][0].Value); //Filer on smoothed eASCFilter Lower = MyIndicators.BMDS1(_Smooth,_Period)["LowerBand"]; Upper = MyIndicators.BMDS1(_Smooth,_Period)["UpperBand"]; // Bullish >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if (MathEL.CrossesOver(Lower, Upper)) { iBuy++; } else { iBuy=0; } //If no current positions are held and all tests have been passed for iBuy then enter Buy Trade if ((Statistics.MarketPosition(0) == 0) && (iBuy == iWait)) { TradeEngine.EntryOrder(OrderSide.Buy, 1, OrderType.Market, 0, "Buy", SignalFlags.None); iBuy=0; } // Bearish >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if (MathEL.CrossesUnder(MyIndicators.BMDS1(_Smooth,_Period)["LowerBand"], MyIndicators.BMDS1(_Smooth,_Period)["UpperBand"])) { iSell++; } else { iSell=0; } if ((Statistics.MarketPosition(0) == 0) && (iSell == iWait)) { TradeEngine.EntryOrder(OrderSide.Sell, 1, OrderType.Market, 0, "Sell", SignalFlags.None); iSell=0; } } protected override void Reinitialize() { MyIndicators.Input = InputData; } } internal sealed class MyIndicators { public static Series Input; [DescriptionAttribute("BMDS1\nDefault: Smooth=2, Period=5")] public static SeriesArray BMDS1(int Smooth, int Period) { return CustomIndicatorInternal.CurrentContext.GetIndicatorM(Input, Smooth, Period); } } } Mark Wadel
|
||||
JSmith5611 Posts: 187 Joined: |
I see nothing that immediately jumps out at me, but I'm looking into it.
Jason Smith
|
||||
MWadel3496 Posts: 3 Joined: Apr 14, 2014 |
Thanks Jason.
Here is some additional information. I placed the ind file is in OEC/PlugIns folder and I have tried referencing them in \AppData\Local\OEC\CustomIndicators\bin.3.5.15.134\ but I still get the same result. Is there another way that I should / could call custom indicators from a strategy? Thanks Mark Wadel
|
||||
JSmith5611 Posts: 187 Joined: |
Odd, I thought I had responded, but it seems like the forum ate my response.
We have determined that this is an actual bug, and have it on our list of things to fix. Jason Smith
|
||||
MWadel3496 Posts: 3 Joined: Apr 14, 2014 |
Thanks for the response. I am sure that others want to do a similar processes with strategies so what is the recommended code implementation that you all would suggest while the bug is being fixed? Since OEC Trader has been out for a while and this bug is just being discovered, I am sure there must be a another way to work-around it that you or other users would recommend to use.
Thanks Mark Wadel
|
||||
CMicciche902 Posts: 367 Joined: |
A fix was released to Production on 29/May/17.
Chris M
|
||||