Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 52

 

Hi all! just started learning the language today. i can't figure out how to write the condition to be always checked.

If price in time interval t (entered by the user as a decimal place with one decimal place, e.g. 15.5 sec) falls by an amount n (entered by the user as an integer, e.g. 5), then the Expert Advisor opens a sell.

thank you!

 
Hello all. There is a need for a quality random quotation generator, at least of the geometric Brownian motion type or (ideally)))) Weierstrass-Mandelbrot function with a stochastic Hearst exponent. The need has arisen because of the weekend, I need to debug an indicator on a price series. I will not do without iTicks script. I have tried to do it or I will have to develop it myself? Search on the site gave nothing, but perhaps what I'm looking for is simply called something else than the keywords I'm looking for...
 
expmaestro:

Hi all! just started learning the language today. i can't figure out how to write the condition to be always checked.

If price in time interval t (entered by the user as a decimal place with one decimal place, e.g. 15.5 sec) falls by an amount n (entered by the user as an integer, e.g. 5), then the Expert Advisor opens a sell.

thank you!

Here's that algorithm. Learn from the examples.
 
Thanks, I'll try to figure it out. I hope that's really what I need.
 
expmaestro:
Thanks, I'll try to figure it out. I hope it's really what I need.

I was sure that Lucky was based on this principle, but it turned out not to be. Then try such a scheme:

extern int ShiftSec = 15;
extern int ShiftPips = 10;
//IIIIIIIIIIIIIIIIIII======Глобальные переменные советника======IIIIIIIIIIIIIIIIIIIIII+
datetime   gdt_NewTime;
double     gda_Price[0][2];
int        gi_size;
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
//|                  Custom expert initialization function                            |
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
void init()
{
//----
    gi_size = 0;
//---- 
}
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
//|                  Custom expert deinitialization function                          |
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
void deinit()
{
//----
//----
}
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
//|                  Custom expert iteration function                                 |
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
void start()
{       
//----
    if (gdt_NewTime == TimeCurrent()) return;
    gdt_NewTime = TimeCurrent();
    if (gi_size < ShiftSec) {ArrayResize (gda_Price, gi_size + 1); gi_size++;}
    else
    {
        //---- Это схема к которой нужно добавить управление ордерами
        if (gda_Price[0][0] - Bid > ShiftPips * Point)
        //---- Открываемся BUY
        if (Ask - gda_Price[0][1] > ShiftPips * Point)
        //---- Открываемся SELL
        //---- Сдвигаем массив цен на 1 вниз
        double lda_tmp[][2];
        ArrayResize (lda_tmp, gi_size);
        ArrayCopy (lda_tmp, gda_Price);
        int li_IND0, li_IND1;
        for (li_IND0 = 0; li_IND0 < gi_size - 1; li_IND0++)
        {
            for (li_IND1 = 0; li_IND1 < 2; li_IND1++)
            gda_Price[li_IND0][li_IND1] = lda_tmp[li_IND0+1][li_IND1];
        }
    }
    //---- Собираем цены
    gda_Price[gi_size-1][0] = Bid;
    gda_Price[gi_size-1][1] = Ask;
//----
}
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
You need to check if the code works. The time interval is calculated as a multiple of 1 second. Reducing the time interval is not up to me.
 

Can you please tell me how to implement a hotkey on the chart? so that you can change the value of a parameter in the EA - is this possible? what do I need to do?

Assuming that the variable type is bool - if I understand correctly, you will only need 2 keys per variable: you will get TRUE or FALSE.

 

I need to use the same function but with different variables to calculate the cell values of 2 similar arrays. The arrays are one-dimensional.

How do I write such a function? Is it possible?

Расчет_Массива(Массив_1, 5.0, 6.0);                       // Вызов функции

void Расчет_Массива(double array[], double A, double B)   // Сама функция
  {
   for (i=0; i<10; i++)
     {
      array[i]= A+B*i;
     }
  }

And is it possible to do the same thing with more multidimensional arrays? - 2, 3 dimensional.

--------------

I added an ampersand (&)

void Расчет_Массива(double& array[], double A, double B)   // Сама функция

and it works... : ))) Only I don't know what it's for - just tried it by analogy (gauge method). If you can tell me, I'd be glad to know. : ))

 
Chiripaha:

Can you please advise how to implement a hotkey on the chart? so that you can change the value of a parameter in the EA - is this possible? what do you need to do?

Suppose that the type of variable is bool - if I understand correctly, then there will only need 2 keys on one variable: you will get TRUE or FALSE.

Can the library help?

 // 2.2.3. Функция управляет горячими клавишами терминала МТ4.
 void ServiceMetaTraderHotKeys(int nKeyMode, // Код клавиши-модификатора. Может быть только предопределённым значением из:
                                             // VK_SHIFT, VK_LSHIFT, VK_RSHIFT, VK_CONTROL, VK_LCONTROL, VK_RCONTROL, VK_MENU, VK_LMENU, VK_RMENU, VK_LWIN, VK_RWIN.
                               int nKey);    // Код дополнительной клавиши.

 // 4.1.2. Функция управляет горячими клавишами на указанном графике.
 void ServiceChartHotKeys(int hwndChart, // Системный дескриптор окна, на котором применяются горячие клавиши.
                          int nKeyMode,  // Код клавиши-модификатора. Может быть только предопределённым значением из:
                                         // VK_SHIFT, VK_LSHIFT, VK_RSHIFT, VK_CONTROL, VK_LCONTROL, VK_RCONTROL, VK_MENU, VK_LMENU, VK_RMENU, VK_LWIN, VK_RWIN.
                          int nKey);     // Код дополнительной клавиши.
These are descriptions from the new version. The parameters are arranged differently in the piggy bank.
 
Zhunko:

Maybe the library can help?

These descriptions are from the new version. The piggy bank has different parameters.

Yes, Vadim, I was just looking at your library when I wrote this question. And I downloaded it more than half a year ago (and looked the new one yesterday too). I just don't know how to use it, that's why I asked "how to do it" - like a little example. Because I could with the function to the array myself, but here I find it a bit difficult to guess at my current level of programming skills.
Reason: