Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1552

 
законопослушный гражданин:

owls should open trades according to their algorithm

if stop, then the next trade with a martin, and so on until the number of multiplications I have specified (function -OrdersClose = .....;).

further on, if owl is disabled along with the terminal, just press "auto-trade" button with another owl, then the next trade will start with the starting lot, not with the last one increased by a martingale.

It would also be nice to attach a schedule to it, but this idea has only just occurred to me.

For example: it was activated at 10-00 on Monday with starting lot, then it was switched off during the day when some result was achieved, and on Tuesday morning it was activated at 10-00 and started with starting lot again.

everything.

how to deal with this issue to the end?

 
законопослушный гражданин:

how do you get to the bottom of this question?

You answer it, you answer it,

but you disappear and then you get the same questions again.

 
MakarFX:

you answer, you answer,

but you disappear and then you get the same questions again.

You showed me to create a global variable, I tried it but then I have a question

i'm not good at this yet. i already have a datetime OpenTime; - should i replace it witha datetimeStart or in addition?

"and then if there are no open/closed orders later "Start "Lots=Lot;"- it's not at all clear where to refer to?

Then you asked for a brief description of the logic of owl, what I want from it.

your question how to automatically reset lot on shutdown has not yet been answered.

 
законопослушный гражданин:

You showed me to create a global variable, I tried it but then I have a question

i am not good at this yet. i already have datetime OpenTime; - should i replace it withdatetimeStart or in addition?

"and then if there are no open/closed orders later "Start "Lots=Lot;"- it's not at all clear where to refer to?

Then you asked me to briefly describe the logic of the owl, what I want from it.

When I asked how to make the automatic lot reset on shutdown, I didn't get an answer.

When I asked for a description of the logic of the EA, I didn't mean the problem encountered, but the general actions

for example:

if there is a signal, we open an order

if the order closes with a profit, we will wait for a new signal

if the order closed with a loss, then increase the lot and wait for a new signal


I do not need your strategy, I just need to understand what the EA should do.

 
законопослушный гражданин:

You showed me to create a global variable, I tried it but then I have a question

i am not good at this yet. i already have datetime OpenTime; - should i replace it withdatetimeStart or in addition?

"and then if there are no open/closed orders later "Start "Lots=Lot;"- it's not at all clear where to refer to?

Then you asked me to briefly describe the logic of the owl, what I want from it.

I haven't got an answer to my question how to do automatic lot reset on shutdown.

Here is the function for starters:

//+----------------------------------------------------------------------------+
//|  Размер лота/профита и время последней закрытой позиции                    |
//|  1 - возвращает размер лота                                                |
//|  2 - возвращает размер профита с учетом комиссии и свопа                   |
//|  3 - возвращает время закрытия ордера                                      |
//+----------------------------------------------------------------------------+
double GetInfoLastPos(int a=1)
  {
   datetime t=0;
   double result=0,l=0,p=0;
   int i=OrdersHistoryTotal();

   for(int pos=0; pos<i; pos++)
     {
      if(OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY))
        {
         if((OrderSymbol()==_Symbol)&&(OrderMagicNumber()==Magic))
           {
            if(OrderType()==OP_BUY || OrderType()==OP_SELL)
              {
               if(t<OrderCloseTime()) {t=OrderCloseTime(); l=OrderLots(); p=OrderProfit()+OrderCommission()+OrderSwap();}
              }
           }
        }
     }
   if(a==1) {result=l;} else
   if(a==2) {result=p;} else
   if(a==3) {result=(double)t;}
   else     {result=0;}
   return(result);
  }

if an order is at a loss

   if(GetInfoLastPos(2)<0)
     {Lots=NormalizeDouble(GetInfoLastPos(1)*K_Martin,DigitsLot);}
   else 
     {Lots=NormalizeDouble(Lot,DigitsLot);}
 

Regarding

datetime Start;

int OnInit()
{
   Start=TimeCurrent();
.....................
}
void OnTick()
{
   if (!IsTradeAllowed()) 
   {
      DrawLABEL("Торговля",0,0,0,Red,"Торговля запрещена");
      Start=TimeCurrent();
      return;
   } 
.....................
}

if the time of the last closed order is less than the Start time of the advisor

   if(GetInfoLastPos(3)<Start)
     {Lots=NormalizeDouble(Lot,DigitsLot);}
 
MakarFX:

When I asked for a description of the EA's logic, I was not referring to the problem encountered, but to general actions

for example:

if there is a signal, we open an order

if the order closes with a profit, we will wait for a new signal

if the order closed with a loss, then increase the lot and wait for a new signal


I do not need your strategy, I just need to understand what the EA should do.

if there is a signal, then we open an order with the first lot

if the order closed in profit, we will wait for a new signal

if the order closed with a loss, then increase the lot and wait for a new signal

if profit reaches xxxx(in the deposit currency), the advisor closes all deals and resets the lot to the initial one

if loss reached yuu (in the currency of the deposit) advisor closes all deals and res ets the lot to the starting one

if advisor was switched off and then on again - if there is a signal, we open an order with the starting lot

right?

 
законопослушный гражданин:

if there is a signal, we open an order with a starting lot

if the order closed with a profit, we wait for a new signal

If the order closed with a loss, then increase the lot and wait for a new signal

if profit reaches xxxx(in the deposit currency), the advisor closes all deals and resets the lot to the initial one

if loss reached yuu (in the currency of the deposit) advisor closes all deals and res ets the lot to the starting one

if advisor was switched off and then on again - if there is a signal, we open an order with the starting lot

like this?

Yes, like this.

What if the EA was disabled and then enabled again, and there is an open order?

 
MakarFX:

Yes, it is.

What if the EA is switched off and then switched back on and there is an open order?

If the EA is switched off, then before it is switched off, it closes all open orders, regardless of whether they are in profit or loss,

When the owl is switched on again, the "blank field", the starting lot, will be closed.

Indicator that gives a signal to open, in the example was RSI but I assume to test three different owls on different indicators.

So if i have an example code for the above logic, i hope i will be able to rework other EA's codes myself, they are open source and available for free.

 
законопослушный гражданин:

If owls are switched off, then before they are switched off they close all open orders, regardless of whether they are in profit or loss,

The indicator that gives the signals to open was RSI, but I assume that it has been cleared.

Indicator that gives a signal to open, in the example was RSI but I assume to test three different owls on different indicators.

So if i have an example code for the above logic, i hope i will be able to rework other EAs' codes myself, i hope they are open source and available for free.

and owl.turns off when you change timeframe, communication problems, and 100500 and one more reason...

the EA has to be restarted because it is the natural essence of the EA

Reason: