On Replay, I am using 2 DataSeries : Data 1 with 1 min data and Data 2 with 1 Hour data. (See Attachment Workspace 2 Data) As an example, I am using "MovAvg_Cross_LE" signal.
I want the calculus of the Average to be on the 1 Hour Data : Dataserie 2, with an update every minute as in Data 1
I am doing a change in void Create() : m_AverageFC = new AverageFC(this,2);
Code: Select all
protected override void Create()
{
m_AverageFC = new AverageFC(this,2);
m_MACrossLE =
OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "MACrossLE", EOrderAction.Buy));
m_Counter = new VariableObject<int>(this);
}
I insert the signal on Data 1 but the update is only every 1 Hour. How can I have the Moving Average Calculus of 1 hour Data 2 with a 1 minute update on Data 1 ?
In Real time or Replay, with the Signal I don't have any minute update with a calculus on 1 hour data, it is the same with the indicator if I am doing a change in void Create() : m_AverageFC = new AverageFC(this,2);
Code: Select all
protected override void Create()
{
m_AverageFC = new AverageFC(this,2);
m_MACrossLE =
OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "MACrossLE", EOrderAction.Buy));
m_Counter = new VariableObject<int>(this);
}
Code: Select all
using System;
using PowerLanguage.Function;
using System.IO;
using System.Text;
namespace PowerLanguage.Strategy
{
public class MovAvg_Cross_LE : SignalObject
{
private AverageFC m_AverageFC;
private VariableObject<Int32> m_Counter;
private IOrderMarket m_MACrossLE;
String path4InputOutPut;
StreamWriter sw4;
public MovAvg_Cross_LE(object ctx) :
base(ctx)
{
Length = 9;
ConfirmBars = 1;
}
private ISeries<double> Price { get; set; }
[Input]
public int Length { get; set; }
[Input]
public int ConfirmBars { get; set; }
protected override void Create()
{
m_AverageFC = new AverageFC(this,2);
m_MACrossLE =
OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "MACrossLE", EOrderAction.Buy));
m_Counter = new VariableObject<int>(this);
}
protected override void StartCalc()
{
Price = BarsOfData(2).Close; // Bars.Close;
m_AverageFC.price = Price;
m_AverageFC.length = Length;
path4InputOutPut = "C:\\Temp\\Test1.txt";
sw4 = new StreamWriter(path4InputOutPut, true, Encoding.ASCII);
sw4.AutoFlush = true;
}
protected override void StopCalc()
{
if (sw4 != null)
{
sw4.Close();
}
base.StopCalc();
}
protected override void CalcBar()
{
double m_Avg = m_AverageFC[0];
if (PublicFunctions.DoubleGreater(Price[0], m_Avg)){
++m_Counter.Value;
}
else{
m_Counter.Value = 0;
}
if (PublicFunctions.DoubleGreater(Bars.CurrentBar, ConfirmBars)
&& m_Counter.Value == ConfirmBars)
{
m_MACrossLE.Send();
}
// sw4.WriteLine(this.BarsOfData(1).Time[0].ToString() + " m_Avg : " + m_Avg.ToString());
}
}
}