how to reset when price crosses this line

 

hello, i am making an EA for my system, what is it is when prices leaves the box to the top i buy and to the bottom i sell. this is done eachtime the box leaves the box

what i want to do is find a way so that when prices leaves the box and re-enters, the prices must come back into hte box to a certain point (for example the red line in the picture i posted). if it doesnt reach this point before it leaves the box again a trade isnt made.

also keep in mind that the box in redrawn each day, in a different spot.

thanks, and i am going to post the code i have typed so far, it is not yet done, any tips, tricks, techniques, etc, are welcome, and remember i am a newbie when it comes to programming.

//+------------------------------------------------------------------+

//| optimized If Else EA.mq4 |

//| Alex Nikolaou Copyright © 2008, MetaQuotes Software Corp. |

//| Forex Trading Software: Forex Trading Platform MetaTrader 4 |

//+------------------------------------------------------------------+

#property copyright "Alex Nikolaou Copyright © 2008, MetaQuotes Software Corp."

#property link "Forex Trading Software: Forex Trading Platform MetaTrader 4"

//--------------------------------------------------------------------

//--------------------------------------------------------------------

extern double levelhigh = 1.5000; // preset high alert level

extern double levellow = 1.4990; // preset low alert level

//--------------------------------------------------------------------

int start ()

{

double price=Bid;

if(OrdersTotal() < 1) // keeps max simultaneous orders at 1

{ // current Bid

if ( price > levelhigh) // Condition

{

OrderSend(Symbol(),OP_BUY,0.1,Ask,1,Bid-14*Point,Bid+15*Point,Green); //Opens long orders

Alert(GetLastError()); // Last Error Alert

}

else // Else operator

{

if (price < levellow) //Condition

{

OrderSend(Symbol(),OP_SELL,0.1,Bid,1,Bid+16*Point,Bid-14*Point,Black); //opens short oders

Alert(GetLastError()); //Last Error Alert

}

}

}

return; //Return operator

}

//--------------------------------------------------------------------

Files:
pic.jpg  66 kb
Reason: