[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 225

 
granit77:
Take a look atthe analogues. In particular Equity_simple.mq4


Thank you! The indicator itself works in a separate window...

But what to do if you insert #property... in the standard EA, but the journal says - 2011.03.09 18:04:58 Expert 'MACD Sample' is an indicator and cannot be executed

 
Vinin:


You need to read the trades history and read the balance at the point in time when the next position was closed.

Equity is a little more complicated, but you can do exactly the same thing.

You can bring all the calculations to a standard lot or count in pips


So you don't have to read and count anything, let the indicator show everything by itself.

So how about trying to make it work?

--------------------------------------------------------------------------------------------------------------------

I've been out of the process for 3-4 hours.

 
doon:

I want a message to be displayed after closing on a stop loss, but nothing happens in mt4.

int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
string sy="NULL";
int op=-1;
int mn=-1;
bool isCloseLastPosByStop(string sy="", int op=-1, int mn=-1) {
datetime t;
double ocp, osl;
int dg, i, j=-1, k=OrdersHistoryTotal();

if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderSymbol()==sy || sy=="") {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
if (t<OrderCloseTime()) {
t=OrderCloseTime();
j=i;
}
}
}
}
}
}
}
if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {
dg=MarketInfo(sy, MODE_DIGITS);
if (dg==0) if (StringFind(OrderSymbol(), "JPY")<0) dg=4; else dg=2;
ocp=NormalizeDouble(OrderClosePrice(), dg);
osl=NormalizeDouble(OrderStopLoss(), dg);
if (ocp==osl) return(True);
}
return(False);
}
int start()
{
//----
bool stopl;
stopl = isCloseLastPosByStop(sy,op,mn);
if (stopl == true)
Alert ("последняя сделка закрылась по s/l");
//----
return(0);
}

 
kulon:


So that you don't have to read or count anything, let the indicator show everything by itself.

So how about trying to make it work?

--------------------------------------------------------------------------------------------------------------------

I've been out of the process for 3-4 hours.


Such indicators already exist
 
doon:


Advice has already been given to you on the previous page.
 
kulon:

So that you don't have to read or count anything, let the indicator show everything by itself.

meant "read by the indicator"
 

Here is the code in simplified form

Files:
33.ex4  3 kb
 
Vinin:

Indicators like this exist as it is

I've never seen one. Can you see them?
 
kulon:

I've never seen one before. Can I see it?

Look here https://www.mql5.com/ru/forum/103774
 

How do I make an EA buy or sell at a certain time(sleep not to use)?