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

 
psyman:


Thank you very much, tomorrow I will think of a way to replace iTime and iClose, as I'm sitting on XP.

//+------------------------------------------------------------------+ 
//| Get Time for specified bar index                                 | 
//+------------------------------------------------------------------+ 
datetime iTime(const int index,string symbol=NULL,ENUM_TIMEFRAMES timeframe=PERIOD_CURRENT)
  {
   if(symbol==NULL)
      symbol=m_symbol.Name();
   if(timeframe==0)
      timeframe=Period();
   datetime Time[1];
   datetime time=0;
   int copied=CopyTime(symbol,timeframe,index,1,Time);
   if(copied>0) time=Time[0];
   return(time);
  }
//+------------------------------------------------------------------+
 

How do I compile a separate function, e.g. trawl, so that it can be called -imported from EAs?

similar to .mqh or dll

 
demonRDV:

Hi all!

Can you please tell me why I can't enter its properties when the EA is working? I used to, but now I can't open the properties. Once restarting the terminal helped, but the problem appeared again after a minute. EA is fresh, terminal is also working recently. What is the problem with EA properties ?

Thank you !

most likely it is looped without checking for interrupts.
Do you have the source code? was there a problem with this EA before ?

 
Ghabo:

How to compile a separate function, e.g. trawl, so that it can be called -imported from EAs?

similar to how .mqh is called

like this.

in the EA
#include <trall.mqh>

and directly in the code call the function trall, for example

int trall_size = 20;
int trall_start = 30;
int trall_step = 5;


trall("",0,-1, trall_size, trall_start, trall_step); // trall("); // trall of all orders on the account with the set parameters

int magic = 345;
trall(_Symbol,magic, OP_BUY, trall_size, trall_start, trall_step); // trall only BUY orders on the current symbol with the specified slow

Files:
trall.mqh  27 kb
 
Maxim Kuznetsov:

Press hotkey F7 :-)

The mouse on the EA icon does not always work - the icon can be overlapped by other objects and the EA loads the message queue and 100500 other reasons

I know what it is. It does not help )
 
Nikolay Khrushchev:

something like that.

in the advisor
#include <trall.mqh>

I meant the trawl file should be compiled separately and have the extension ex4.

#include <trall.ex4>

or

#import "trall.ex4"
    ...
    ...
    ...
#import
What should be inserted inside the trawl functionitself?
 
Ghabo:

I meant the trawl file has to be compiled.

or

What should be inserted inside the trawl functionitself?

Why do you need such a perversion? Isn't it easier to write the function in the EA or as it was suggested with .mqh file?

Or is there an Expert Advisor with the trail, but no source? But if there is no export modifier after the function name, it will be impossible to import it into another EA.

Another disadvantage of such libraries is that they have to be dragged into a new terminal together with the EA. And if you use the include file .mqh, then you can copy only the compiled EA to another terminal.

Экспортирование функций - Функции - Основы языка - Справочник MQL4
Экспортирование функций - Функции - Основы языка - Справочник MQL4
  • docs.mql4.com
Экспортирование функций - Функции - Основы языка - Справочник MQL4
 
Alexey Viktorov:

What's with the perversion?

It's a fetish.)

There, that should work.

#property strict
void trall(string tr_symbol, int tr_magic, int tr_type, double tr_trall_size, double tr_trall_start, double tr_trall_step=1) export {
   if(tr_type>1) return;
   int ti;
   for(ti=OrdersTotal()-1;ti>=0;ti--) if(OrderSelect(ti,SELECT_BY_POS,MODE_TRADES)) {
      if(OrderSymbol()!=tr_symbol && tr_symbol!="") continue;
      if(OrderMagicNumber()!=tr_magic && tr_magic>0) continue;
      if(tr_type>=0 && OrderType()!=tr_type) continue;
      double work_price;
      double work_pp = SymbolInfoDouble(_Symbol,SYMBOL_POINT);
      int    work_dig = SymbolInfoInteger(_Symbol,SYMBOL_DIGITS);
      if(tr_trall_size>0) {
         if(OrderType()==0) {
            work_price = SymbolInfoDouble(_Symbol,SYMBOL_BID);
            if(NormalizeDouble(work_price-(tr_trall_size+tr_trall_step)*work_pp, work_dig)>NormalizeDouble(OrderStopLoss(), work_dig) && 
               NormalizeDouble(work_price-tr_trall_start*work_pp, work_dig)>=NormalizeDouble(OrderOpenPrice(), work_dig)) 
                  OrderModify(OrderTicket(),-1,0,NormalizeDouble( work_price-tr_trall_size*work_pp, work_dig),-1,-1);
            }
         if(OrderType()==1) {
            work_price = SymbolInfoDouble(_Symbol,SYMBOL_BID);
            if((NormalizeDouble(work_price+(tr_trall_size+tr_trall_step)*work_pp,work_dig)<NormalizeDouble(OrderStopLoss(),work_dig) || OrderStopLoss()==0) && 
               NormalizeDouble(work_price+tr_trall_start*work_pp,work_dig)<=NormalizeDouble(OrderOpenPrice(),work_dig)) 
                  OrderModify(OrderTicket(),-1,0,NormalizeDouble(work_price+tr_trall_size*work_pp, work_dig),-1,-1);
         }
      }
   }
}

or am I putting it in the wrong place?

 
Ghabo:

It's a fetish.)

There, that should work.

Or am I putting it in the wrong place?

It seems to be in the wrong place. You need to figure out how to put import in quotes or angle brackets. It depends on the location of this file in the Libraries folder or in the same place as the Expert Advisor importing functions of this library. I experimented with this a long time ago and can't remember, and now I'm sorry, I'm too lazy to find out how to do it.
 
psyman:


Thank you very much, tomorrow I'll think of something to replace iTime and iClose as I'm sitting on XP.

Here, pure code for the tag. Runs after the Bid price any way, any way when scrolling the chart, any way after switching charts. It runs behind the crosshair and remembers the offset set in this way, continuing to navigate to the Bid afterwards.

PS even I've already changed the hp recently as everything is starting to fail, some sites require browser update and it can't be updated on the hp,

I'm sick and tired of limiting RAM to 3.7gb as well.

xp has no support for testing owls on all CPU cores

Files:
Reason: