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

 
One more thing - when I start the EA, one order opens on the first candle, even though there were no signals at that moment. How can it be removed?
Files:
 
artem artem opening prices within the same period - 29 orders ?

+ several orders explicitly missed their opening price if they were tested by ticks. I attached a screenshot which shows

Try

Files:
artem.mq4  13 kb
 
Now it opens the same number of orders by both ticks and opening price. 23orders in total during the same period of time. Only now for some reason I enter from the 7th candle, not from the 4th.
 
artem artem orders in total during the same period of time. Only now we are entering from the 7th candle, not the 4th.

Removed everything unnecessary...seems to be working as it should

Files:
artem.mq4  11 kb
 
Can you tell me if there is a way to delimit EA settings strings in the terminal so that they cannot be erased? If you write extern string in the code, it allows you to edit the string, and if you accidentally delete it, you have to press "reset" to restore it, but then all the settings are reset. They can of course be saved to a set-file beforehand, but I'm just curious if it's possible to make a "stone table")
 

Checked, both on ticks and opening price... RA-BO-TA-ET!!!!

MakarFX, thank you so much!!! It's been 2 weeks since I've been messing around with this puzzle, all to no avail until today. Thank you so much, once again! I have literally a few clarifications left, and I won't keep you any longer, and so much of your time has been spent. Actually, here's what I'm interested in:


1. As far as I understand it, if I want to change the number of "confirmation candlesticks", then I just have to change one number to another in the constant, and that's it?

void OnTick()
  {
//---
   StopLevel = MarketInfo(Symbol(), MODE_STOPLEVEL); 
   //---
   if(newbar!=Time[0])
     {
      if(CheckForOpen()!=Start)
        {Start=CheckForOpen(); cnt=1;}
      else
        {cnt+=1;}
      //---
      if(cnt==8)
        {
         // Открытие ордера по методу Пуриа
         if(CheckForOpen()==0) // Если сигнал для покупок 
           {
            if(OrderSend(Symbol(),OP_BUY,Lots(),Ask,Slip,Bid-StopLoss*Point,Ask+TakeProfit*Point,"",MagicNumber,0,Blue))
              {Print("BUY OK");}
              else {Print(GetLastError());}
           } 
         if(CheckForOpen()==1) // Если сигнал для продаж 
           {
            if(OrderSend(Symbol(),OP_SELL,Lots(),Bid,Slip,Ask+StopLoss*Point,Bid-TakeProfit*Point,"",MagicNumber,0,Red))
              {Print("SELL OK");}
              else {Print(GetLastError());}
           }
        }   
      newbar=Time[0];
     }
  }

2. When I run the Expert Advisor, the first SELL order is opened on the first candlestick, even though there were no signals. This means that this very first order is redundant, and the EA should not open a deal immediately at the first order, just because the EA has just been started. How could this be fixed? I have an idea that Init is responsible for this and I should just change it to "false", or delete this Init altogether?

bool OrderBuy = true, OrderSell = true, Order = false, Init = true;

And lastly, if I leave it like this and run it to trade on several currency pairs at once, will it work as it should? Or I have to prescribe something else in the code, so that there would not be any bugs and so on. Especially, if this EA will work on several currency pairs at once?

Actually, that's all I am interested in, but anyway - thanks a lot again! If I would have done it myself, I don't know how much time it would have taken)

 
artem artem #:

Checked, both on ticks and opening price... RA-BO-TA-ET!!!!

MakarFX, thank you so much!!! It's been 2 weeks since I've been messing around with this puzzle, all to no avail until today. Thank you so much, once again! I have literally a few clarifications left, and I won't keep you any longer, and so much of your time has been spent. Actually, here's what I'm interested in:


1. As far as I understand it, if I want to change the number of "confirmation candlesticks", then I just need to change one number to another in the constant, and that's it?

2. When I run the Expert Advisor, the first SELL order is opened on the first candlestick, even though there were no signals. This means that this very first order is redundant, and the EA should not open a deal immediately at the first order, just because the EA has just been started. How could this be fixed? I have an idea that Init is responsible for this and I should just change it to "false", or delete this Init altogether?

And lastly, if I leave it like this and run it to trade on several currency pairs at once, will it work as it should? Or I have to prescribe something else in the code, so that there would not be any bugs and so on. Especially, if this EA will work on several currency pairs at once?

Actually, that's all I am interested in, but anyway - thanks a lot again! If I had tried it myself, I don't know how much time it would take)

1) Yes, these are the values of the number of "confirmation candles" .

2) No, on the first one does not open, only after a given number of "confirmation candles"

3) Change the magik and put it on any pair

It is better to make the magik an external variable

 
Ivan Butko #:
Can you tell me if there is a way to delimit EA settings strings in the terminal so that they cannot be erased? If you write extern string in the code, it allows you to edit the string, and if you accidentally delete it, you have to press "reset" to restore it, but then all the settings are reset. They can, of course, be preserved in a set file, but I'm just curious if it's possible to make a "stone tableau")
Make an ENUM
 
MakarFX #:
Do the ENUM

I'll give it a try, thank you.

 
Ivan Butko #:

I'll give it a try, thank you.

enum MODE
  {
   MODE_1=1,    // Мертвая строка
  };
//--- input parameters
input MODE mode= MODE_1; // Эта строка
Reason: