Below are some specific bits of code from a strategy that are needed to clarify my issue.
Strategy specifics
Primary bars object: 3 minutes
Series<bool> primaryCodeLongOK; protected override void OnStateChange() { if (State == State.SetDefaults) { Calculate = Calculate.OnEachTick; primaryCodeLongOK = new Series<bool>(this,MaximumBarsLookBack.Infinite); } else if (State == State.Configure) { AddDataSeries(Instrument.FullName, Data.BarsPeriodType.Minute, 6, Data.MarketDataType.Last); AddDataSeries(Instrument.FullName, Data.BarsPeriodType.Minute, 15, Data.MarketDataType.Last); AddDataSeries(Instrument.FullName, Data.BarsPeriodType.Minute, 65, Data.MarketDataType.Last); } } protected override void OnBarUpdate() { // ENTRIES // First Tick Of Bar is the bar Open, on the chart timeframe if (IsFirstTickOfBar && BarsInProgress == 0 && Position.MarketPosition == MarketPosition.Flat) { // gather criteria flags bool primary_Long = PrimaryCodeLong(); // go to the custom Method, execute the code, then come back here // store in the boolean series primaryCodeLongOK[0] = primary_Long; // try to open a new trade if (primary_Long) { EnterLong("LE1"); } } } // custom Methods private bool PrimaryCodeLong() { //LONG FORMULA - OPEN bool signalValid = (MACD(BarsArray[0], 10, 20, 9).Diff[0] > 0) && (EMA(BarsArray[1], 10)[2] < EMA(BarsArray[1], 10)[1]) && (Stochastics(BarsArray[2], 6, 7, 8).K[1] >= 90) && (RSI(BarsArray[3], 19, 1)[1] >= 20); return signalValid; }
The time frames of 3, 6, 15, and 65 minutes are all part of the custom Method. All of these component time frames have different times when their “bars ago” will change. Sometimes they will be aligned, sometimes they won’t.
Let’s say that “primaryCodeLongOK[0]” was valid at the 10:42 bar of the “3 min. Primary Bars object” and LongEntry was entered.
Once Long, print statements are also triggered at the same time.
Print (Instrument.FullName + " "+Times[0][0].ToString("MM/dd/yy HH:mm:ss")+" primaryCodeLongOK[1]: "+primaryCodeLongOK[1]);
Print (Instrument.FullName + " "+Times[0][0].ToString("MM/dd/yy HH:mm:ss")+" primaryCodeLongOK[2]: "+primaryCodeLongOK[2]);
Print (Instrument.FullName + " "+Times[0][0].ToString("MM/dd/yy HH:mm:ss")+" primaryCodeLongOK[3]: "+primaryCodeLongOK[3]);
Print (Instrument.FullName + " "+Times[0][0].ToString("MM/dd/yy HH:mm:ss")+" primaryCodeLongOK[4]: "+primaryCodeLongOK[4]);
Print (Instrument.FullName + " "+Times[0][0].ToString("MM/dd/yy HH:mm:ss")+" primaryCodeLongOK[5]: "+primaryCodeLongOK[5]);
Print (Instrument.FullName + " "+Times[0][0].ToString("MM/dd/yy HH:mm:ss")+" primaryCodeLongOK[6]: "+primaryCodeLongOK[6]);
Would the True/False print calculations take into account the component parts and the alignment of the varying multi-time frames within the custom Method when deciding if the previous “3 min. Primary Bars objects” were valid?
Another hypothetical. A “for loop” is created to be calculate if “primaryCodeLongOK[i]” was TRUE for any of the previous XX “3 min. Primary Bars objects”.
Would the “for loop” calculations take into account the component parts and the alignment of the varying multi-time frames within the custom Method when deciding if the previous “3 min. Primary Bars objects” were valid?
Thanks in advance.
Comment