#property copyright "Copyright © 2009, Totom Sukopratomo" #property link "forexengine@gmail.com" #define Magic 1234 #define buy -15 #define sell 15 extern double StartLot=0.1; extern int Range=20; extern int Level=15; extern double TPInMoney=10.0; //in money extern int StartHour=0; extern int EndHour=24; extern bool TradeInMonday=true; extern double MoneyTargetInMonday=100; extern double CutLossInMonday=0; extern bool TradeInTuesday=true; extern double MoneyTargetInTuesday=100; extern double CutLossInTuesday=0; extern bool TradeInWednesday=true; extern double MoneyTargetInWednesday=100; extern double CutLossInWednesday=0; extern bool TradeInThursday=true; extern double MoneyTargetInThursday=100; extern double CutLossInThursday=0; extern bool TradeInFriday=true; extern double MoneyTargetInFriday=100; extern double CutLossInFriday=0; extern bool UseMultiplier=true; extern string note="true,maka besar nextlot dikali multiplier"; extern double Multiplier=2.0; extern bool UseIncreament=false; extern string note1="true,maka besar nextlot ditambah increament"; extern double Increament=1.0; extern int MySWBStyle=2; extern string note2="0=swb GRID, 1=swb GRID 2, 2=swb GRID 3"; extern int MyTradeStyle=1; extern string note3="0=Follow Trend, 1=CounterTrend"; extern string TradeStyle_0="Follow Trend"; extern int FastMAPeriod=5; extern int SlowMAPeriod=20; extern string TradeStyle_1="Counter Trend"; extern bool UseBB=true; extern int BBPeriod=20; extern int BBDeviation=2; extern bool UseStoch=true; extern int StochKPeriod=5; extern int StochDPeriod=3; extern int StochSlowing=3; extern int UseRSI=true; extern int RSIPeriod=9; extern int HighLevel=70; extern int LowLevel=30; int total,histotal,i,jumlah,prec,type,ticket,ordercounter=0; double pt,minlot,maxlot,stoplevel,lot,openprice,profit,profitX,profitY; int totalorder() { total=OrdersTotal(); jumlah=0; for(i=0; i=0; i--) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; switch(OrderType()) { case 0: { OrderClose(OrderTicket(),OrderLots(),Bid,1,CLR_NONE); break; } case 1: { OrderClose(OrderTicket(),OrderLots(),Ask,1,CLR_NONE); break; } case 2: { OrderDelete(OrderTicket()); break; } case 3: { OrderDelete(OrderTicket()); break; } } } return(0); } double lastlot() { total=OrdersTotal(); lot=0; for(i=0; ifastma1 && fastma1>slowma1) return(buy); if(fastma0upperbb) return(sell); if(Close[0]HighLevel) return(sell); if(stochHighLevel) return(sell); if(rsiupperbb && stoch>HighLevel) return(sell); if(Close[0]upperbb && rsi>HighLevel) return(sell); if(Close[0]HighLevel && rsi>HighLevel) return(sell); if(stochupperbb && stoch>HighLevel && rsi>HighLevel) return(sell); if(Close[0]=TPInMoney) { closeorder(); } if(totalorder()==0 && lastlot()==0) { if(signal()==buy) { if(sendorder(0,StartLot,Ask,Blue)>0) return(0); } if(signal()==sell) { if(sendorder(1,StartLot,Bid,Red)>0) return(0); } } if(totalorder()>0 && totalorder()openprice-Range*pt) return(0); if(UseMultiplier) { if(NormalizeDouble(StartLot*MathPow(Multiplier,totalorder()),prec)>maxlot) return(0); if(sendorder(0,NormalizeDouble(StartLot*MathPow(Multiplier,totalorder()),prec),Ask,Blue)>0) return(0); } if(UseIncreament) { if(NormalizeDouble(StartLot+(lastlot()+Increament),prec)>maxlot) return(0); ticket=sendorder(0,NormalizeDouble(lastlot()+Increament,prec),Ask,Blue); } } if(type==1) { if(Bidmaxlot) return(0); if(sendorder(1,NormalizeDouble(StartLot*MathPow(Multiplier,totalorder()),prec),Bid,Red)>0) return(0); } if(UseIncreament) { if(NormalizeDouble(StartLot+(lastlot()+Increament),prec)>maxlot) return(0); if(sendorder(1,NormalizeDouble(StartLot+(Increament*i),prec),Bid,Blue)>0) return(0); } } } return(0); } int manageorder1() { if(totalorder()==0) ordercounter=0; histotal=OrdersHistoryTotal(); total=OrdersTotal(); profit=0; for(i=histotal-ordercounter; i=TPInMoney) { closeorder(); } if(totalorder()==0 && lastlot()==0 && ordercounter==0) { if(signal()==buy) { ticket=sendorder(0,StartLot,Ask,Blue); if(ticket>0) { ordercounter++; return(0);} } if(signal()==sell) { ticket=sendorder(1,StartLot,Bid,Red); if(ticket>0) { ordercounter++; return(0);} } } if(totalorder()>0 && totalorder()openprice-Range*pt) return(0); if(UseMultiplier) { if(NormalizeDouble(StartLot*MathPow(Multiplier,ordercounter),prec)>maxlot) return(0); ticket=sendorder(0,NormalizeDouble(StartLot*MathPow(Multiplier,ordercounter),prec),Ask,Blue); if(ticket>0) { ordercounter++; total=OrdersTotal(); for(i=0; imaxlot) return(0); ticket=sendorder(0,NormalizeDouble(lastlot()+Increament,prec),Ask,Blue); if(ticket>0) { ordercounter++; total=OrdersTotal(); for(i=0; imaxlot) return(0); ticket=sendorder(1,NormalizeDouble(StartLot*MathPow(Multiplier,ordercounter),prec),Bid,Red); if(ticket>0) { ordercounter++; total=OrdersTotal(); for(i=0; imaxlot) return(0); ticket=sendorder(1,NormalizeDouble(StartLot+(Increament*ordercounter),prec),Bid,Blue); if(ticket>0) { ordercounter++; total=OrdersTotal(); for(i=0; i=TPInMoney) { closeorder(); } if(totalorder()==0 && lastlot()==0) { if(signal()==buy) { if(sendorder(0,StartLot,Ask,Blue)>0) return(0); } if(signal()==sell) { if(sendorder(1,StartLot,Bid,Red)>0) return(0); } } if(totalorder()==1 && lastlot()==StartLot) { type=-1; openprice=0; total=OrdersTotal(); for(i=0; imaxlot) return(0); sendorder(2,NormalizeDouble(StartLot*MathPow(Multiplier,i),prec),Ask-((Range*i)*pt),Blue); } if(UseIncreament) { if(NormalizeDouble(StartLot+(Increament*i),prec)>maxlot) return(0); sendorder(2,NormalizeDouble(StartLot+(Increament*i),prec),Ask-((Range*i)*pt),Blue); } } } if(type==1) { for(i=1; i<=Level; i++) { if(UseMultiplier) { if(NormalizeDouble(StartLot*MathPow(Multiplier,i),prec)>maxlot) return(0); sendorder(3,NormalizeDouble(StartLot*MathPow(Multiplier,i),prec),Bid+((Range*i)*pt),Red); } if(UseIncreament) { if(NormalizeDouble(StartLot+(Increament*i),prec)>maxlot) return(0); sendorder(3,NormalizeDouble(StartLot+(Increament*i),prec),Bid+((Range*i)*pt),Blue); } } } } return(0); } int init() { if(Digits==3 || Digits==5) pt=10*Point; else pt=Point; minlot=MarketInfo(Symbol(),MODE_MINLOT); if(minlot==0.01) prec=2; else if(minlot==0.1) prec=1; else prec=0; if(StartLot<=minlot) StartLot=minlot; stoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL); if(Range<=stoplevel) Range=stoplevel; maxlot=MarketInfo(Symbol(),MODE_MAXLOT); return(0); } int deinit() { Comment(""); return(0); } int start() { if((TimeHour(TimeCurrent())=EndHour) && totalorder()==0) { Comment("\nBELUM JAMNYA TRADING........"); return(0); } if(DayOfWeek()==1 && !TradeInMonday) { Comment("\nTIDAK TRADING DI HARI SENIN....."); return(0); } if(DayOfWeek()==2 && !TradeInTuesday && totalorder()==0) { Comment("\nTIDAK TRADING DI HARI SELASA...."); return(0); } if(DayOfWeek()==3 && !TradeInWednesday && totalorder()==0) { Comment("\nTIDAK TRADING DI HARI RABU...."); return(0); } if(DayOfWeek()==4 && !TradeInThursday && totalorder()==0) { Comment("\nTIDAK TRADING DI HARI KAMIS...."); return(0); } if(DayOfWeek()==5 && !TradeInFriday && totalorder()==0) { Comment("\nTIDAK TRADING DI HARI JUMAT....."); return(0); } if(DayOfWeek()==1) { if(profitoftheday(1)>=MoneyTargetInMonday && totalorder()==0) { Comment("\nTARGET HARI INI TERCAPAI"); return(0); } if(AccountEquity()<=CutLossInMonday) { Comment("\nHARI INI CUTLOSS"); closeorder(); return(0); } } if(DayOfWeek()==2) { if(profitoftheday(2)>=MoneyTargetInTuesday && totalorder()==0) { Comment("\nTARGET HARI INI TERCAPAI"); return(0); } if(AccountEquity()<=CutLossInTuesday) { Comment("\nHARI INI CUTLOSS"); closeorder(); return(0); } } if(DayOfWeek()==3) { if(profitoftheday(3)>=MoneyTargetInWednesday && totalorder()==0) { Comment("\nTARGET HARI INI TERCAPAI"); return(0); } if(AccountEquity()<=CutLossInWednesday) { Comment("\nHARI INI CUTLOSS"); closeorder(); return(0); } } if(DayOfWeek()==4) { if(profitoftheday(4)>=MoneyTargetInThursday && totalorder()==0) { Comment("\nTARGET HARI INI TERCAPAI"); return(0); } if(AccountEquity()<=CutLossInThursday) { Comment("\nHARI INI CUTLOSS"); closeorder(); return(0); } } if(DayOfWeek()==5) { if(profitoftheday(5)>=MoneyTargetInFriday && totalorder()==0) { Comment("\nTARGET HARI INI TERCAPAI"); return(0); } if(AccountEquity()<=CutLossInFriday) { Comment("\nHARI INI CUTLOSS"); closeorder(); return(0); } } Comment(""); switch(MySWBStyle) { case 0: { manageorder0(); break;} case 1: { manageorder1(); break;} case 2: { manageorder2(); break;} } return(0); }