[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 508
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
Could be a coincidence, but I had a 229 build at work yesterday that refused to work, installed a 402 - successfully got SL, I wish I hadn't installed it :(
Does anyone have an example of a function that closes all trades if they exceed a certain lifetime. For example, to close all trades that are open for more than one hour.
From myself, I can recommend the following - when you open an order(s) - remember its(their) characteristic(s) in some variable(s) like (their validity time...) - opening time, then compare current time with this (these) variables - if it's more than one hour - cover them all with standard f-function - everything. I.e. like this (loop through all your orders in the market and use the OrderSelect function to compare the condition:
Thank you
Does anyone have an example of a function that closes all trades if they exceed a certain lifetime. For example, to close all trades that are open for more than one hour.
https://docs.mql4.com/ru/trading/OrderOpenTime
Compare with the current time and draw conclusions.
Please tell me what to change in this code to make the EA open a sell instead of a bai and vice versa...
int X=0;
double S = 0.0000;
extern double lot=0.1;
extern double koef=1.5;
extern int SL=10;
extern int TP=10;
double dl;
double a;
int init()
{
a=lot;
return(0);
}
int deinit()
{
return(0);
}
int start()
{
S=Open[0];
Sleep(1000);
if(OrdersTotal() == 0 && X==1)
{
if(Close[0]>dl){lot=a;}
X=0;
}
if(OrdersTotal() == 0 && X==2)
{
if (Close[0]<dl){lot=a;}
X=0;
}
if(OrdersTotal() == 0 && Close[0]>S && Close[1]>Open[1])
{
dl=Close[0];
OrderSend(Symbol(),OP_BUY,lot,Ask,3,Ask-SL*0.0001,Ask+TP*0.0001,"",14774,0,Blue);
lot=lot*koef;
X=1;
}
if(OrdersTotal() == 0 && Close[0]<S && Close[1]<Open[1])
{
dl=Close[0];
OrderSend(Symbol(),OP_SELL,lot,Bid,3,Bid+SL*0.0001,Bid-TP*0.0001,"",14774,0,Red);
lot=lot*koef;
X=2;
}
return(0);
}
Can you please tell me what to change in this code to make the EA open a sell instead of a bai and vice versa...
Normally, put the code - we'll tell you... via SRC - in the editor.