int y; int totalOrders = 4; datetime toT; // Time of Trade datetime doT; // Day of Trade datetime now = TimeCurrent(); datetime boD=now-now%86400; // Beginning of day
for(y=0;y<totalOrders; y++) {
if(OrderSelect(y,SELECT_BY_POS,MODE_HISTORY)) { toT=OrderOpenTime(); // Time of Trade doT=toT-toT%86400; // Day of Trade. if(doT==boD) { // Time of Trade within Current Day.
for(j=OrdersTotal()-1;j>=0; j--) { if(OrderType()==OP_BUY) totalOrders++; // Check # of long trades. if(OrderType()==OP_SELL) totalOrders++; // Check # of short trades }
In order to check both history (for orders closed at the current day) and opened orders, try like this :
datetime today = StringToTime(TimeToString(TimeCurrent(),TIME_DATE)); int totalOrdersLong = 0, totalOrdersShort = 0; for(int y=OrdersHistoryTotal()-1;y>=0; y--) { if (OrderSelect(y,SELECT_BY_POS,MODE_HISTORY)) if (OrderCloseTime()>=today) { if (OrderType()==OP_BUY) totalOrdersLong++; if (OrderType()==OP_SELL) totalOrdersShort++; } } for(int y=OrdersTotal()-1;y>=0; y--) { if (OrderSelect(y,SELECT_BY_POS,MODE_TRADES)) if (OrderOpenTime()>=today) { if (OrderType()==OP_BUY) totalOrdersLong++; if (OrderType()==OP_SELL) totalOrdersShort++; } }
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi Mladen, I have downloaded your
stepma_pdf_4_4.ex4 as well as the histgram,
copied them into MT4. Draging them onto the chart window
I get the following message, pls see in the image:
Would you tell me how I can use your indicator?
Lea
ps. the same happend with: averages_-_mtf__alerts_7_4.ex4 and histogram
Use these :
Use these :
Thank you again!! , when you have some spare time ... hope you like fish
Lea
Thank you again!! , when you have some spare time ... hope you like fish
Lea
hello mr mladen:
please update it
regard
hello mr mladen:
please update it
regard
Try now.
Try now.
Which one of fish,the laying near around ?
Do you have only 1 order (same magic,symbol I mean) opened at the same time?
If yes, then it will work.
Hi Mladen,
thank you for your advise. Yes the EA will just trade one position.
I will implement the code and run some tests with it..
Have a nice week.
hi---
can any1 make a code (indicator or script ) makes mt4 holidays as empty candle --at axis's time---
Good Luck to all
Dear pro-coders,
I would like to implement "four trades per day" feature into my EA. If the maximum trade limit
is reached the EA should wait until the next day to continue trading.
I wonder if someone could review my code, I have a bit of a "brain freeze" here... ;-)
Thank you in advance!
extern int MaxLongTrades = 2;
// Count Trades per Day.
int y;
int totalOrders = 4;
datetime toT; // Time of Trade
datetime doT; // Day of Trade
datetime now = TimeCurrent();
datetime boD=now-now%86400; // Beginning of day
for(y=0;y<totalOrders; y++)
{
if(OrderSelect(y,SELECT_BY_POS,MODE_HISTORY))
{
toT=OrderOpenTime(); // Time of Trade
doT=toT-toT%86400; // Day of Trade.
if(doT==boD)
{ // Time of Trade within Current Day.
for(j=OrdersTotal()-1;j>=0; j--)
{
if(OrderType()==OP_BUY) totalOrders++; // Check # of long trades.
if(OrderType()==OP_SELL) totalOrders++; // Check # of short trades
}
}
}
}
if(totalOrders<MaxLongTrades && Indicator_LONG_signal) Order=SIGNAL_BUY;
if(totalOrders<MaxShortTrades && Indicator_SHORT_signal) Order=SIGNAL_SELL;
In order to check both history (for orders closed at the current day) and opened orders, try like this :
int totalOrdersLong = 0, totalOrdersShort = 0;
for(int y=OrdersHistoryTotal()-1;y>=0; y--)
{
if (OrderSelect(y,SELECT_BY_POS,MODE_HISTORY))
if (OrderCloseTime()>=today)
{
if (OrderType()==OP_BUY) totalOrdersLong++;
if (OrderType()==OP_SELL) totalOrdersShort++;
}
}
for(int y=OrdersTotal()-1;y>=0; y--)
{
if (OrderSelect(y,SELECT_BY_POS,MODE_TRADES))
if (OrderOpenTime()>=today)
{
if (OrderType()==OP_BUY) totalOrdersLong++;
if (OrderType()==OP_SELL) totalOrdersShort++;
}
}
if(totalOrdersLong <MaxLongTrades && Indicator_LONG_signal) Order=SIGNAL_BUY;
if(totalOrdersShort<MaxShortTrades && Indicator_SHORT_signal) Order=SIGNAL_SELL;