Checking against the final value of an indicator for the previous bar

 

Hi Everyone,


I am trying to write a program to determine if the ask or bid for a previous bar has gone below a lower bollinger in the previous bar. At this point the program will check if the Ask or Bid are less than the Lower Bollinger at every interval (start()), and print a "1" on the screen if this condition is met:



This is what it looks like right now


If you look at the next screen, the red arrows indicate where I would like it to indicate the ask/bid has crossed the lower bollinger as well:



This is what it should look like. There should be 1's where the red arrows are


So it seems as though at at the current time when it is checking if ask or bid are less than the lower bollinger, it is not less. However I want to find out if, during the previous period, the Low for Ask or Bid was less than the lower bollinger value displayed on the chart.


I think I am using the wrong approach with this.... I guess my question is is there a way to find the value of an indicator (in my case the lower bollinger) for a previous bar, so I can compare it to the Low for the previous bar? I have only been able to find the value for the exact time that the code is being executed (every start()).


Any help/ comments / suggestions are greatly appreciated as I am really stumped and would love to hear your ideas on how to do this!


Thanks!!!!!

-John


This is my code below, just ignore the ObjectCount, that is just being used for managing the text objects.

double LowerBollinger;
int ObjectCount = 0;

int init()
  {
   return(0);
  }

int deinit()
  {
   return(0);
  }

int start()
  {
   LowerBollinger = iBands(NULL, 0, 9, 2, 0, PRICE_CLOSE, MODE_LOWER, 0);
   
   if (Ask < LowerBollinger) {
      ObjectCreate(ObjectId(), OBJ_TEXT, 0, Time[0], Ask);
      ObjectSetText(DoubleToStr(ObjectCount, 0), "1", 8, "Arial Black", White);
   } else if (Bid < LowerBollinger) {
      ObjectCreate(ObjectId(), OBJ_TEXT, 0, Time[0], Bid);
      ObjectSetText(DoubleToStr(ObjectCount, 0), "1", 8, "Arial Black", White);
   }
   return(0);
  }

string ObjectId() {
   ObjectCount += 1;
   return (DoubleToStr(ObjectCount, 0));
}

Reason: