//+------------------------------------------------------------------+
//| Copyright 2006, Osama M. Shaban |
//| Email:
[email protected] |
//+------------------------------------------------------------------+
#property copyright "Copyright 2006, Osama M. Shaban"
#property link "
[email protected]"
#define MAGIC 345678
//Expert Entry Values
//------------------------------------------------------------------------
extern int TimeFrame = 60; //H1 = 60, H4 = 240
extern int SL = 2000; // Should be very big ! Will not work with smaller values!
extern int TP = 10; // use 10 pips for TF=H1=60 and 30 Pips for TF=H4=240
extern double L_level = 15;
extern double S_level = 85;
extern double Lots = 1; // Adjust the lot size according to your account Balance/Type
extern int TotalOfOrders = 2;
extern bool UseSound = True;
//------------------------------------------------------------------------
//Slippage
//------------------------------------------------------------------------
int Slippage = 2;
//------------------------------------------------------------------------
//Expert name
//------------------------------------------------------------------------
string Name_Expert = "بن فريحان عشرة نقاط";
//------------------------------------------------------------------------
//Colour settings
//------------------------------------------------------------------------
color clOpenBuy = Blue;
color clCloseBuy = Aqua;
color clOpenSell = Red;
color clCloseSell = Violet;
color clModiBuy = Blue;
color clModiSell = Red;
//------------------------------------------------------------------------
string NameFileSound = "alert.wav";
void deinit() {
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start(){
double total;
if(Bars<100){
Print("bars less than 100");
return(0);
}
if(SL<10){
Print("StopLoss less than 10");
return(0);
}
if(TP<10){
Print("TakeProfit less than 10");
return(0);
}
if(SL<10){
Print("StopLoss less than 10");
return(0);
}
if(TP<10){
Print("TakeProfit less than 10");
return(0);
}
total=OrdersTotal();
if(total<TotalOfOrders)
double d0Sto=iStochastic(NULL,TimeFrame,5,3,3,MODE_EMA,PR ICE_CLOSE,MODE_MAIN,0);
double d1Sto=iStochastic(NULL,TimeFrame,5,3,3,MODE_EMA,PR ICE_CLOSE,MODE_MAIN,1);
if(AccountFreeMargin()<(1000*Lots)){ //Will not trade if mini account has less than $100 or standard <$1000
Print("You have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
//if (!ExistPositions()){
if ((d0Sto>d1Sto)&&(d0Sto<=L_level)){
OpenBuy();
return(0);
}
if ((d0Sto<d1Sto)&&(d0Sto>=S_level)){
OpenSell();
return(0);
}
}
return (0);
//}
//bool ExistPositions() {
// for (int i=0; i<OrdersTotal(); i++) {
// if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
// if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
// return(True);
// }
// }
//}
// return(false);
//}
void OpenBuy() {
double ldLot, ldStop, ldTake;
string lsComm;
ldLot = GetSizeLot();
ldStop = GetStopLossBuy();
ldTake = GetTakeProfitBuy();
lsComm = GetCommentForOrder();
OrderSend(Symbol(),OP_BUY,ldLot,Ask,Slippage,ldSto p,ldTake,lsComm,MAGIC,0,clOpenBuy);
if (UseSound) PlaySound(NameFileSound);
}
void OpenSell() {
double ldLot, ldStop, ldTake;
string lsComm;
ldLot = GetSizeLot();
ldStop = GetStopLossSell();
ldTake = GetTakeProfitSell();
lsComm = GetCommentForOrder();
OrderSend(Symbol(),OP_SELL,ldLot,Bid,Slippage,ldSt op,ldTake,lsComm,MAGIC,0,clOpenSell);
if (UseSound) PlaySound(NameFileSound);
}
string GetCommentForOrder() { return(Name_Expert); }
double GetSizeLot() { return(Lots); }
double GetStopLossBuy() { return (Bid-SL*Point);}
double GetStopLossSell() { return(Ask+SL*Point); }
double GetTakeProfitBuy() { return(Ask+TP*Point); }
double GetTakeProfitSell() { return(Bid-TP*Point); }