[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 512

 
LazarevDenis:
Can you please advise if it is possible to write some text in mql4 into a file, e.g. *.txt, and then retrieve this data for trading. The idea is that the EA would learn to trade itself, when the price changes by >100*Point per couple of bars, the EA would memorise these values and then try to use them (indicator value +/- n% to open an order). This could also be implemented in the EA, but after closing MetaTrader all variable values seem to be reset to zero
Global variables can be used.
 
could someone please test my EA and tell me its strengths and weaknesses?
Files:
 

help me write a function that would perform a certain action, if the last 10 positions were closed in minus

Thanks in advance
 
Kreol:
Yes, yes, I got you ... But before I give up my hard-earned money, I want to make sure that the script I need is not available in the public domain
The scripts in the database is as big as dog eat dog. You are asking the wrong question. The universal script, even if they make it for you, will be inconvenient, and you will throw it away.
Scripts are usually designed to perform a simple uniform action. It's best to use a set of scripts, each of which is bound to a different hotkey.
For example:

Script
Key
Open Buy scriptCtrl+B
Script to open SellCtrl+S
Revers scriptCtrl+R
Close script
Ctrl+C

And so on.
You can find the corresponding ready-made scripts in the database by doing a search, google requests like reverse script site:mql4.com

 
nuan:

help me write a function that would perform a certain action if, for example, the last 10 positions were closed in minus

Thanks in advance

It is not difficult to calculate the number of last orders closed at a loss in the loop. But how can we write code that would perform an unclear action?
 
Need a code that counts
 
Hello! Here's a question... Is it the abundance of input conditions and auxiliary functions, as well as external variables like extern double, that can slow down the Expert Advisor? It's just a mystery in the tester... The first robot with everything hidden in the code has more drawdowns than the robot where everything is extern double... Although both have the same variable parameters. (they are the same too)
 
Shniperson:
Hello! Here's a question... Is it because of the abundance of input conditions and auxiliary functions, as well as external variables like extern double that the EA may become sluggish? It's just a mystery in the tester... The first robot with everything hidden in the code has more drawdowns than the robot where everything is extern double... Although both have the same variable parameters. (and they are the same too).


Check again the values of variables - maybe they are different and when compiling the first one, will work differently from each other.

Apart from that, compare them with this program in the search - download - WinMergeU.exe.

 

I downloaded from https://www.mql5.com/ru/code/9274

I downloaded from here a script to automatically set a pre-set take and loss, but they start to float following the price, can you tell me what the problem is and how to set it up so that they are static?

 
nuan:
We need a code that calculates


This is not difficult. Write a subprogram:

// этот код будет работать корректно только если в истории отсутствуют отложенные ордера.
int SchLossOrders(){
  string SMB=Symbol();
  int Sch=0;
  int i;
  for (i=OrdersHistoryTotal()-1;i>=0;i--){
    if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) { Print("Ошибка ",GetLastError()," при выборе ордера");}
    else {
      if(OrderProfit()<0 && (OrderType()==OP_BUY || OrderType()==OP_SELL)){
        Sch++;
      }
      else{
        return(Sch);
      }
    }
  }
 return(Sch);     
}

At the start of the EA we write:

if(SchLossOrders()>=10){
  // 10 последних сделок были убыточными - выполняем какое-то действие
}
Reason: