Background: I am coding a strategy with multiplpe "flags". Basically dataseries with values of 0, 1, or -1 indicating if a condition is true false.
The strategy is coded with onbarupdate method. however i want the dataseries flags to base their calculations on the value of indicators at the close of the previous bar, and that calculation should occur on the first tick of the current bar.
any example i have been playing with is my macd flag. see below:
(FlagMACDMACD dataseries is set up and working)
if (FirstTickOfBar)
{
if (MACD(Median,3,10,16).Avg[1] > MACD(Median,3,10,16).Avg[2])
{
if (MACD(Median,3,10,16).Default[1] > MACD(Median,3,10,16).Default[2])
{
else
{
if (FirstTickOfBar)
{
if (MACD(Median,3,10,16).Avg[1] < MACD(Median,3,10,16).Avg[2])
{
if (MACD(Median,3,10,16).Default[1] < MACD(Median,3,10,16).Default[2])
{
else
{
In above example I want a dataseries to have a value of 1 if both the avg and default plots of the macd are rising over the previous bar and minus 1 if falling.
Now my problem is with this code is that the value (as displayed in the output window by a print(FlagMACDMACD) statement shows the value updating more than on the open of each bar. I have played for hours trying to work this out so would sincerely appreciate the help of one of the gurus.
Thanks again guys. What a night on the markets eh!

Comment