Set a variable flag when price crosses a camarilla/pivotline?

 
Hi group

I am trying to learn how to code an expert, and are looking for a snippet of code that look for the price to cross a camarilla/pivot line, and when that happens it shall activate a flag.

I have a snippet that look like this:
In the variable section I have already defined the camarillalines with their respective variables.

double CurrentPrice=MarketInfo(Symbol(),MODE_BID);
    if (((CurrentPrice)==(P))||((CurrentPrice)==(L3))||
       ((CurrentPrice)==(L4))||((CurrentPrice)==(L5))||
       ((CurrentPrice)==(H3))||((CurrentPrice)==(H4))||((CurrentPrice)==(H5))){
       SetFlag=true;
      }



The problem with this code is if price move very quickly, or price move across a line in the form of a pricegap, then MarketInfo may not receive the bid value it should have return on the tick price crossed the camarillalines, and ofcourse if that happens then we get a cross of the lines without the SetFlag being triggered.

Can any of you codinggurus help me with a good code that does the job?

I was thinking of some code that uses the MarketInfo(Symbol(),MODE_BID); as part of the code that detects the crossing of the camarillalines. A friend of mine suggested to use Open and Close values, but on larger timeframes price can make huge moves before a candle closes, so part of the move will be missed, thus I would like to the tickvalue instead so to detect the cross immediately when it happens.

Any help?

 
Is there some code that can say:

If (PreviousTick<Camline && CurrentTick>Camline) || (PreviousTick>Camline && CurrentTick<Camline) {
SetFlag=true;
}

If there is a way to do it like the above, would that code be sufficient to detect all type of price crossing any of the lines, or do the code have to be a bit more advanced?
 
You can try: if (Low[0] < CamLine && High[0] > CamLine)
 
Hi MichaelB and thanks for your suggestion.

However if you read my above post again, you will see I mentioned I had already look at that option, and the problem with using High/Low/Close on bars as a method is of detection is when there are large bars on the cross. Specially if you trade higher timeframes, you can get 100 pip bars/moves that you miss because the EA is waithing for a High og Low to start trading.

Thats why I request help to find a method that triggers on tick/pricemovement, so the EA can trigger immediately if price cross a line.

Thanks though for taking time to try to help.
 
I think what you say is not true.
Suppose you begin with the condition (Low[0] < CamLine && High[0] > CamLine) as false and, for sample, the CamLine is above bar[0] ; If new ticks does High[0] to go up, when it reach the CamLine the condition above will become true and you can immediately set your flag. You have not to wait the bar is closed. But take care of the fact that your flag will be continously set until the end of the bar.
 
OK MichaelB, then please accept my appology. I thought high[0] would only get a value when bar is closed, but if you are correct then each tick will return value for each bar [0] move.

If so, then I can use your code, I am happy, thanks a lot :)
Reason: