I have written an empirical scan into a strategy which tracks what happens after a specific bar pattern and calculates a percentage probability of the likely outcome based on the historical data loaded. I want to reset the count every day, but keep the previous day's counts for use in the calculations. I have tried to do this by creating multiple series to house the counts. During debugging I have noticed the IsFirstBarOfSession script I have written appears to process twice, but I could be missing something. On the second process the number previously sent to the prior day series switches to zero. Here is the script in question:
if (Bars.IsFirstBarOfSession) { priordaydeuptracker[0] = deuptracker[1]; priordaydedowntracker[0] = dedowntracker[1]; priordaydetotaltracker[0] = detotaltracker[1]; Print("Eggs = " + priordaydeuptracker[0]); longtradefilter = false; shorttradefilter = false; trailingstoppriceseries[0] = stoplosss; losslimitbool = false; gainlimitbool = false; currentPnL = 0.00; risklimitbool = false; deupcount = 0; dedowncount = 0; deuptracker[0] = 0; dedowntracker[0] = 0; detotaltracker[0] = 0; decounter = 0; Print("Bacon = " + priordaydeuptracker[0]); } else { priordaydeuptracker[0] = priordaydeuptracker[1]; priordaydedowntracker[0] = priordaydedowntracker[1]; priordaydetotaltracker[0] = priordaydetotaltracker[1]; }
Eggs = 4
Bacon = 4
Eggs = 0
Bacon = 0
There are no other assignments to the priorday series anywhere in the strategy, and there are no other bacon and eggs prints, either. I am not sure why this code is running twice like this and undoing itself. Any input on this is appreciated.
Cheers.
Comment