_____





extern double TakeProfit = 15,StopLoss=15; 
extern double pp=2.5,pp1=3.5,pp2=3.5,pp3=4.5, mm=3.5, mm1=3.5, mm2=4.5,SL=15; 
double close; 
int start() 
{ 
int cnt, ticket; 
int mag; 
if (Symbol()=="EURUSD") mag=1; 
if (Symbol()=="GBPUSD") mag=2; 
if (Symbol()=="USDCHF") mag=3; 
if (Symbol()=="USDJPY") mag=4; 


double Lots; 
if (Symbol()=="EURUSD" || Symbol()=="GBPUSD") Lots=(MathCeil(AccountBalance()/Close[0]*Point*100)-1)/10; 
if (Symbol()=="USDCHF") Lots=(MathCeil(AccountBalance()*Point*100)-1)/10; 
if (Symbol()=="USDJPY") Lots=(MathCeil(AccountBalance()*Point)-1)/10; 

if (Lots>100) Lots=100; 
if (Lots<0.1) Lots=0.1; 

double bc=((iBullsPower(NULL, 0, 1,PRICE_CLOSE,0)+iBearsPower(NULL,0, 1,PRICE_CLOSE,0))/Point); 
double s,b; 

if ((Close[0]-Open[1])/Point > pp3) 
{s=1; 
Print("sell pp3");} 
if ((Close[0]-Open[1])/Point <-pp3) 
{b=1; 
Print("buy pp3");} 
if ((Close[0]-Open[0])/Point > pp2) 
{s=1; 
Print("sell pp2");} 
if ((Close[0]-Open[0])/Point <-pp2) 
{b=1; 
Print("buy pp2");} 
if ((Close[0]-Close[1])/Point > pp1) 
{s=1; 
Print("sell pp1");} 
if ((Close[0]-Close[1])/Point <-pp1) 
{b=1; 
Print("buy pp1");} 
if (bc > pp) 
{b=1; 
Print("buy pp");} 
if (bc < -pp) 
{s=1; 
Print("sell pp");} 


Print(Day(),"/",Month()," ",Hour(),":",Minute(),":",Seconds()," Bal=",AccountBalance()," eq=",AccountEquity()," ",Symbol(),"=",Close[0]," BC=",bc," cl1=",(Close[0]-Close[1])/Point," c=",close," L=",Lots); 
Comment(Hour(),":",Minute(),":",Seconds()," Bal=",AccountBalance()," eq=",AccountEquity()," ",Symbol(),"=",Close[0]," BC=",bc," cl1=",(Close[0]-Close[1])/Point," c=",close," L=",Lots); 


for(cnt=0;cnt<OrdersTotal();cnt++) 
{ 
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); 

if(OrderType()==OP_BUY && OrderMagicNumber()==mag ) close=OrderOpenPrice()-SL*Point; 
if(OrderType()==OP_SELL && OrderMagicNumber()==mag) close=OrderOpenPrice()+SL*Point; 
} 

//--------------------------------------------------------------- 
if (OrdersTotal()>0) 
{ 
for(cnt=0;cnt<OrdersTotal();cnt++) 
{ 
if (OrderMagicNumber()==mag ) 
{ 
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); 

if(OrderType()==OP_BUY ) 
{ 
if(bc<-mm || (Close[0]-Open[0])/Point>mm2) 
{ 
Print("bc_BUY"); 
OrderClose(OrderTicket(),OrderLots(),Bid,0,Red); 
} 
} 
if(OrderType()==OP_SELL) 
{ 
if(bc>mm || (Close[0]-Open[0])/Point<-mm2) 
{Print("bc_SELL"); 
OrderClose(OrderTicket(),OrderLots(),Ask,0,Aqua); 
} 
} 

if(OrderType()==OP_BUY ) 
{ 
if(bc<-mm || (Close[0]-Close[1])/Point>mm1) 
{ 
Print("bc_BUY"); 
OrderClose(OrderTicket(),OrderLots(),Bid,0,Red); 
} 
} 
if(OrderType()==OP_SELL) 
{ 
if(bc>mm || (Close[0]-Close[1])/Point<-mm1) 
{Print("bc_SELL"); 
OrderClose(OrderTicket(),OrderLots(),Ask,0,Aqua); 
} 
} 

if(OrderType()==OP_BUY) 
{ 
if(Bid<close) 
{Print("close_BUY"); 
OrderClose(OrderTicket(),OrderLots(),Bid,0,Red); 
} 
} 
if(OrderType()==OP_SELL) 
{ 
if(Ask>close ) 
{ 
OrderClose(OrderTicket(),OrderLots(),Ask,0,Aqua); 
Print("close_SELL"); 


} 
} 

if(OrderType()==OP_BUY) 
{ 
if(AccountEquity()-AccountBalance() > 0) 
{ 
Print("+_BUY"); 
OrderClose(OrderTicket(),OrderLots(),Bid,0,Red); 


} 
} 
if(OrderType()==OP_SELL) 
{ 
if(AccountEquity()-AccountBalance() > 0) 
{ 
Print("+_SELL"); 
OrderClose(OrderTicket(),OrderLots(),Ask,0,Aqua); 


} 
} 
} 
} 
} 
//------------------------------------------------------------------------------- 
if(OrdersTotal()<1) 
{ 
if(b==1 && (Ask-Bid)/Point<3) 
{ 
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Ask-StopLoss*Point,Ask+TakeProfit*Point,"buy",mag,0,Red); 

if(ticket>0) 
{ 
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); 
close=Ask-SL*Point; 
} 
else Print("Error opening BUY order : ",GetLastError()); 

} 

if(s==1 && (Ask-Bid)/Point<3) 
{ 
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,0,Bid+StopLoss*Point,Bid-TakeProfit*Point,"sell",mag,0,Aqua); 

if(ticket>0) 
{ 
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); 
close=Bid+SL*Point; 
} 
else Print("Error opening SELL order : ",GetLastError()); 

} 

} 
}



Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar
Series array that contains open prices of each bar


Indicator Curves created:


Indicators Used:

Bears Power indicator
Bulls Power indicator


Custom Indicators Used:

Order Management characteristics:
Checks for the total of open orders
It Closes Orders by itself
It automatically opens orders when conditions are reached

Other Features:


BackTest : EURUSD on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.00 Total Net Profit:0.00

BackTest : USDJPY on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:0.00 Total Net Profit:0.00

BackTest : USDCAD on H1

From 2009-12-01 to 2010-01-01 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2009-08-01 to 2009-10-01 Profit Factor:0.00 Total Net Profit:0.00

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-02-27 Profit Factor:0.00 Total Net Profit:0.00

BackTest : USDCAD on H1

From 2009-01-01 to 2010-01-01 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:0.00 Total Net Profit:0.00

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-04-16 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-04-01 to 2010-04-30 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-05-01 to 2010-05-31 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-06-01 to 2010-06-30 Profit Factor:0.00 Total Net Profit:0.00

Request Backtest for _____


From : (yyyy/mm/dd) To: (yyyy/mm/dd)

Pair: Period: