//+------------------------------------------------------------------+
//| 00000000.mq4 |
//| Copyright 2022, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
extern int MagicNumber=10001;
extern double Lots =0.01;
extern double TakeProfit=50;
extern int Slippage=3;
void OnTick()
{
double buyticket = 0;
double lastbuy = 0;
double buytarget = 0;
double buyprofit = 0;
datetime buydate = 0;
double sellticket = 0;
double lastsell = 0;
double selltarget = 0;
double sellprofit = 0;
datetime selldate = 0;
double buystop = 0;
double sellstop = 0;
double buytp = 0;
double selltp =0;
double buylots=0;
double selllots=0;
double buysl=0;
double sellsl=0;
double speared = DoubleToStr(Ask-Bid,Digits);
for (int cntl = 0; cntl < OrdersTotal(); cntl++){
if(OrderSelect(cntl,SELECT_BY_POS,MODE_TRADES) && OrderMagicNumber()== MagicNumber){
//buy details
if(OrderMagicNumber()== MagicNumber && OrderType() == OP_BUY){
buyticket = OrderTicket();
lastbuy = OrderOpenPrice();
buydate = OrderOpenTime();
buyprofit = OrderProfit();
buytp = OrderTakeProfit();
buysl = OrderStopLoss();
buylots = OrderLots();}
//buystop details
if(OrderMagicNumber()== MagicNumber && OrderType() == OP_BUYSTOP){
buystop = OrderTicket();
}
//sell details
if(OrderMagicNumber()== MagicNumber && OrderType() == OP_SELL){
sellticket = OrderTicket();
lastsell = OrderOpenPrice();
selldate = OrderOpenTime();
sellprofit = OrderProfit();
selltp = OrderTakeProfit();
sellsl = OrderStopLoss();
selllots = OrderLots();}
}
//sellstop details
if(OrderMagicNumber()== MagicNumber && OrderType() == OP_SELLSTOP){
sellstop = OrderTicket();
}
}
double lotsb = DoubleToStr(buylots*1.5,2);
double lotss = DoubleToStr(selllots*1.5,2);
double accountplus2 = AccountProfit();
if(OrdersTotal() == 0){
OrderSend(Symbol(),OP_BUY,0.01,Ask,Slippage,Ask-0.003,Ask+0.002,"SELL_Double_Order_EA",MagicNumber,0,Green);
OrderSend(Symbol(),OP_SELLSTOP,0.02,Ask-0.001,Slippage,Ask+0.002,Ask-0.003,"SELL_Double_Order_EA",MagicNumber,0,Blue);
}
double pending =0;
if(buyticket < 1 && sellticket < 1){
pending = 1;
OrderDelete(buystop);
OrderDelete(sellstop);
}
double pending1 =0;
if(buystop < 1 && sellstop < 1){
pending1 = 1;
if(selldate > buydate){
OrderSend(Symbol(),OP_BUYSTOP,lotss,lastbuy,Slippage,buysl,buytp,"SELL_Double_Order_EA",MagicNumber,0,Blue);
}
if(buydate > selldate){
OrderSend(Symbol(),OP_SELLSTOP,lotsb,lastsell,Slippage,sellsl,selltp,"SELL_Double_Order_EA",MagicNumber,0,Blue);
}
}
Comment(" Account Balance ", AccountBalance() ," Equity " , AccountEquity(), " speard ", speared," ask ",Ask,
"\n boy order ", buyticket, " last buy price " ,lastbuy , " buy target ", buytarget," buy profit ",buyprofit," buy date ",buydate,
"\n sell order ",sellticket, " last sell price ",lastsell,"sell target", selltarget," sell profit ",sellprofit," sell date ",selldate, " aplus2 ",accountplus2, " order count ",OrdersTotal(),
"\n buystop ",buystop , " sellstop ",sellstop, " pending ",pending , " buytp ",buytp, " sell tp ",selltp,
"\n buylots ",buylots," lotsb ", lotsb," buysl ",buysl, " selllots ",selllots," lotss ", lotss," sell sl ",sellsl);
//-----------------------------------
}