//+------------------------------------------------------------------+ //| scalping.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.scalping.nm.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, MetaQuotes Software Corp." #property link "http://www.scalping.nm.ru" //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ extern int SL=57,TP=100,TS=35; extern double UDayChanel=0.004; extern int StartTime=6,EndTime=11; extern double lots=1; int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int total,cnt; double HighPrice,LowPrice,DayChanel; //---- HighPrice=iHigh(Symbol(),PERIOD_D1,0); LowPrice=iLow(Symbol(),PERIOD_D1,0); DayChanel=HighPrice-LowPrice; total=OrdersTotal(); for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { if(Hour()>EndTime) { OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); return(0); } if(TS>0) { if(Bid-OrderOpenPrice()>Point*TS) { if(OrderStopLoss()<Bid-Point*TS) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TS,OrderTakeProfit(),0,Red); return(0); } } } } else { if(Hour()>EndTime) { OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); return(0); } if(TS>0) { if((OrderOpenPrice()-Ask)>(Point*TS)) { if(OrderStopLoss()==0.0 || OrderStopLoss()>(Ask+Point*TS)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TS,OrderTakeProfit(),0,Red); return(0); } } } } } } if (Hour()>=StartTime && Hour()<EndTime) { if (AccountFreeMargin()>=2000) lots=1; if (AccountFreeMargin()>=3000) lots=1; if (AccountFreeMargin()>=4000) lots=2; if (AccountFreeMargin()>=5000) lots=3; if (AccountFreeMargin()>=6000) lots=4; if (AccountFreeMargin()>=7000) lots=5; if (AccountFreeMargin()>=8000) lots=6; if (AccountFreeMargin()>=9000) lots=7; if (AccountFreeMargin()>=10000) lots=8; if (AccountFreeMargin()>=11000) lots=9; if (DayChanel>=UDayChanel) { Print(Day(),"/",Month()," - ",Hour(),":",Minute()," - H",HighPrice," L",LowPrice," Ch",DayChanel," OB:",MathCeil(AccountFreeMargin()/1000)," LOT",lots); total=OrdersTotal(); if (total==0) { OrderSend(Symbol(),OP_SELL,lots,LowPrice,0,LowPrice+SL*Point,LowPrice-TP*Point,"Scalp",16384,0,Red); OrderSend(Symbol(),OP_BUY,1,HighPrice,0,HighPrice-SL*Point,HighPrice+TP*Point,"Scalp",16384,0,Blue); OrderSend(Symbol(),OP_BUY,lots,HighPrice,0,HighPrice-SL*Point,HighPrice+TP*Point,"Scalp",16384,0,Red); return(0); } if (total==1) { OrderSelect(1,SELECT_BY_POS,MODE_TRADES); if (OrderSymbol()==Symbol()) { if (OrderType()==OP_BUYSTOP) { OrderSend(Symbol(),OP_SELLSTOP,lots,LowPrice,0,LowPrice+SL*Point,LowPrice-TP*Point,"Scalp",16384,0,Red); OrderSend(Symbol(),OP_BUY,1,HighPrice,0,HighPrice-SL*Point,HighPrice+TP*Point,"Scalp",16384,0,Blue); } if (OrderType()==OP_SELLSTOP) { OrderSend(Symbol(),OP_BUYSTOP,lots,HighPrice,0,HighPrice-SL*Point,HighPrice+TP*Point,"Scalp",16384,0,Red); OrderSend(Symbol(),OP_BUY,1,HighPrice,0,HighPrice-SL*Point,HighPrice+TP*Point,"Scalp",16384,0,Blue); } } return(0); } if (total==2) { return(0); } } } //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Indicator Curves created:
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Checks for the total of open orders
It Closes Orders by itself
It can change open orders parameters, due to possible stepping strategy
It automatically opens orders when conditions are reached
Other Features: