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

 
r772ra:
double iClose( string symbol, int timeframe, int shift)

Something like this.

Thank you very much!



 
extern double lot = 1;
extern double ts = 50; 
extern double sl = 50; 
extern double tp = 40;
extern double periodrsi = 30;
extern double hirsi = 80;
extern double lowrsi = 30;

int K=0;
int L=0;
 


int init()
  {
   return(0);
  }

 
int start()
  { 
    double r1 = iRSI(NULL,0,periodrsi,PRICE_CLOSE,1);


  

    static bool first = true;
    static int pre_OrdersTotal = 0;
    int _OrdersTotal = OrdersTotal();
    if ( first )
    {
        pre_OrdersTotal = _OrdersTotal;
        first = false;
        return(0);
    }
 
   
   
   
    if ( _OrdersTotal > pre_OrdersTotal ) 
{K=0;
L=0;}
    if ( _OrdersTotal < pre_OrdersTotal )
{K=0;
L=0;}
    pre_OrdersTotal = _OrdersTotal; 

if (r1>hirsi) K=1;
 {
 if ((K==1) && (r1<hirsi))

 { 
  L=(L+1);                        // набираем проходы вниз под hirsi

K=0;
 }
 }



 if(OrdersTotal()<1)

 {
 if((r1<hirsi) && (L==2))   //есть два прохода

 OrderSend(Symbol(),OP_SELL,lot,Bid,0,Ask+sl*Point,Bid-tp*Point,"Easiest ever",0,0);
Hello friends! please advise such a function which would add the following condition to this code. The deal is opened only if rsi has made two downward passes during n-number of bars. i.e. if rsi has made two downward passes during 30 bars then we open an order, i can't figure it out) I'm a beginner)
 
TemirKhan:
Hello friends! suggest a function that would add the following condition to this code. If rsi has made two downward passes during n-number of bars. i.e. if rsi has made two downward passes during 30 bars then open order, i can't figure it out.)


You start the counter. Then when you run it through the history, it counts by the condition: "If it crosses down, you add one to the counter... "etc.

Learn and take your time and you'll get it right!

 
hoz:


You start the counter. Then when you run it through history, it counts by the condition: "If it crosses downwards, add one to the counter... " etc.

Learn and take your time and it will all work out!


So there is a crossing counter, there it is:
if (r1>hirsi) K=1;
 {
 if ((K==1) && (r1<hirsi))

 { 
  L=(L+1);                        // набираем проходы вниз под hirsi

K=0;
 }
 }
now we need a bar counter, but how?)) so that L can get a value of "2" only if the crossovers happen within 30 bars
 

I started to think. I looked into Kim's function to dispel my doubts... and my arguments were confirmed. For some reason, the "Free Trade Flow" check only happens at opening и closing orders... And when modifications (initial setting of SL and TP), at traale and during transfer of a position to Breakeven there is no check. Why? After all, in both cases the server is called!

After all, if the trader is then taken, the Expert Advisor logically will not set stops, for example, and will not do anything with the position at all. I do not understand this.

 
hoz:

I started to think. I looked into Kim's function to dispel my doubts... and my reasoning was confirmed. For some reason, the "Free Trade Flow" check only happens at opening и closing orders... And when modifications (initial setting of SL and TP), at traale and during transfer of a position to Breakeven there is no check. Why? After all, in both cases the server is called!

After all, if the trader is then taken, the Expert Advisor logically will not set stops, for example, and will not do anything to the position at all. I do not understand this.


No big deal. Set it on the next tick
 
Vinin:

It's no big deal. Will set it on the next tick

So in that case, why check on opening or closing? It will be set on the next tick as well :) After all, it may play a great role for a scalper...
 
hoz:

So in that case, why check when opening or closing? Will also set on the next tick :) After all, it can play a huge role for a scalper...

So everything is in your hands. So it will be done. Some do it that way.
 

Again I looked in the reference and again read the lines here:

https://docs.mql4.com/ru/basis/preprosessor/import

Для импорта функций во время выполнения mql4-программы используется так называемое позднее связывание. Это значит, что пока не вызвана импортируемая функция, соответствующий модуль (ex4 или dll) не загружается.

I mean, in order for the library to be loaded, it should be called in the code after the import lines, right?

For example, I did it like this:

#import "hoz_Base@Library.ex4"
   double ND(double A);
   double Get_TradePrice(int fi_priceId,       // Цена: 0 - Ask; 1 - Bid
                      string fs_symbol);

1. It turns out that we declare functions. that we will use in the Expert Advisor at the very beginning of code of the Expert Advisor?

2. and not to declare them a lot in the code of the Expert Advisor itself and use header files? I.e. only for declarations?

This question came up because I have seen such Expert Advisors that were written by quite serious programmers, but their header files contain all main and non-main functions. I was surprised by this... The reason is that the speed of compiled libraries is much faster, in addition, the code of library functions is "isolated", which is also very convenient.

 
Good morning, this is my first time here so apologies, didn't see this thread and created a new one, really need to hear from professionals !

https://www.mql5.com/ru/forum/145453
Reason: