//+---------------------------------------------------------+ //| Asian High Asian Low | //| version 1.2 | //| original idea by FXOperator | //| EA conversion by Azmel | //+---------------------------------------------------------+ //| DESCRIPTION: This EA will find the Asian High and Asian | //| Low values during the given times. Once Europe, London | //| and New York start to open, it will then take advantage | //| of the more volatile activity. A trade will be placed | //| if the AHAL is breached. The system will reset once | //| market closes. If EA placed when market is already | //| opened, it will wait for the next cycle. | //+---------------------------------------------------------+ //| VERSION HISTORY | //| 1.0 Initial release. | //| 1.1 New, more efficient trading codes written. | //| 1.11 Startup sequence: will not place trade if AHAL is | //| already breached. | //| 1.2 Double trades. Added BE and TS. | //+---------------------------------------------------------+ extern int Magic = 68415; extern int AsianOpen = 0; extern int AsianClose = 6; extern int MarketClose = 20; extern int MinRange = 20; extern int MaxRange = 150; extern int Buffer = 0; extern bool MM = false; extern double Risk = 0.1; extern double Lots = 0.1; extern int TakeProfit1 = 10; extern int TakeProfit2 = 100; extern int BreakEven = 10; extern int TrailingStop = 15; extern int StopLoss = 50; extern bool EnableAlert = true; bool Admin; string AdminComment; double AsianHigh; double AsianLow; int BarCount; int BarStart; int BarShift; double MinLot; double LotSize; int i; int slippage = 5; int ticket; string Status; string BuyStatus1; string BuyStatus2; string SellStatus1; string SellStatus2; double AsianRange; string RangeComment; int init() { if(GlobalVariableGet("AHAL.B1."+Symbol())==1) { BuyStatus1="Active"; } else { BuyStatus1="Ready"; } if(GlobalVariableGet("AHAL.B2."+Symbol())==1) { BuyStatus2="Active"; } else { BuyStatus2="Ready"; } if(GlobalVariableGet("AHAL.S1."+Symbol())==1) { SellStatus1="Active"; } else { SellStatus1="Ready"; } if(GlobalVariableGet("AHAL.S2."+Symbol())==1) { SellStatus2="Active"; } else { SellStatus2="Ready"; } return(0); } int deinit() { if(BuyStatus1=="Active") { GlobalVariableSet("AHAL.B1."+Symbol(),1); } else { GlobalVariableSet("AHAL.B1."+Symbol(),0); } if(BuyStatus2=="Active") { GlobalVariableSet("AHAL.B2."+Symbol(),1); } else { GlobalVariableSet("AHAL.B2."+Symbol(),0); } if(SellStatus1=="Active") { GlobalVariableSet("AHAL.S1."+Symbol(),1); } else { GlobalVariableSet("AHAL.S1."+Symbol(),0); } if(SellStatus2=="Active") { GlobalVariableSet("AHAL.S2."+Symbol(),1); } else { GlobalVariableSet("AHAL.S2."+Symbol(),0); } return(0); } int start() { //ADMIN if(Admin) { AdminComment=StringConcatenate("Asian High = ",AsianHigh,"\n" ,"Asian Low = ",AsianLow,"\n" ,"Status = ",Status,"\n" ,"BuyStatus1 = ",BuyStatus1,"\n" ,"BuyStatus2 = ",BuyStatus2,"\n" ,"SellStatus1 = ",SellStatus1,"\n" ,"SellStatus2 = ",SellStatus2 ); } else { AdminComment=""; } //ON-SCREEN COMMENTS Comment("\n" ,"AsianHighAsianLow version 1.2","\n" ,"Copyright © 2007-2008 FXOperator","\n" ,"EA Conversion by Azmel","\n\n" ,RangeComment,AdminComment); //MM if(MM) { MinLot=MarketInfo(Symbol(),MODE_MINLOT); LotSize=MarketInfo(Symbol(),MODE_LOTSIZE); Lots=Risk*AccountBalance()/LotSize; if(LotsAsianClose) { BarCount=24+AsianClose-AsianOpen; } if(AsianOpen=AsianClose && Hour()=MaxRange) { RangeComment="Market too volatile. No trades today.\n\n"; return(0); } //CHECK IF HIGH BREACHED. BUY SIGNAL if(Status=="Open" && BuyStatus1=="Ready" && Ask>=AsianHigh+Buffer*Point) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,slippage,Ask-StopLoss*Point,Ask+TakeProfit1*Point,"AHAL-Buy1",Magic,0,Blue); if (ticket != -1) { BuyStatus1 = "Active"; if(EnableAlert) { Alert(Symbol()+": High breached. Trade1 placed."); } } } if(Status=="Open" && BuyStatus2=="Ready" && Ask>=AsianHigh+Buffer*Point) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,slippage,Ask-StopLoss*Point,Ask+TakeProfit2*Point,"AHAL-Buy2",Magic,0,Blue); if (ticket != -1) { BuyStatus2 = "Active"; if(EnableAlert) { Alert(Symbol()+": High breached. Trade2 placed."); } } } //CHECK IF LOW BREACH. SELL SIGNAL if(Status=="Open" && SellStatus1=="Ready" && Bid<=AsianLow-Buffer*Point) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,slippage,Bid+StopLoss*Point,Bid-TakeProfit1*Point,"AHAL-Sell1",Magic,0,Red); if (ticket != -1) { SellStatus1 = "Active"; if(EnableAlert) { Alert(Symbol()+": Low breached. Trade1 placed."); } } } if(Status=="Open" && SellStatus2=="Ready" && Bid<=AsianLow-Buffer*Point) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,slippage,Bid+StopLoss*Point,Bid-TakeProfit2*Point,"AHAL-Sell2",Magic,0,Red); if (ticket != -1) { SellStatus2 = "Active"; if(EnableAlert) { Alert(Symbol()+": Low breached. Trade2 placed."); } } } //BREAK-EVEN AND TRAILING-STOP ROUTINE for(i=0;i0 && Bid>=OrderOpenPrice()+BreakEven*Point && OrderStopLoss()0 && Ask<=OrderOpenPrice()-BreakEven*Point && OrderStopLoss()>OrderOpenPrice()) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,CLR_NONE); } if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_BUY && TrailingStop>0 && Bid-OrderStopLoss()>TrailingStop*Point && Bid>=OrderOpenPrice()+TrailingStop*Point) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,CLR_NONE); } if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_SELL && TrailingStop>0 && OrderStopLoss()-Ask>TrailingStop*Point && Ask<=OrderOpenPrice()-TrailingStop*Point) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,CLR_NONE); } } return(0); }