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

 
MaxZ:

Are there any MT4 accounts where you can open a lock with negative equity? I'm asking purely out of interest. The dispute arose on another forum. I am told that such accounts do exist! :DD

So that there are no unnecessary questions, here's an example:

You have opened one trade with volume N. Your terminal says after the line "Free:": "-XXX.XX"... Would you be able to open a lock with volume N!? I don't think so in a regular account... And I was told that there are some special accounts! :)))))) I don't believe it...

The answer is received... I'm shocked...


borilunad:

And I don't believe it! Is Uncle Kolya resting there?

It's normal if the account is in minus, all positions are forcibly closed. It is another matter if you managed to open a losing position before the minus, because the margin for the losing position does not increase, while you cannot even open a position in the same direction.

But it happens! And Uncle Kolya is not resting, he's ready to knock on the door! :D

And you are confused about something... When your free funds have just become less than zero, you will be forced to close the most unprofitable trade only if the StopOut is 100%. And at 50%, your free funds will be in the red for a long time! :)))

 
Hi folks! Where or how do I click to find out the maximum lot I can bet?
 
MaxZ:

Are there any MT4 accounts where you can open a lock with negative equity? I'm asking purely out of interest. The dispute arose on another forum. I am told that such accounts do exist! :DD

So that there are no unnecessary questions, here's an example:

You have opened one trade with volume N. Your terminal says after the line "Free:": "-XXX.XX"... Will you be able to open a lock with volume N! I don't think so in a regular account. And I was told that there are some special accounts! :)))))) I don't believe it...

The answer is received... I'm shocked...

These "chefs" don't know how to lure "silly Pinocchio" anymore!

I only meet Kolya Morzhov in the tester. I put my restrictions in the Worker's Counsellor so as not to go to extremes! ;))

 
Beowulf:
Hi folks! Where or how do I click to find out the maximum lot I can bet?

double MaxLot = MarketInfo(Symbol(), MODE_MAXLOT);
//В следущий раз не ленитесь заглянуть в Доку, а то тут могут послать к телепату!
 
borilunad:

He has already asked in another thread about it. It was answered... But he doesn't understand the code - he wrote about it himself.

He wants a script (ready-made solution - press a key (run the script) - look at the screen).

 

r772ra, wow, I should pay more attention to kim functions, thanks!

 
Roman.:

He already asked in another thread about it. It was answered... But he doesn't understand code - he wrote about it himself.

It needs a script (ready-made solution - press a key (run the script) - look at the screen).



There is only one thing left, to invite him to invest our accounts! :))

 
borilunad:


There's only one thing left to do, invite him to invest our accounts! :))


It's a good idea, but difficult to implement
 

 

hoz:

I'm getting a bit confused now. Here are 3 functions, each of which receives a specific signal for a specific indicator.

This function receives general signal from all indices and makes decision to BUY or SELL.

This is the main function that receives the general signal; here we get the values of indices through the loop to go through all the bars, of course... And then the obtained values are passed by reference to the appropriate functions where these values are needed, i.e. to the functions:

int GetCrossingMa(double& i_maFast1, double& i_maFast2, double& i_maSlow1, double& i_maSlow2)

int GetStochSignal(double& stochD1, double& stochD2, double& stochK1, double& stochK2)

void GetMomentumSignal() , in principle, can also be put there.

Thus, all the calculations of the indices will be in one main function of getting the signal. Everything is logical in this case...

TarasBY:

Victor! You have the logic, but the knowledge is not so far enough. If you keep at it, the first will help you go further than the textbook, and to "conquer" the second, you have to start with it (the textbook). You are not ready (yet) to build your own logical code structure, go back to the alphabetical version.
P.S. What "catches the eye" in your code:

In the function GetSignal() for search of crossing of two lines the for loop MAY be used, but it is better to use while loop, although this is personal preference. To start with, you need to move a parenthesis like in "Execution cannot be pardoned" to make your code execute what you have just said. For some reason, this (result) function lacks results of two functions: GetStochSignal() and GetMomentumSignal() - this is slightly inconsequential.

in functions GetCrossingMa() and GetStochSignal() there is NO point in passing parameters by references, because it would make sense, if these variables inside the function CHANGE their values.

The void GetMomentumSignal() function returns NOTHING.

Although I admit that it's "worse to see" from the outside... :)))

Here is an alternative variant of the function that gets signals from MAsh(s):

//IIIIIIIIIIIIIIIIIII==================CONSTANS=================IIIIIIIIIIIIIIIIIIIIII+
#define       BULL          0
#define       BEAR          1
#define       STOP         -1
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
extern int    Use_ChangeTrend.MA      = 0;           // 0 - off; Брать сигнал на смене тренда: 
//1 - ТОЛЬКО на первом; 2 - ТОЛЬКО не на первом; 3 - на всех
extern double MA_K_Period             = 3.0;         // коэффициент получения периода 2-ой МАшки.
extern int    MA_Period               = 14;
/*extern*/ int    MA_Shift                = 0;
extern int    MA_Method               = 7;
extern int    MA_Price                = 7;
/*extern*/ int    Color_Mode               = 0;
int           bia_PeriodMA[2];
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
//|  Автор : TarasBY, taras_bulba@tut.by                                              |
//+-----------------------------------------------------------------------------------+
//|        Получаем сигнал по наклону MA или по пересечению 2-х MA                    |
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
int fGet_SignalMA (string fs_Symbol,                        // Symbol
                   int fi_TF,                               // Таймфрейм
                   double fd_Deviation = 0,                 // расхождение м/у МАшками
                   bool fb_ControlBeginChangeTrend = False, // Контроль начала смены тренда
                   int fi_BarSignal = 1,                    // Бар на котором считываем сигнал
                   int fi_VerificationBars = 1)             // Количество баров для подтверждения сигнала
{
    static int li_preSignal = STOP;
    double lda_MA[2];
    bool   lb_twice = (MA_K_Period > 1.0), lb_Condition;
    int    li_BAR = fi_BarSignal, li_Trend = STOP, li_VerificationBars = 0, li_cmd = 1;
//----
    //---- Если работаем с 2-мя МАшками
    if (lb_twice)
    {
        for (int li_IND = 0; li_IND < 2; li_IND++)
        {lda_MA[li_IND] = iCustom (fs_Symbol, fi_TF, "AllAverages_v2.51", fi_TF, bia_PeriodMA[li_IND], MA_Shift, MA_Method, MA_Price, Color_Mode, 0, li_BAR);}
        //---- На 1-ом проверяемом баре фиксируем расхождение МАшек
        double ld_Deviation = fControl_Deviation (lda_MA, lb_Condition, li_cmd, li_Trend, fd_Deviation);
    }
    //---- Если работаем с 1-ой МАшкой
    else
    {
        for (li_IND = 0; li_IND < 2; li_IND++)
        {lda_MA[li_IND] = iCustom (fs_Symbol, fi_TF, "AllAverages_v2.51", fi_TF, MA_Period, MA_Shift, MA_Method, MA_Price, Color_Mode, 0, li_BAR + li_IND);}
        double ld_Price = fGet_PriceOnBar (PRICE_TYPICAL, fs_Symbol, fi_TF, li_BAR);
        //---- На 1-ом проверяемом баре фиксируем расхождение МАшек
        ld_Deviation = fControl_Deviation (lda_MA, lb_Condition, li_cmd, li_Trend, fd_Deviation);
        if (NDD (li_cmd * (lda_MA[0] - ld_Price)) >= 0.0) return (STOP);
    }
    //---- Если фиксируем на баре пересечение или горизонтальное расположение МА - выходим
    if (ld_Deviation == 0.0) return (STOP);
    int li_cnt = 0;
    while (lb_Condition == true)
    {
        li_BAR++;
        //---- Собираем показания МАшек в массив
        if (lb_twice)
        {
            for (li_IND = 0; li_IND < 2; li_IND++)
            {lda_MA[li_IND] = iCustom (fs_Symbol, fi_TF, "AllAverages_v2.51", fi_TF, bia_PeriodMA[li_IND], MA_Shift, MA_Method, MA_Price, Color_Mode, 0, li_BAR);}
            bool lb_AddCondition = true;
            li_cnt++;
        }
        else
        {
            for (li_IND = 0; li_IND < 2; li_IND++)
            {lda_MA[li_IND] = iCustom (fs_Symbol, fi_TF, "AllAverages_v2.51", fi_TF, MA_Period, MA_Shift, MA_Method, MA_Price, Color_Mode, 0, li_BAR + li_IND);}
            ld_Price = fGet_PriceOnBar (PRICE_TYPICAL, fs_Symbol, fi_TF, li_BAR);
            lb_AddCondition = (NDD (li_cmd * (lda_MA[0] - ld_Price)) < 0.0);
        }
        //---- Фиксируем расхождение МАшек или наклон 1-ой МА
        ld_Deviation = NDD (lda_MA[0] - lda_MA[1]);
        //---- Определяем условия контроля пересечения МАшек или изменение наклона
        if (li_Trend == BULL) lb_Condition = (ld_Deviation >= 0.0); else lb_Condition = (ld_Deviation <= 0.0);
        //---- Производим подсчёт баров, на которых выполняется означенное расхождение
        if (lb_AddCondition)
        {
            if (fd_Deviation != 0.0) {if (MathAbs (ld_Deviation) >= fd_Deviation) li_VerificationBars++;}
            else li_VerificationBars++;
        }
        else li_cnt++;
        //---- Если не отслеживаем начало смены тренда
        if (!fb_ControlBeginChangeTrend) {if (li_VerificationBars == fi_VerificationBars) return (li_Trend);}
        else
        {
            //---- Если баров, на которых выполняются заданные нами условия, > fi_VerificationBars - выходим
            if (li_VerificationBars > fi_VerificationBars) {li_preSignal = STOP; return (STOP);}
            else if (!lb_Condition)
            {
                if (li_VerificationBars == fi_VerificationBars) {return (li_Trend);}
                //---- Если не набрали нужное количество подтверждений сиганала после пересечения
                // или смены наклона - выходим
                else if (li_VerificationBars < fi_VerificationBars) return (STOP);
            }
        }
        //---- Предусматриваем уход от зацикливания (на начале отсчёта)
        if (li_cnt > MA_Period) return (STOP);
    }
//----
    return (STOP);
}
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
//|  Автор : TarasBY, taras_bulba@tut.by                                              |
//+-----------------------------------------------------------------------------------+
//|        Контролируем расхождение 2-ух МАшек или наклон 1-ой МАшки                  |
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
double fControl_Deviation (double ar_MA[],           // массив входящих значений
                           bool& fb_Condition,       // состояние тренда
                           int& fi_cmd,              // "знак тренда"
                           int& fi_Trend,            // тренд
                           double fd_Deviation = 0)  // расхождение м\у МАшками
{
    double ld_Deviation = NDD (ar_MA[0] - ar_MA[1]);
//----
    //---- Если фиксируем на баре пересечение или горизонтальное расположение МА - выходим
    if (ld_Deviation == 0.0) return (0.0);
    //---- Проверяем расхождение на нужную величину (если задано)
    if (fd_Deviation != 0.0) {if (MathAbs (ld_Deviation) < fd_Deviation) return (0.0);}
    if (ld_Deviation > 0.0) {fb_Condition = (ld_Deviation >= 0.0); fi_Trend = BULL;}
    else {fb_Condition = (ld_Deviation <= 0.0); fi_Trend = BEAR; fi_cmd = -1;}
//----
    return (ld_Deviation);
}
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+

As it can be understood from the comments, the signal can be obtained as a result of inclination of one МА (at MA_K_Period <= 1.0) or as a result of intersection of 2 МА (at MA_K_Period > 1.0). The period of the 2nd MA is calculated by itself (outside of this function):

    bia_PeriodMA[0] = MA_Period;
    bia_PeriodMA[1] = MA_Period * MA_K_Period;

You can also specify in the function the condition for divergence of 2 MAs (when fd_Deviation > 0.0). You can also track the fact of intersection (fb_ControlBeginChangeTrend = TRUE) or just fix the finding of Fast and Slow relative to each other.

To see how this code works, I placed an indicator in the archive that draws arrows by the signals of this function. We launch it using Signal_MA.tpl (for one MA) or Signal_MA2.tpl (for 2 MAs). By the way, the MAs can be of different types.

Files:
signal_ma.zip  185 kb
 
TarasBY:

Here is an alternative variant of the function, which receives signals from MAs:

As we can see from the comments, the signal can be obtained based on inclination of one MA (at MA_K_Period <= 1.0) or based on intersection of 2 MA (at MA_K_Period > 1.0). The period of the 2nd MA is calculated by itself (outside of this function):

You can also specify in the function the condition for divergence of 2 MAs (when fd_Deviation > 0.0). You can also track the fact of intersection (fb_ControlBeginChangeTrend = TRUE) or just fix the finding of Fast and Slow relative to each other.

To see how this code works, I placed an indicator in the archive that draws arrows by signals of this function. By the way, the MAs may be different.


If you want to speed up the work of the indicator, please contact