IDT_close_profit_positions





//+------------------------------------------------------------------+
//|                       IDT_close_profit_positions.mq4                          |
//|                      Copyright © 2004, Globus                    |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Globus"

#include <stdlib.mqh>
#include <WinUser32.mqh>

#define SLIPPAGE  1   // value of slippage

//+------------------------------------------------------------------+
//| script "intraday trading - close all profit positions"                            |
//+------------------------------------------------------------------+
int start()
  {
  PlaySound("Tick.wav");
  double sum=OrdersTotal();
  double change=0;
  Print ("Count of ticket ",sum);
 
  while (sum>0)
    {
    OrderSelect(sum-1,SELECT_BY_POS);
    Print ("Ticket : ",OrderTicket(), "  Profit :" ,OrderProfit(), "  Order type :", OrderType());
    RefreshRates();
      if (OrderProfit()>0)
      {
        if (OrderType ()==0)
         {
          OrderClose( OrderTicket(), OrderLots(), Bid, SLIPPAGE, SeaGreen);
         }
         if (OrderType ()==1)
         {
          OrderClose( OrderTicket(), OrderLots(), Ask, SLIPPAGE, SeaGreen);
         }
        change++;    
       }
 
     sum--;
    
    }
      
  Print ("Count of changes ",change);
  PlaySound("Ok.wav");
  return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:



Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:
Checks for the total of open orders

It Closes Orders by itself

Other Features:

It plays sound alerts