BadOrders
Download scriptThis script is designed to automate a specific sequence of trade executions and modifications on the MetaTrader platform. Its primary logic focuses on rapid cycle management by closing existing positions and immediately placing new ones with adjusted parameters.
Here is a breakdown of how the logic functions:
Position Management The script begins by scanning the active trading list. It identifies the position currently held at the second index of the open orders and automatically closes it. This ensures that any previous trades are cleared out before the script moves on to its next objective.
Trade Execution Immediately after closing the previous position, the script generates a new "Buy Stop" order. This is a pending order placed at a price slightly above the current market price. The script sets specific parameters for this trade, including a designated volume and a unique identification label.
Dynamic Modification Once the new pending order is successfully placed into the system, the script instantly detects its unique ID. It then performs an automated modification on that specific order, shifting its entry price to a level slightly below the current market price.
Summary of Workflow In simple terms, the script follows a "clear and reposition" cycle:
- Clear: It closes an existing active trade.
- Place: It opens a new pending buy order at a higher price point.
- Adjust: It immediately moves that pending order to a lower price point to redefine the entry conditions.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| BadOrders.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
double asdf;
double ticket, t2;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
//This section closes any positions opened on the last tick
OrderSelect(1,SELECT_BY_POS);
OrderClose(OrderTicket(),1,Bid,8,Red);
ticket=OrderSend(Symbol(),OP_BUYSTOP,1,Bid+100*Point,3,0,0,"asdfasdf",16384,0,Green);
t2=OrderSelect(ticket,SELECT_BY_TICKET);
OrderModify(OrderTicket(),Bid-100*Point,0,0,0,Green);
//OrderClose(OrderTicket(),1,Bid,8,Red);
// OrderSend(Symbol(),OP_BUYSTOP,1,Bid-100*Point,3,0,0,"asdfasdf",16384,0,Green);
//----
return(0);
}
//+------------------------------------------------------------------+
Profitability Reports
Expected payoff
Average expected payoff across the available backtests for each symbol.
Comments