c orders counter

c orders counter
Download ALL MT4 scripts (422)
YouTube Video Thumbnail



Similar MetaTrader Tools

c orders counter

Info

The c orders counter is a Script for MetaTrader 4 that descripition:the class corderscounter was developed for counting of the orders with different filters: by symbol of currency, magic number, either closed, either opened orders. below is description of the public methods of this class.

Usage

This tool is typically used for enhancing chart analysis and decision making.

Platform

This Script works exclusively on MetaTrader 4 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL4/Scripts folder via File ? Open Data Folder in MetaTrader 4.


How to Install and Use c orders counter

1. Installation: Move your script file into the MQL/Scripts directory and restart the platform.

2. Execution: Drag the script onto a chart; it will perform a one-time action, such as closing all open orders or clearing chart objects.

3. Editing: Use MetaEditor (F4) to modify code, click "Compile," and verify no errors appear in the terminal before running.

4. Removing: Scripts stop automatically, but you can remove them manually by right-clicking the chart and choosing "Remove Script."

Frequently Asked Questions

Q: How are scripts different from EAs? A: Scripts execute a single action and then stop; EAs monitor the market and trade continuously.

Q: Can I assign a hotkey to a script? A: Yes, right-click the script in the Navigator, select "Set Hotkey," and define your preferred keyboard shortcut.

Q: Why did my script stop? A: Scripts are designed to stop immediately after finishing their programmed command; this is normal behavior.

What this tool does

descripition:the class corderscounter was developed for counting of the orders with different filters: by symbol of currency, magic number, either closed, either opened orders.

Typical Use Case

This Script excels in automated trading and technical analysis on MetaTrader 4.

Compatible Platform & Setup

This Script works on MetaTrader 4. Place the file in the MQL4/Scripts folder and restart the terminal.

Description & Settings

Related: script to close all orders - another powerful script for MetaTrader 4 traders.



descripition:

the class
corderscounter
was developed for counting of the orders with different filters: by symbol of currency, magic number, either closed, either opened orders.

Also recommended: trailing stop for all orders - similar script with strong performance on MetaTrader 4.


below is description of the public methods of this class.

constructors:

method

description

 
corderscounter(void)

constructor by default.

corderscounter(int magic, string symbol, int counter_mode = mode_trades)

parameters:

magic
- integer value of  magic number for for the filtering of the orders. when magic = 0 is not used.

symbol
- symbol of the instrument. when symbol =  "" is not used.

counter_mode
- the pool of the orders (either closed, either opened orders). allows 2 values: mode_trades (by default) - opened orders, mode_history - closed orders.

methods:

method

 description

void refreshdata(void)

the method renews data for orders. this method must called before the calling getorderscount(), gettotalprofit(), getmarketvolume(), gettotalvolume().

int getorderscount(int type)

the method returns orders count of defined type. parameters:
 type - type of the orders. allowed values:

 op_buy - market buy orders,
 op_sell - market sell orders,
 op_selllimit - sell limit orders,
 op_buylimit - buy limit orders,
 op_sellstop - sell stops orders,
 op_buystop - buy stop orders.
 when type = -1, the method will return total count of all orders.

int getlastorder()

returns ticket number of last closed/opened order from the retrieved list.

int getfirstorder()

returns ticket number of  first closed/opened order from the retrieved list.

profitdata gettotalprofit()

returns an instance of the struct profitdata, containing total profit/loss of the retrieved list.
the struct
profitdata
contains fields:

double currency - profit/loss in currency
double points - profit/loss in points

double getmarketvolume()

 returns the total volume of the market trades of the retrieved list.

double gettotalvolume()

 returns the total volume for all orders of of the retrieved list.

void setmagicnumber(int magic)

 sets magic number

value. parameters:
magic
- new value  for magic number.

void setsymbol(string symbol)

 sets symbol value. parameters:
symbol
- new symbol value of currency.

void setmode(int mode)

 set pool. parameters:
mode
- the pool type: mode_trades - opened orders, mode_history - closed orders.

int getmagicnumber()

 returns value of magic (magic number) for the filtering of the orders.

string getsymbol()

 returns value of symbol.

int getmode()

 return type of current pool for orders filtering: mode_trades - opened orders, mode_history - closed orders.

You may also like: scripts for placing stop and limit orders - excellent alternative for script users on MetaTrader 4.

Source Code

#property copyright "robotfx"
#property link "https://robotfx.org"
#property strict
#property version   "1.00"
struct profitdata
{
public:
   double currency;
   double points;
};

.......

Leave your opinion, ask a question, share some knowledge

Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.