[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

 
IgorM:
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 :(
Yesterday at 19-03 gmt the 225th build strangely stopped working. Communication was there, quotes were coming in, but the chart stood still. Only discovered it in the morning, "General Error" was flashing on the connection status triangles, logs from that point on are littered with memory error. Rebooted in the morning, everything went on. Going to look at all the indicators, probably the cause as build is stable.
 
Good day to all, if anyone knows the difference between a closed order tp comment and tp/a ? Can anyone give the deciphering of tp/a ?
 
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.
 
nuan:
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:
if (OrderOpenTime+1*60*60<TimeCurrent) 
    {
      //то кроете их все "стандартной" ф-ией
    }
 

Thank you

 
nuan:
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);

}

 
ALigarx:

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.
 
Roman.:

Normally, put the code - we'll tell you... via SRC - in the editor.
In my previous post I clicked on "change EA" and copied code from there, how to do it via SRC?