by toyolman on 19th June 2009, 03:48
Nie scrip utk memudahkan buat scalper....long, short n close all order.....
//+------------------------------------------------------------------+
//| Long SL TP(scalp).mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
extern double Lots = 0.10;
extern bool SL_option = true;
extern bool TP_option = true;
extern double SL = 30;
extern double TP = 7;
extern double Entry = 0.0000;
extern double InitialStop = 30;
//extern double TrailingStop = 30;
string Input = " Buy Price ";
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
int Mode = OP_BUYSTOP;
if (Ask > Entry && Entry > 0) Mode = OP_BUYLIMIT;
if (Entry == 0) {Entry = Ask; Mode = OP_BUY;}
double SLB = Entry - SL*Point, TPB = Entry + TP*Point;
if (SL_option == false) SLB = 0;
if (TP_option == false) TPB = 0;
if(Lots > 0)
OrderSend(Symbol(),Mode, Lots, Entry, 2,SLB , TPB, "Buy TMFx", 0, NULL, LimeGreen);
return(0);
}
//+------------------------------------------------------------------+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//+------------------------------------------------------------------+
//| Short SL TP (Scalp).mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
extern double Lots = 0.10;
extern bool SL_option = true;
extern bool TP_option = true;
extern double SL = 30;
extern double TP = 7;
extern double Entry = 0.0000;
extern double InitialStop = 30;
//extern double TrailingStop = 30;
string Input = " Sell Price ";
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
int Mode = OP_SELLSTOP;
if (Bid < Entry && Entry > 0) Mode = OP_SELLLIMIT;
if (Entry == 0) {Entry = Bid; Mode = OP_SELL;}
double SLS = Entry+SL*Point, TPS = Entry - TP * Point;
if (SL_option == false) SLS = 0;
if (TP_option == false) TPS = 0;
if(Lots > 0)
OrderSend(Symbol(),Mode, Lots, Entry, 2, SLS, TPS, "Sell TMfx",0, NULL, Red);
return(0);
}
//+------------------------------------------------------------------+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//+------------------------------------------------------------------+
//| close-all-orders.mq4 |
//| Copyright © 2005, Matias Romeo. |
//| Custom Metatrader Systems. |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Matias Romeo."
#property link "mailto:matiasDOTromeoATgmail.com"
int start()
{
int total = OrdersTotal();
for(int i=total-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
int type = OrderType();
bool result = false;
switch(type)
{
//Close opened long positions
case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
break;
//Close opened short positions
case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
break;
//Close pending orders
case OP_BUYLIMIT :
case OP_BUYSTOP :
case OP_SELLLIMIT :
case OP_SELLSTOP : result = OrderDelete( OrderTicket() );
}
if(result == false)
{
Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
Sleep(3000);
}
}
return(0);
}