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

 

I'm just learning.

SellClose = (AC<0.0 && RSI<30 && Open[1]>Close[1] && ? );

Instead of the question mark you should write - profit is greater than zero for the given instrument.

 
cashnewmoney:

I'm just learning.

SellClose = (AC<0.0 && RSI<30 && Open[1]>Close[1] && ? );

Instead of the question mark you should write - profit is greater than zero for the given instrument.

It depends on your own desire.
 
Alexey Viktorov:
It depends on your own will.

Like close with your hands.

That's no good, you have to automate it.

 
cashnewmoney:

Like close with your hands.

That's no good, you have to automate it.

No, not by hand. I meant you can write in at your own will. But apparently I misunderstood the question the first time. To set the condition of profit on the instrument greater than zero, this profit should be calculated.

  double profit = 0;
  for(int i = 0; i < OrdersTotal(); i++)
   {
    if(OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == _Symbol && OrderMagicNumber() == Magic)
     {
      if(OrderType() < 2)
        profit += OrderProfit()+OrderCommission()+OrderSwap();
     }
   }
 
Alexey Viktorov:

No, not by hand. I meant you can write it in at your own will. But I must have misunderstood the question the first time. This profit should be calculated to set the condition of profit by the instrument to be more than zero.

Is this how it should be done?

double profit = 0;

for(int i = 0; i < OrdersTotal(); i++)

{

if(OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == _Symbol && OrderMagicNumber() == Magic)

{

if(OrderType() < 2)

profit += OrderProfit()+OrderCommission()+OrderSwap();

}

}

SellClose = (AC<0.0 && RSI<30 && Open[1]>Close[1] && profit + );

 
cashnewmoney:

Is this how it should be done?

double profit = 0;

for(int i = 0; i < OrdersTotal(); i++)

{

if(OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == _Symbol && OrderMagicNumber() == Magic)

{

if(OrderType() < 2)

profit += OrderProfit()+OrderCommission()+OrderSwap();

}

}

SellClose = (AC<0.0 && RSI<30 && Open[1]>Close[1] && profit + );

Are you kidding me?

double profit = 0;
  for(int i = 0; i < OrdersTotal(); i++)
   {
    if(OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == _Symbol && OrderMagicNumber() == Magic)
     {
      if(OrderType() < 2)
        profit += OrderProfit()+OrderCommission()+OrderSwap();
     }
   }

SellClose = (AC<0.0 && RSI<30 && Open[1]>Close[1] && profit > 0 );
 
Vitaly Muzichenko:

Are you kidding me?

Thank you very much, it's all working.

 
cashnewmoney:

Thank you very much, everything is working.

Thank you here,Alexey Viktorov

 

The Expert Advisor places only one order per algorithm, consider Sell:

SellOpen = (AC<0.0 && RSI<30 && Close[2]>Open[2] && Close[1]>Open[1] && Low[2]<Low[1] );

How to write the code so that it would continue placing orders until the AC<0.0 condition is met

 
Alexey Viktorov:

No, not by hand. I meant you can write it in at your own will. But I must have misunderstood the question the first time. In order to condition profit on an instrument to be greater than zero, this profit has to be calculated.

Thank you very much. Everything works.