//+------------------------------------------------------------------+ //| BADX.mq4 | //| Copyright © 2011, AM2. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, AM2." #define MagicNumber 20110217 extern double StopLoss = 950; extern double TakeProfit = 950; extern double ADXPeriod = 30; extern double BBPeriod = 10; extern double BBDev = 1.5; extern int Level = 20; extern double Lot = 2; bool b=true, s=true; //+------------------------------------------------------------------+ //| Calculate open positions | //+------------------------------------------------------------------+ int CalculateCurrentOrders(string symbol) { int pos=0; //---- for(int i=0;i0) return(pos); } //+------------------------------------------------------------------+ //| Check for open order conditions | //+------------------------------------------------------------------+ void CheckForOpen() { //---- go trading only for first tiks of new bar if(Volume[0]>1) return; //---- int res; //---- get Indicatorrs double bbh=iBands(NULL,0,BBPeriod,BBDev,0,PRICE_CLOSE,MODE_UPPER,0); double bbl=iBands(NULL,0,BBPeriod,BBDev,0,PRICE_CLOSE,MODE_LOWER,0); double adx=iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_MAIN,0); //---- buy if(adxbbh && s) { res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",MagicNumber,0,Red); b=true; s=false; return; } } //+------------------------------------------------------------------+ //| Start function | //+------------------------------------------------------------------+ void start() { //---- check for history and trading if(Bars<100 || IsTradeAllowed()==false) return; //---- calculate open orders by current symbol if(CalculateCurrentOrders(Symbol())==0) CheckForOpen(); //---- } //+------------------------------------------------------------------+