Forum on trading, automated trading systems and testing trading strategies
When you post code please use the CODE button (Alt-S)!
- Please edit
your (original) post and use the CODE button
(Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor -
Why did you post your MT4 question in the
Root /
MT5 General section
instead of the MQL4 section,
(bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't
start, won't go in gear, no electrical, missing the key, flat tires —
meaningless.
There are no mind readers here and our crystal balls are cracked.
-
Using OrdersTotal (or OrdersHistoryTotal) directly and/or no Magic
number filtering on your OrderSelect loop means your code is incompatible
with every EA (including itself on other charts and manual trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi all,
Because i use a lot of small lotsizes 0.01 (martingale) i need a indicator that show my open positions in lotsize.
Can somebody help me with that?
I already found this code below:
//+------------------------------------------------------------------+
//| testt.mq4 |
//| Copyright 2015, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
void PrintText(string object, string text, int x, int y)
{
ObjectCreate(object, OBJ_LABEL, 0, 0, 0);
ObjectSetText(object, text, 9, "Verdana", Yellow);
ObjectSet(object, OBJPROP_CORNER, 0);
ObjectSet(object, OBJPROP_XDISTANCE, x);
ObjectSet(object, OBJPROP_YDISTANCE, y);
}
void CalculateLots()
{
double totalBuyLots = 0;
double totalSellLots = 0;
for(int i=0; i < OrdersTotal(); i++)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true)
{
//if(OrderSymbol() == Symbol())
{
if(OrderType() == OP_BUY)
totalBuyLots += OrderLots();
if(OrderType() == OP_SELL)
totalSellLots += OrderLots();
}
}
}
string sBuyText = "Total Buy = ";
sBuyText += DoubleToString(totalBuyLots, 2);
string sSellText = "Total Sell = ";
sSellText += DoubleToString(totalSellLots, 2);
PrintText("BuyObject", sBuyText, 20, 20);
PrintText("SellObject", sSellText, 20, 40);
}
int OnInit()
{
//---
CalculateLots();
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
CalculateLots();
}
//+------------------------------------------------------------------+
I tried a lot but i can't make it work! Not that good in scripts.
I hope somebody can help me.
Thanks.
Kind Regards, Hannes.