[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 387

 
artemka_1981:

Hello, please advise: My problem is the following: in the Expert Advisor, there should be only one signal to trade (when all three indicators have crossed their respective zones)

if(SignalType_1 && (RSI >= 35 && Stoch >= 20 && CCI >= -100)) return(+1)

Here is the question. How to write this line correctly, so that there is only ONE signal. (Otherwise, it turns out that the Expert Advisor makes deals according to the following algorithm: RSI crosses the line 35 - deal; STOCH crosses the line 20 - deal; CCI crosses the line -100 - deal; it makes three deals)

The signal for a deal only ONE when all three indicators crossed their zones

Try it like this:

bool GO = true;// глобальная переменная
//---------------------

if(GO && SignalType_1 && RSI >= 35 && Stoch >= 20 && CCI >= -100) {GO=false; return(+1);}//запретить повторный вход
//---------------
{OrderClose(.......); GO = true; }//открыть семафор при закрытии позиции.
 
DhP:

Try it this way:

Thank you. I'll give it a try.
 

Afternoon.

1. How do you express the result of a trade, i.e. was it profitable or loss-making? For example, the last one?

2. How to make a virtual trade and take into account its result (sign) ?

 
inoy:

Afternoon.

1. How do you express the result of the trade, i.e. whether it was profitable or unprofitable? For example, the last one?

2. How to make a virtual transaction and account for its result (sign) ?

1. Look at these 2 functions:

isCloseLastPosByStop
isCloseLastPosByTake

2. There is a very simple way for a virtual trade. Increase your deposit amount by 100 times, well, let's say, instead of the notorious 1000 quid take 100000. And lots of a virtual position reduce to the limit - to 0.01, for example, with a working lot, such as 10. 0.01 of 10 - this is one-tenth of one percent - completely imperceptible losses and profits.

Deal mark: isLossLastPos

 
sss2019:

Help me solve the problem, why if the loop has only 2 passes i first equals 0 and then immediately equals 4?

From this script the alert outputs 0, 4.

Well, maybe it's patamushta:

for(i=0,g=0,c=0;i<OrdersTotal();i++)
    {
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == false) break;
    if(OrderMagicNumber() == MasterMagicNumber)     // а других точно нет?
      {
.............
      Alert(i);
.............
      }
.............
    }

Maybe it's better this way:

for(i=0,g=0,c=0;i<OrdersTotal();i++)
    {
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == false) break;
    Alert(i);
    if(OrderMagicNumber() == MasterMagicNumber)
      {
      starttime = OrderOpenTime();
      ArrayResize(prices,ArraySize(prices)+TradesCount);
      if(OrderSelect(i+1,SELECT_BY_POS,MODE_TRADES))
      if(OrderMagicNumber() == MasterMagicNumber) endtime = OrderOpenTime();
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      times[i] = starttime;
      times[i+1] = endtime;
      tickets[i] = OrderTicket();
      symbol = OrderSymbol();
      while(g < TradesCount*(i+1))
        {
        if(OrderType() == OP_BUY)
          {
          if(g == TradesCount*i)
            {
            prices[g] = OrderOpenPrice()-LowOpen*Point;
            }else
            {
            prices[g] = prices[g-1]-step*Point;
            }
          }
        if(OrderType() == OP_SELL)
          {
          if(g == TradesCount*i)
            {
            prices[g] = OrderOpenPrice()+HighOpen*Point;
            }else
            {
            prices[g] = prices[g-1]+step*Point;
            }
          }
        g++;
        }
      }
    }
 
DmitriyN:

1. Check out these 2 functions:

isCloseLastPosByStop
isCloseLastPosByTake

2. For a virtual trade there is a very simple way. Increase your deposit amount by 100 times, well, let's say, instead of the notorious 1000 quid take 100000. And lots of a virtual position reduce to the limit - to 0.01, for example, with a working lot, such as 10. 0.01 of 10 - this is one-tenth of one percent - hardly noticeable losses and gains.

Deal sign: isLossLastPos


Thank you. But there must be a more elegant option for virtual inputs, surely. "Increase the deposit size by a factor of 100" - I'm afraid I don't have that option in real life)). Pro's, don't pass it by!
 
inoy:

Thank you. But there must be a more elegant option for virtual inputs, surely. "Increase the deposit size by a factor of 100" - I'm afraid I don't have that option in real life)). Pro's, don't pass it by!

https://www.mql4.com/ru/search#!keyword=%D0%B2%D0%B8%D1%80%D1%82%D1%83%D0%B0%D0%BB%D1%8C%D0%BD%D0%B0%D1%8F%20%D1%82%D0%BE%D1%80%D0%B3%D0%BE%D0%B2%D0%BB%D1%8F&module=mql4_module_articles
 
Vinin:

https://www.mql4.com/ru/search#!keyword=%D0%B2%D0%B8%D1%80%D1%82%D1%83%D0%B0%D0%BB%D1%8C%D0%BD%D0%B0%D1%8F%20%D1%82%D0%BE%D1%80%D0%B3%D0%BE%D0%B2%D0%BB%D1%8F&module=mql4_module_articles

Thank you.
 
DhP:

Try it like this:

bool GO = true;// глобальная переменная
//---------------------

if(GO && SignalType_1 && RSI >= 35 && Stoch >= 20 && CCI >= -100) {GO=false; return(+1);}//запретить повторный вход
//---------------
{OrderClose(.......); GO = true; }//открыть семафор при закрытии позиции.

Good afternoon.Tried to fix it now owl makes only one trade closes at stop loss and that's it.No other trades open.Tell me what's wrong

Files:
 
artemka_1981:

Good afternoon.tried to fix now owl makes only one trade closes at stop loss and that's it.no other trades open.tell me what's wrong

if(OrdersTotal()==0)GO=true;