if (Rising(SMA(50)))
{
Most of the time it is correct however every once in awhile for one bar it gives an incorrect signal.
I am using a 3 minute chart. When I use Visual Studio I notice that the code is being run at three time per bar. The first time the SMA 50 value match what is on the chart. The second time the SMA 50 value is changed. Both have the time stamp of 1330. Could you please explain why this is happening?
Also here is my Initialize function where I set CalculateOnBarClose:
protected override void Initialize()
{
// Add a 15 minute Bars object to the strategy
Add(PeriodType.Minute, 15);
//Add(Stochastics(3, 5, 2));
CalculateOnBarClose = true;
//EntryHandling = EntryHadling.UniqueEntries;
}
Values the first time:
Rising(smav50) false
Mom_Value 54.2986425339362
Past_Mom_K 40.196078431372108
ToTime(Time[0]) 133000
Values the second time:
Rising(smav50) true
Mom_Value 29.411764705882362
Past_Mom_K 54.2986425339362
ToTime(Time[0]) 133000
Values the third time:
Rising(smav50) false bool
Mom_Value 65.384615384614932 double
Past_Mom_K 29.411764705882362 double
ToTime(Time[0]) 133300 int
Value the fourth time but notice the time changed:
Rising(smav50) false bool
Mom_Value 65.384615384614932 double
Past_Mom_K 65.384615384614932 double
ToTime(Time[0]) 133600 int
Could you please explain why this is happening? Is it running 3 times because this is a 3 minute chart? At least at the 1330 bar the 1st and 3rd values matches the SMA 50 on the chart with is down. The 2nd time does not match the SMA 50 on the chart.
I do not want to assume I can disregard the 2nd time value.
I have also attached the chart. Notice the green arrow.
Thanks advance you for any help
Comment