Friday 9 November 2012

Cara protect EA



1. Password protection code:
Metode ini banyak di gunakan untuk memprotect EA.
Cara kerjanya dengan memberikan password untuk melock ea kita. Code ini dapat digunakan:
int start()
{extern string Please_Enter_Password = "0";// your code here....int start()
{if (password != "indo.mt5") //change to the password you give the user!
{Alert ("Wrong password!");return (0); }// your code here....}
Pada code diatas password yang digunakan adalah “indo.mt5″ dimana sudah di tuliskan di dalam MQL4 file dan kita hanya tinggal mengcompile program kita.
2. Trial period protection:
Memberikan batas waktu bagi user sehingga bila mencapai limit waktu penggunaan maka EA tidak dapat berfungsi lagi.
int start()
{string expire_date = "2006.31.06"; //<-- hard coded datetimedatetime e_d = StrToTime(expire_date);
if (CurTime() >= e_d){Alert ("The trial version has been expired!");return(0);}// your normal code!return(0);}
3. Limited account number protection:
Digunakan untuk menglock penggunaan EA pada account tertentu saja.
int start()
{
int hard_accnt = 11111; //<-- type the user account here before compilingint accnt = AccountNumber();
if (accnt != hard_accnt){Alert ("You can not use this account (" + DoubleToStr(accnt,0) + ") with this program!");return(0);}// your normal code!return(0);}
4. Limited account type protection:
Cara ini membatasi user hanya pada demo account saja.
int start()
{
bool demo_account = IsDemo();
if (!demo_account){Alert ("You can not use the program with a real account!");return(0);}// your normal code!return(0);}
5. DLL protection:
Metode ini dengan menuliskan DLL dan di export ke dalam MQL4 kita.
SEMUA EA INDI DAN SCRIPT SAYA KUMPULKAN DARI FORUM” TERBUKA, NAMUN APABILA ADA KETIDAKNYAMANAN SAYA MOHON MAAF

ANEKA SCRIPT ORDER DENGAN RISK MANAGEMENT


SCRIPT ORDER DENGAN RISK MANAGEMENT
::::BUY SCRIPT:::::
//+------------------------------------------------------------------+
//| Buy with MM |
//| Copyright © 2011, Rubianto |
//| Rubi_Sniper |
//+------------------------------------------------------------------+
#property copyright "Copyright © Rubi_Sniper_2011"
#property link "rubianto.md@gmail.com"
//#property show_inputs
extern double Lots = 1;
extern bool UseMoneyMgmt = true;
extern double RiskPercent = 5;
extern bool UseStop = true;
extern bool UseTakeProfit = true;
extern double StopLoss = 30;
extern double TakeProfit = 5;
extern string Note="0 in Entry field means Market Order Buy";
extern double Entry = 0.0000;
string Input = " Buy Price ";
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
double Risk = RiskPercent / 100;
if (UseMoneyMgmt)
Lots = NormalizeDouble( AccountBalance()*Risk/StopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);
int Mode = OP_BUYSTOP;
if (Ask > Entry && Entry > 0) Mode = OP_BUYLIMIT;
if (Entry == 0) {Entry = Ask; Mode = OP_BUY;}
double SLB = Entry - StopLoss*Point, TPB = Entry + TakeProfit*Point;
if (UseStop == false) SLB = 0;
if (UseTakeProfit == false) TPB = 0;
if(Lots > 0)
OrderSend(Symbol(),Mode, Lots, Entry, 2,SLB , TPB, "Rubi_Sniper_BUY", 0, NULL, LimeGreen);
return(0);
}
//+------------------------------------------------------------------+
::::SELL SCRIPT::::
//+------------------------------------------------------------------+
//| Sell with MM |
//| Copyright © 2011, Rubianto |
//| Rubi_Sniper |
//+------------------------------------------------------------------+
#property copyright "Copyright © Rubi_Sniper_2011"
#property link "rubianto.md@gmail.com"
//#property show_inputs
extern double Lots = 1;
extern bool UseMoneyMgmt = True;
extern double RiskPercent = 5;
extern bool UseStop = true;
extern bool UseTakeProfit = true;
extern double StopLoss = 30;
extern double TakeProfit = 5;
extern string Note="0 in Entry field means Market Order Sell";
extern double Entry = 0.0000;
string Input = " Sell Price ";
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
double Risk = RiskPercent / 100;
if (UseMoneyMgmt)
Lots = NormalizeDouble( AccountBalance()*Risk/StopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);
int Mode = OP_SELLSTOP;
if (Bid < Entry && Entry > 0) Mode = OP_SELLLIMIT;
if (Entry == 0) {Entry = Bid; Mode = OP_SELL;}
double SLS = Entry+StopLoss*Point, TPS = Entry - TakeProfit * Point;
if (UseStop == false) SLS = 0;
if (UseTakeProfit == false) TPS = 0;
if(Lots > 0)
OrderSend(Symbol(),Mode, Lots, Entry, 2, SLS, TPS, "Rubi_Sniper_SELL",0, NULL, Red);
return(0);
}
//+------------------------------------------------------------------+
Script Buy n Sell dari bos Fkipoi Rian duet Taufik Kiads
SCRIPT BUY :
//====================================================
//IA1_script_buy_multiple.mq4
//depok.investor@gmail.com
//Note: Adjust lot1,takeprofit1 and stoploss1 as u like
//build:31/10/2011 taufik
//====================================================
#property copyright "IA1_2011"
#property link "depok.investor@gmail.com"
double lot1 =1.0;
int total_entry =5;
int takeprofit1 =5;
int stoploss1 =0;
int slippage1 =5;
int repeat =1;
int start()
{
while (repeat<=total_entry)
{
buy(lot1,takeprofit1,stoploss1,slippage1);
Sleep(1000);
int err=GetLastError();
if (err==0) {repeat++;}
else {repeat=repeat;}
}
}
void buy(double lot, double tp, double sl, int slip)
{
double askprice = Ask;
if (tp>0)tp = askprice + (tp * Point);
if (sl>0)sl = askprice - (sl *Point);
OrderSend(Symbol(), OP_BUY, lot, askprice, slip, sl, tp, "IA1_Buy-"+repeat, 0, 0, Blue);
return(0);
}
SCRIPT SELL :
//====================================================
//IA1_script_sell_multiple.mq4
//depok.investor@gmail.com
//Note: Adjust lot1,takeprofit1 and stoploss1 as u like
//build:31/10/2011 taufik
//====================================================
#property copyright "IA1_2011"
#property link "depok.investor@gmail.com"
double lot1 =1.0;
int total_entry =5;
int takeprofit1 =5;
int stoploss1 =0;
int slippage1 =5;
int repeat =1;
int start()
{
while (repeat<=total_entry)
{
sell(lot1,takeprofit1,stoploss1,slippage1);
Sleep(1000);
int err=GetLastError();
if (err==0) {repeat++;}
else {repeat=repeat;}
}
}
void sell(double lot, double tp, double sl, int slip)
{
double bidprice = Bid;
if (tp>0) tp = bidprice - (tp * Point);
if (sl>0) sl = bidprice + (sl * Point);
OrderSend(Symbol(), OP_SELL, lot, bidprice, slip, sl, tp, "IA1_Sell-"+repeat, 0, 0, Red);
return(0);
}

Script Close order lengkap n muantap


##script Close order lengkap n muantap
//+------------------------------------------------------------------+
//| Close order lengkap n muantap.mq4 |
//| Oprekan by Bambang Sugianto |
//+------------------------------------------------------------------+
#property copyright "Bambang Sugianto"
#property show_inputs
#include
//+------------------------------------------------------------------+
//| input parameters: |
//+------------------------------------------------------------------+
extern bool CloseAllSymbols = false;
extern string Important = "Select one of the following:";
extern bool CloseOpenOrdersAndCancelPending = true;
extern bool CloseOpenOrders = false;
extern bool DeleteAllPendingOrders = false;
extern bool CloseOrdersWithPlusProfit = false;
extern bool CloseOrdersWithMinusProfit = false;
extern bool CloseOrdersOpenedBeforeToday = false;
//+------------------------------------------------------------------+
//| global variables to program: |
//+------------------------------------------------------------------+
double Price[2];
int giSlippage;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
void start() {
int iOrders=OrdersTotal()-1, i;
if(CloseOpenOrdersAndCancelPending) {
for(i=iOrders; i>=0; i--) {
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
if ( OrderSymbol()==Symbol() || CloseAllSymbols == true ) {
if((OrderType()<=OP_SELL) && GetMarketInfo()) {
if(!OrderClose(OrderTicket(),OrderLots(),Price[1-OrderType()],giSlippage)) Print(OrderError());
}
else if(OrderType()>OP_SELL) {
if(!OrderDelete(OrderTicket())) Print(OrderError());
}
}
}
}
}
if(CloseOpenOrders) {
for(i=iOrders; i>=0; i--) {
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
if ( OrderSymbol()==Symbol() || CloseAllSymbols == true ) {
if((OrderType()<=OP_SELL) && GetMarketInfo()) {
if(!OrderClose(OrderTicket(),OrderLots(),Price[1-OrderType()],giSlippage)) Print(OrderError());
}
}
}
}
}
if(DeleteAllPendingOrders) {
for(i=iOrders; i>=0; i--) {
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
if ( OrderSymbol()==Symbol() || CloseAllSymbols == true ) {
if(OrderType()>OP_SELL) {
if(!OrderDelete(OrderTicket())) Print(OrderError());
}
}
}
}
}
else if(CloseOrdersWithPlusProfit) {
for(i=iOrders; i>=0; i--) {
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderProfit() >= 0)) {
if ( OrderSymbol()==Symbol() || CloseAllSymbols == true ) {
if((OrderType()<=OP_SELL) && GetMarketInfo()) {
if(!OrderClose(OrderTicket(),OrderLots(),Price[1-OrderType()],giSlippage)) Print(OrderError());
}
}
}
}
}
else if(CloseOrdersWithMinusProfit) {
for(i=iOrders; i>=0; i--) {
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderProfit() <= 0)) {
if ( OrderSymbol()==Symbol() || CloseAllSymbols == true ) {
if((OrderType()<=OP_SELL) && GetMarketInfo()) {
if(!OrderClose(OrderTicket(),OrderLots(),Price[1-OrderType()],giSlippage)) Print(OrderError());
}
}
}
}
}
else if( CloseOrdersOpenedBeforeToday) {
datetime tTodayStart=TimeCurrent()-TimeHour(TimeCurrent())*60*60-TimeMinute(TimeCurrent())*60;
for(i=iOrders; i>=0; i--) {
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderOpenTime() < tTodayStart)) {
if ( OrderSymbol()==Symbol() || CloseAllSymbols == true ) {
if((OrderType()<=OP_SELL) && GetMarketInfo()) {
if(!OrderClose(OrderTicket(),OrderLots(),Price[1-OrderType()],giSlippage)) Print(OrderError());
}}
else if(OrderType()>OP_SELL) {
if(!OrderDelete(OrderTicket())) Print(OrderError());
}
}
}
} Alert("beres juragan...perintah CLOSE sudah terlaksana..." ); // tambahan alert
}
//+------------------------------------------------------------------+
//| Function..: OrderError |
//+------------------------------------------------------------------+
string OrderError() {
int iError=GetLastError();
return(StringConcatenate("Order:",OrderTicket()," GetLastError()=",iError," ",ErrorDescription(iError)));
}
//+------------------------------------------------------------------+
//| Function..: GetMarketInfo |
//| Returns...: bool Success. |
//+------------------------------------------------------------------+
bool GetMarketInfo() {
RefreshRates();
Price[0]=MarketInfo(OrderSymbol(),MODE_ASK);
Price[1]=MarketInfo(OrderSymbol(),MODE_BID);
double dPoint=MarketInfo(OrderSymbol(),MODE_POINT);
if(dPoint==0) return(false);
giSlippage=(Price[0]-Price[1])/dPoint;
return(Price[0]>0.0 && Price[1]>0.0);
}