[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 49

 
xruss >> :

I'll post a section of my code later, but I think it would be cooler with checkboxes. how do I write them in mql4?

https://book.mql4.com/ru/variables/arrays

At the end of this section, the principle of using flags is very well described by the example of the fact of forming a new bar. Similarly, we create two variables of the bool type that will indicate the possibility to open trades of a certain type, for example Buy_Allowed and Sell_Allowed. By default, we assign values of true to these variables. If there is a Buy signal, in case of successful position opening we set Buy_Allowed=false; in this case before OrderSend() we add the condition of its execution for Buy deals only if Buy_Allowed==true. When a reverse signal is received, we discard the Buy_Allowed=true flag. The same scheme is used for Sell deals but with the Sell_Allowed flag.

 
Everlost >> :

https://book.mql4.com/ru/variables/arrays

At the end of this section the principle of using flags is very well described by the example of the fact of forming a new bar. By analogy, we create two variables of bool type that will indicate permissibility of opening deals of a certain type, for example Buy_Allowed and Sell_Allowed. By default, we assign values of true to these variables. If there is a Buy signal, in case of successful position opening we set Buy_Allowed=false; in this case before OrderSend() we add the condition of its execution for Buy deals only if Buy_Allowed==true. When a reverse signal is received, we discard the Buy_Allowed=true flag. The same scheme is used for Sell deals but with the Sell_Allowed flag.

Thank you. I posted some of the code in the last post.

 

I have already downloaded my Daydream EA from this site.When I tested it, the maximum lot taken in the test was 0.1 and the balance was 10,000. I tested it with GBPUSD 15 in Meta Trader 4 222.

Second question: what is the "error mismatch" in the test report?

The third question, why can't I get a signal? I have the impression that this is somehow related to the first question, that is, something is glitching in the program. I'm using EURUSD M1 MACD Sample (which comes as standard), I decreased the MACD OpenLevel to 1 and got nothing.

I do not know how to use it.

 
xruss >> :

Thank you, I will educate myself. I posted some of the code in the last post.

int    ORDtype=-1, ORDtime=0;
double ORDprofit;

for (int i=OrdersHistoryTotal()-1; i>=0; i--) {
  if (OrderSelect( i, SELECT_BY_POS, MODE_HISTORY)) {
    if (OrderSymbol()==Symbol()) {
      if (OrderCloseTime()!=0 && OrderCloseTime()> ORDtime) {
        ORDtime=OrderCloseTime();
        ORDtype=OrderType();
        ORDprofit=OrderProfit();
      }
    }
  }
}

//........

if ( ORDtype==-1)
{
  // В истории не нашлось подходящих ордеров
}

if ( ORDtype==OP_SELL)
{
  // Последним был закрыт Sell
}

if ( ORDtype==OP_BUY)
{
  // Последним был закрыт Buy
}
The working variant of your code. You should not have removed the check (OrderCloseTime()>time). Without it, the whole sense would be lost - we are choosing the latest closed order by comparing the closing time of each order being searched against the oldest time of closing from the orders found earlier, which we save in the ORDtime variable. But you have just gone through all orders of the history. You also had a condition on ORDprofit, but you can add that yourself. :)
 
Everlost >> :
Working version of your code. You should not have removed the check (OrderCloseTime()>time) because without it the whole sense would be lost - we are choosing the latest closed order comparing the closing time of each order being searched against the oldest time from the orders found earlier. You also had a condition on ORDprofit, but you can add that yourself. :)

yes i had a condition to prohibit opening in the same direction if the last order had a profit :)

thanks a lot!!!))

 
zas писал(а) >>

Second question: What are "discrepancy errors" in the test report?

It's been asked many times, it's easier for you to search...

zas wrote >>

I tried to use GBPUSD 15 on a Meta Trader 4 222. What`s interesting, the test with 1 lot on another computer was ok. What`s the trick?

Maybe MT4 on the other computer is attached to the account of another broker, different brokers, different trading conditions... Or maybe the EA determines the lot randomly?) You may need the code of the Expert Advisor, the statements, and you will get an accurate answer.

zas wrote(a) >>

My impression is that it is somehow related to the first question, i.e., something is glitching in the program. I tried to use EURUSD M1 MACD Sample (which comes as standard), I decreased the MACD OpenLevel to 1 and got nothing.

Look at the tester's log, if you are talking about a tester. Post the set of parameters, and the result of the test EA (where there are no signals). It seems that all your clutches from lack of experience, and not from glitches in program...

 
VladislavVG >> :

One option :

Set the bool variable NeedAlert to true when you start trading.


Thank you, and I thought it would not work - like the loop will not work - it turns out I forgot the curly bracket))

 
Here's a question: How do I calculate the lot size so that the estimated profit for 20 pips is 4% of the current deposit?
 
xruss писал(а) >>

Thank you, I will educate myself. I posted some of the code in the last post.

//+------------------------------------------------------------------+
// Проверка последнего ордера по условию                             |
//+------------------------------------------------------------------+
bool LastCloseOrd(string Sy = "",//Если Sy=="" на принадлежность символу не проверяем
                  int  Type = -1,//Если Typ==-1 любой тип ордера
                  int Magic = -1,//Если Magic=-1любой магик
                  int Pr_Ls =  0){//Если Pr_Ls =0 без проверки на профит, если <0 то фильтр лосевых , если >0 то фильтр профитных ордеров
                  int time=0;
if(OrdersHistoryTotal()<1){return(false);}//Если нет закрытых ордеров выходим 
  for(int i=0; i<OrdersHistoryTotal(); i++){//Перебираем закрытые ордера
    if(OrderSelect( i, SELECT_BY_POS, MODE_HISTORY)){//Выбираем ордер из истории
      if(OrderCloseTime()!=0){//Если ордер уже закрыт
        if( Sy==""||OrderSymbol()== Sy){//если совпадает символ, или нет проверки на символ
          if( Type==-1||OrderType()== Type){//если совпадает тип, или нет проверки на тип
            if( Magic==-1||OrderMagicNumber()== Magic){//если совпадает магик , или не проверки на магик
              if(OrderCloseTime()> time){//если время закрытия ордера больше чем предыдущее
                time=OrderCloseTime();//записываем время закрытия (в конце цикла у нас в ловушке булет сидеть последний закрытый ордер
              }                                                  //попадающий под все условия выставленных фильтров)
            }
          }
        }
      }
    }
  }  
if( Pr_Ls==0&&time!=0){return(true);}//если нет условия на профит-лосс подтверждаем наличие ордера
if( Pr_Ls<0&&OrderProfit()<0){return(true);}//если ордер лосевый подтверждаем наличие ордера
if( Pr_Ls>0&&OrderProfit()>0){return(true);}//если ордер профитный подтверждаем наличие ордера
return(false);//нет ни одного попадающего под выставленные условия ордера
} 
 

This is about the errors in the tester.........

If anyone knows, please advise.....

')' - wrong parameters count	C:\Program Files\MetaTrader - Alpari\experts\expertCCI_WILLIAMS.mq4 (64, 37)
')' - wrong parameters count	C:\Program Files\MetaTrader - Alpari\experts\expertCCI_WILLIAMS.mq4 (65, 37)
What do the numbers 64.37 and 65.37 mean????????????
Reason: