//+------------------------------------------------------------------+ //| earlyTopProrate_V1.mq4 20.08.2010 - 08:54 //|(earlyOpenTrend.my4) //| //| //| dailyOpen = Basiswert, , DailyHigh, -Low = Selektion //+------------------------------------------------------------------+ #property copyright "hansH" #property link "" extern int StartHour = 5; extern int EndHour = 10; extern int ClosingHour = 18; extern int ZD = 0; // ---- double Lots = 0.5; extern int maxPos = 1; int TP1 = 25; int TP2 = 50; int TP3 = 75; int setTP = 35; // TP => OpenPrice int setSL0 = 100; // SL=> +/-50 int setSL1 = 35; // 40 int setSL2 = 60; // 90 int modiSL = 25; // setSL2-35=25 int Ratio1 = 30; // nicht ändern! int Ratio2 = 70; // nicht ändern! int Ratio3 = 100; // nicht ändern! int Phase = 0; int Magic =170810; bool CommentMode = true; bool SignalBuy =false; bool SignalSell =false; // MoneyManagement extern int MMTyp = 0; int FactorMM2 = 3; int RiskMM2 = 50; // ---- double o1, h1, l1; double MAtrend, MAtrend1; double modLots, varLots, opLongLots, opShortLots; string ProfitPoints; int i; //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ int start() { modiSL = setSL2-35; // ---- Anzahl offene Positionen/Typ int cnt, cntOpPos, cntOpLong=0, cntOpShort=0; double Prof; for(cnt=0; cnt(o1-l1) ) string aktTrend="Up"; else if( (h1-o1)<(o1-l1) ) aktTrend="Down"; else aktTrend="flat"; // ---- if (Bid>o1 && aktTrend=="Up" && cntOpPos<1) SignalBuy=true; // ---- if (Ask3) MMTyp=0; if (MMTyp<=1 && OrdersTotal()<1) Lots=Lots; if (MMTyp==2 && OrdersTotal()<1) Lots=0.1*MathSqrt(AccountBalance()/1000)*FactorMM2; if (MMTyp==3 && OrdersTotal()<1) Lots=AccountEquity()/Close[0]/1000*RiskMM2/100; if(MMTyp>=2) { Lots = modLots(Lots); double minLot = MarketInfo(Symbol(), MODE_MINLOT); double maxLot = MarketInfo(Symbol(), MODE_MAXLOT); if (LotsmaxLot)Lots=maxLot; } } //+------------------------------------------------------------------+ //| OrderSend //+------------------------------------------------------------------+ if(Hour()>=StartHour && Hour()0) { for (cnt=0;cnt0 && Bid-OrderOpenPrice()<=-setTP*10*Point && OrderTakeProfit()==0) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderOpenPrice(),0); return(0); } //---- setSL0 **** 100 **** / BUY-SL od. TP setzen if (setSL0>0 && Bid-OrderOpenPrice()<=-setSL0*10*Point) { //OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-50*10*Point,OrderTakeProfit(),0); OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderOpenPrice()-50*10*Point,0); return(0); } //---- setSL1 / BUY-SL erhöhen auf OrderOpenPrice() if (setSL1>0 && Bid-OrderOpenPrice()>=setSL1*10*Point && OrderStopLoss()0 && Bid-OrderOpenPrice()>=setSL2*10*Point && OrderStopLoss()=TP1*10*Point && Phase==0 && TP1>0) { OrderClose(OrderTicket(),modLots(OrderLots()*Ratio1/100),Bid,0); Phase=1; return(0); } //---- TP2 if(Bid-OrderOpenPrice()>=TP2*10*Point && Phase==1 && TP2>0) { OrderClose(OrderTicket(),modLots(OrderLots()*Ratio2/100),Bid,0); Phase=2; return(0); } //---- TP3 **** 75 **** if(Bid-OrderOpenPrice()>=TP3*10*Point && Phase==2 && TP3>0) { OrderClose(OrderTicket(),modLots(OrderLots()*Ratio3/100),Bid,0); Phase=3; return(0); } } // if (OrderType()==OP_BUY) // ---- if (OrderType()==OP_SELL) { opShortLots=OrderLots(); /* //---- SL- u. TP-Modify if (OrderStopLoss()==0) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+modiSL*10*Point,OrderTakeProfit(),0); return(0); } */ //---- setTP **** 35 **** / TP auf OrderOpenPrice() setzen if (setTP>0 && OrderOpenPrice()-Ask<=-setTP*10*Point && OrderTakeProfit()==0) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderOpenPrice(),0); return(0); } //---- setSL0 **** 100 **** / SELL-SL od. TP setzen if (setSL0>0 && OrderOpenPrice()-Ask<=-setSL0*10*Point) { //OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+50*10*Point,OrderTakeProfit(),0); OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderTakeProfit()+50*10*Point,0); return(0); } //---- setSL1 / SELL-SL senken auf OrderOpenPrice() if (setSL1>0 && OrderOpenPrice()-Ask>=setSL1*10*Point && OrderStopLoss()>OrderOpenPrice()) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0); return(0); } //---- setSL2 / SELL-SL senken auf OrderOpenPrice()-modiSL if (setSL2>0 && OrderOpenPrice()-Ask>=setSL2*10*Point && OrderStopLoss()>OrderOpenPrice()-modiSL*10*Point) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-modiSL*10*Point,OrderTakeProfit(),0); return(0); } //---- TP1 if(OrderOpenPrice()-Ask>=TP1*10*Point && Phase==0 && TP1>0) { OrderClose(OrderTicket(),modLots(OrderLots()*Ratio1/100),Ask,0); Phase=1; return(0); } //---- TP2 if(OrderOpenPrice()-Ask>=TP2*10*Point && Phase==1 && TP2>0) { OrderClose(OrderTicket(),modLots(OrderLots()*Ratio2/100),Ask,0); Phase=2; return(0); } //---- TP3 **** 75 **** if(OrderOpenPrice()-Ask>=TP3*10*Point && Phase==2 && TP3>0) { OrderClose(OrderTicket(),modLots(OrderLots()*Ratio3/100),Ask,0); Phase=3; return(0); } } // if (OrderType()==OP_SELL) // ---- //if(Phase==0) { if (opLongLots==Lots || opShortLots==Lots || (opLongLots==0 && opShortLots==0) ) { Phase=0; ProfitPoints=(TP1+", "+TP2+", "+TP3); } else if((opLongLots >Lots/2 && opShortLots==0) || (opShortLots>Lots/2 && opLongLots ==0)) { Phase=1; ProfitPoints=(TP2+", "+TP3); } else if((opLongLots =3) ProfitPoints="k.A."; */ // ---------------------------------- // --------- DayTradingClose -------- // ---------------------------------- if(ClosingHour!=0) { if (OrderType()==OP_BUY && Hour()>=ClosingHour) OrderClose(OrderTicket(),opLongLots,Bid,0); // nicht: OrderLots() 0.1 if (OrderType()==OP_SELL && Hour()>=ClosingHour) OrderClose(OrderTicket(),opShortLots,Ask,0); // nicht: OrderLots() 0.1 } // if(ClosingHour!=0) // ---- } // if (OrderSymbol() } // for (int cnt } // if (cntOpPos>0) //---- return(0); } // int start() // ----------------------------------- // ---- modLots (MoneyManagement) ---- // ----------------------------------- double modLots(double varLots) { double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP); double tempDouble = varLots + lotStep/2; tempDouble /= lotStep; int tempInt = tempDouble; return (tempInt*lotStep); } // ******************************************************************************