//+------------------------------------------------------------------+ //| 10points 3.mq4 | //| Copyright 2005, Alejandro Galindo | //| http://elCactus.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2005, Alejandro Galindo" #property link "http://elCactus.com" extern double TakeProfit =10 ; extern double Lots = 0.1 ; extern int mm=0; extern double InitialStop = 60 ; extern double TrailingStop = 20; extern int MaxTrades=3 ; extern int Pips=15; extern int SecureProfit=10; extern int AccountProtection=1; extern int OrderstoProtect=3; extern int ReverseCondition=0; extern double EURUSDPipValue=10; extern double GBPUSDPipValue=10; extern double USDCHFPipValue=10; extern double USDJPYPipValue=9.715; extern int StartYear=2005; extern int StartMonth=1; extern int EndYear=2006; extern int EndMonth=12; extern int EndHour=22; extern int EndMinute=30; extern int risk=12; extern int AccountisNormal=0; int OpenOrders=0, cnt=0; int slippage=5; double sl=0, tp=0; double BuyPrice=0, SellPrice=0; double lotsi=0, mylotsi=0; int mode=0, myOrderType=0; bool ContinueOpening=True; double LastPrice=0; int PreviousOpenOrders=0; double Profit=0; int LastTicket=0, LastType=0; double LastClosePrice=0, LastLots=0; double Pivot=0; double PipValue=0; string text="", text2=""; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- if (AccountisNormal==1) { if (mm!=0) { lotsi=MathCeil(AccountBalance()*risk/10000); } else { lotsi=Lots; } } else { // then is mini if (mm!=0) { lotsi=MathCeil(AccountBalance()*risk/10000)/10; } else { lotsi=Lots; } } if (lotsi>100){ lotsi=100; } OpenOrders=0; for(cnt=0;cntEndYear) { return(0); } if (TimeMonth(CurTime())>EndMonth ) { return(0); } } if (Symbol()=="EURUSD") { PipValue=EURUSDPipValue; } if (Symbol()=="GBPUSD") { PipValue=GBPUSDPipValue; } if (Symbol()=="USDJPY") { PipValue=USDJPYPipValue; } if (Symbol()=="USDCHF") { PipValue=USDCHFPipValue; } if (PipValue==0) { PipValue=5; } if (PreviousOpenOrders>OpenOrders) { for(cnt=OrdersTotal();cnt>=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); mode=OrderType(); if (OrderSymbol()==Symbol()) { if (mode==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,Blue); } if (mode==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,Red); } return(0); } } } PreviousOpenOrders=OpenOrders; if (OpenOrders>=MaxTrades) { ContinueOpening=False; } else { ContinueOpening=True; } if (LastPrice==0) { for(cnt=0;cnt0 and iMACD(14,26,9,MODE_MAIN,0)>iMACD(14,26,9,MODE_MAIN,1)) then OrderType=2; // if (iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,0)>iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1)) { myOrderType=2; }//BUY //if (iMACD(14,26,9,MODE_MAIN,0)<0 and iMACD(14,26,9,MODE_MAIN,0) High[0]) { myOrderType=1; }//SELL if (iSAR(NULL,0,0.001,0.1,1) >= High[1] && iSAR(NULL,0,0.001,0.1,0) < Low[0] ) { myOrderType=2; }//BUY if (ReverseCondition==1) { if (myOrderType==1) { myOrderType=2; } else { if (myOrderType==2) { myOrderType=1; } } } } // if we have opened positions we take care of them for(cnt=OrdersTotal();cnt>=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol()) { if (OrderType()==OP_SELL) { if (TrailingStop>0) { if (OrderOpenPrice()-Ask>=(TrailingStop+Pips)*Point) { if (OrderStopLoss()>(Ask+Point*TrailingStop)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderClosePrice()-TakeProfit*Point-TrailingStop*Point,800,Purple); return(0); } } } } if (OrderType()==OP_BUY) { if (TrailingStop>0) { if (Bid-OrderOpenPrice()>=(TrailingStop+Pips)*Point) { if (OrderStopLoss()<(Bid-Point*TrailingStop)) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderClosePrice()+TakeProfit*Point()+TrailingStop*Point(),800,Yellow); return(0); } } } } } } Profit=0; LastTicket=0; LastType=0; LastClosePrice=0; LastLots=0; for(cnt=0;cntOrderOpenPrice()) { Profit=Profit+(OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point; } } if (LastType==OP_SELL) { //Profit=Profit+(Ord(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_CLOSEPRICE))*PipValue*Ord(cnt,VAL_LOTS); if (OrderClosePrice()>OrderOpenPrice()) { Profit=Profit-(OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point; } if (OrderClosePrice()=(MaxTrades-OrderstoProtect) && AccountProtection==1) { //Print(Symbol,":",Profit); if (Profit>=SecureProfit) { OrderClose(LastTicket,LastLots,LastClosePrice,slippage,Yellow); ContinueOpening=False; return(0); } } if (!IsTesting()) { if (myOrderType==3) { text="No conditions to open trades"; } else { text=" "; } Comment("LastPrice=",LastPrice," Previous open orders=",PreviousOpenOrders,"\nContinue opening=",ContinueOpening," OrderType=",myOrderType,"\n",text2,"\nLots=",lotsi,"\n",text); } if (myOrderType==1 && ContinueOpening) { if ((Bid-LastPrice)>=Pips*Point || OpenOrders<1) { SellPrice=Bid; LastPrice=0; if (TakeProfit==0) { tp=0; } else { tp=SellPrice-TakeProfit*Point; } if (InitialStop==0) { sl=0; } // else { sl=SellPrice+InitialStop*Point; } else { sl=(iSAR(NULL,0,0.02,0.2,0)+5*Point); } if (OpenOrders!=0) { mylotsi=lotsi; for(cnt=1;cnt<=OpenOrders;cnt++) { if (MaxTrades>12) { mylotsi=NormalizeDouble(mylotsi*1.5,1); } else { mylotsi=NormalizeDouble(mylotsi*2,1); } } } else { mylotsi=lotsi; } if (mylotsi>100) { mylotsi=100; } OrderSend(Symbol(),OP_SELL,mylotsi,SellPrice,slippage,sl,tp,NULL,0,0,Red); return(0); } } if (myOrderType==2 && ContinueOpening) { if ((LastPrice-Ask)>=Pips*Point || OpenOrders<1) { BuyPrice=Ask; LastPrice=0; if (TakeProfit==0) { tp=0; } else { tp=BuyPrice+TakeProfit*Point; } if (InitialStop==0) { sl=0; } // else { sl=BuyPrice-InitialStop*Point; } else { sl=(iSAR(NULL,0,0.02,0.2,0)-5*Point); } if (OpenOrders!=0) { mylotsi=lotsi; for(cnt=1;cnt<=OpenOrders;cnt++) { if (MaxTrades>12) { mylotsi=NormalizeDouble(mylotsi*1.5,1); } else { mylotsi=NormalizeDouble(mylotsi*2,1); } } } else { mylotsi=lotsi; } if (mylotsi>100) { mylotsi=100; } OrderSend(Symbol(),OP_BUY,mylotsi,BuyPrice,slippage,sl,tp,NULL,0,0,Blue); return(0); } } //---- return(0); } //+------------------------------------------------------------------+j햺± uٴ|flFuszdNS6-ܘ*FuN \/ed]'4J7tUdkek6tm! RT» +HX0`HocQU .u&l rnRhuu>oQN?NafXQ.LtelglZr 7P@Ņ8~xUT_1Nq6/[}x{BWoE`QHmL^-5]KឳxqH4; 4N T(ɒz~~2ђӁa Wk5ޜxcY\3 Eۂ3 Ian$-rfM^qmTOTWDWX{h[%ٜhL1'jh _] )E J !WɎ K\E"h+;9Ge;dS*-;`[wޛ{c}/캋]{B!;.E+jq"G^Ĵ&8o2Ft[jF>@!qs_8w{c *7VdQ#[zzQ)e'sq(gCσ'3o8e;WGnTέ$|-sؚ\%C܁KWvx`ѧ0dሎ3` 8g)aHa9i0l6N(`m/G$i[ S$8,` 969+ wP"Nj ʰ܏q*N`1;ARBptȅȋSp\[B4'q!?6?E -,_zV9BAQ.F9EP4?~}#euhU/0(AtM߯p {$A9Z0uwϠ Mms_Apmp(b揼dm}(ao~?}oo8&+Vb 6~mG3օ[N_&S-cmYWI}pʓ+ao'2'riYKCV9KߍޙhRQ:* h:v烣=Q,h }.bM'+2"ZT0dWdWxWdwDQ4-T[CU" TGO/k; +rm 6EA \a%^*B)xnxv`&c㘈y?VhoGxD% 6%A0`1st%1Ӹvو6aM$%3*2`X|k#TEߐdì =} >Ha%݄_?ݟxC[{uE"!\;ăb*/evع`Ύ6)