I have a question on how to properly use RecalcLastBarAfter. We have MultiCharts.NET 8.7 build 7410.
I have a study on a daily chart and would like CalcBar() to be called on today's bar at least once every 10 seconds even if there are no ticks in the meantime. When I use (with intra bar order generation) the following study
Code: Select all
namespace PowerLanguage.Strategy
{
public class Test : SignalObject
{
public Test (object _ctx) : base (_ctx) {}
protected override void Create() {}
protected override void StartCalc() {}
protected override void CalcBar()
{
if (Bars.LastBarOnChart)
{
Output.WriteLine ("last bar "+Bars.Time[0].ToString ("yyyy-MM-dd HH:mm:ss tt")+" received at "+DateTime.Now.ToString ("yyyy-MM-dd HH:mm:ss"));
}
else
Output.WriteLine ("other bar "+Bars.Time[0].ToString ("yyyy-MM-dd HH:mm:ss tt")+" received at "+DateTime.Now.ToString ("yyyy-MM-dd HH:mm:ss"));
ExecControl.RecalcLastBarAfter (new TimeSpan (0,0,10));
}
}
}
Am I using RecalcLastBarAfter properly? Is there any option that I forgot to activate for this to work? Any kind of help is most appreciated.
Once I have this for a study, I would also like to get it work for an indicator. The reason is that I have an indicator that depends on two instruments, and I do not know which one(s) receive the next tick. I therefore want to recalculate the indicator at least every 10 seconds because its value might change when instrument 2 receives a tick, even if instrument 1 does not.
HPF