[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 26

 
Code:


Thanks for the reply and I'll answer your questions.

That characteristic is exactly the whole idea behind the indicator. And at the same time it's an exercise in MQL. I have thought up a task and intuitively understand that its implementation in a language is not very difficult. I sit and try it.

So, the essence of the characteristic is that I compare a certain fixed theoretical level of two one-directional volumes with the actual level. That is, if the actual ratio of the sum of two volumes to the actual "open-close" interval is higher than the specified theoretical one, I add a "bonus" to the actual second volume in the form of the difference between the calculated theoretical and actual results. If the actual level is lower than the theoretical one, I subtract the same difference from the second bar volume. Can I explain it clearly?

Just in case, I will say that when revealing this characteristic, you put brackets incorrectly, probably in a hurry.

Besides, it seems to me that those strings you consider equivalent to mine will lead to division by zero. I'll check it now.

It is clear. But it is not clear how 2 (the average between the two volumes) and what is calculated in variable UP12 are related. After all, the dimensions of both are different. The times and the price in the denominators. After all, back at school we were taught that meters and kilograms do not add up in any way! :))))


That's right, it's wrong! :)))) It's one thing to have formulas as fractions, but it's another thing to put everything on one line and not understand how... That's inattention, not haste...

I also optimized the code incorrectly. There again it was a mathematical error. I forgot to put in brackets.

   double vrealUP12=(dVolume+vback1)/((Close[i]-Open[i+1])*1000);
 
Roman.:

Your point is not the right one at all... to the wrong trading criteria, the question is about STOHAS-TEAM... :-Р

The question was this:

ideasforlife:

If condition1 is met, then:
-check for open SELL orders
-If there are - close them
-check for availability of funds on the account
-Open BUY order

The same if condition 2 is met, then
-check if there are any BUY orders opened
-if any, close them
check if there are any BUY orders opened - if there are, close them
-open a SELL order
+ error analysis (not the main thing, but it is possible)

What does this have to do with HOSTAGE? :))))

All the necessary checking has already been done and a trade signal has or has not been formed.

 
demlin:

Hi all!

Thanks to the invaluable help of the experts of this branch (especially Roman) I've managed to make a simple Expert Advisor, which has shown + on the tester. Question: How to determine whether it may be placed for real trading? Are there any criteria?


Yes, what are the criteria, you work on the "basic" things (sharpening for the real - the control of disconnection and switching to an additional line I do not consider), in the form of intelligent handling of possible errors with the adoption of appropriate organizational decisions on the expert's further work, then the obligatory demo, then the micro-real ... If you are satisfied with the results - "go crazy" ... :-)) To begin with, take apart error handling of EAs from tutorial, before placing orders do not forget to make necessary checks of requirements and limitations of trading operations, in search something like: error handling site:mql4.com, preparing EAs for real site:mql4.com, I (part :-R) have an expert who does such fi ndings as this:

// После старта
if (!IsTradeAllowed() || IsTradeContextBusy() || !IsConnected()) return; // если торговля невозможна, то выходим

Checking the order selection for using it

                if (ticket>0)                                               // Если позиция открылась
                    {
                       while(OrderSelect(ticket,SELECT_BY_TICKET)==false) Sleep(1000);     // Если ордер выбран
                         double OpenPrice=OrderOpenPrice();
                         ...  
                           

In the beginning

color ColorBuy = Blue, ColorSell = Red;
bool UseSound = true;
string alert.wav;
color clr, ClrClose = Gray;
int Level_new; 
double price;
bool result, Buy_signal=false, Sell_signal=false;
int  orderIndex;
bool IsExpertFailed = false;
bool IsExpertStopped = false;
double lots;                       // вспомогательная переменная для расчета нового размера лота 
double Lots_New;                   // Количество лотов для новых ордеров
int ticket;                        // Номер ордера
double orderLots;                  // Lots   
double orderProfit;                // Profit
double Price;                      // Цена открытия рыночного ордера
double SL;                         // Значение StopLoss ордера
double  TP;                        // Значение TakeProfit ордера
static datetime prevtime = 0;       // по ценам открытия

int init(){
    IsExpertStopped = false;
    if (!IsTradeAllowed())
       {
         Comment("Необходимо разрешить советнику торговать");
         IsExpertStopped = true;
         return (0);
       }
      
    if (!IsTesting())
       {
         if (IsExpertEnabled())  Comment("Советник запустится следующим тиком");       
           else  Comment("Отжата кнопка \"Разрешить запуск советников\"");
      
       }
    ...
   
   return (0);
}

That is all, IMHO, for starters; we could go on and on...

In any case, the control of the "Manager" is necessary ... :-R So as not to be excruciatingly painful for the lost deposits...

 

MaxZ:


The question was this:

What does this have to do with STOCHASTAGE? :))))

All the necessary check has been done and the trading signal has been formed or not.


There was a direct question:

"This is all on the current currency pair.
int start()
{
double M_0, M_1; // MAIN value on 0 and 1 bar
S_0, S_1; // SIGNAL value on 0 and 1 bar
//--------------------------------------------------------------------
// Call the function for the technical display.
M_0 = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN, 0);// 0 bar
M_1 = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN, 1);// 1 bar
S_0 = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0);// 0 bar
S_1 = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,1);// 1 bar
//--------------------------------------------------------------------

if( M_1 < S_1 && M_0 >= S_0 ) // CONDITION 1: Green crosses red from bottom

if( M_1 > S_1 && M_0 <= S_0 ) // CONDITION 2: Green crosses red from above

//--------------------------------------------------------------------
return; //Exit from start()
}"

Basically, whatever, IMHO, the author was referred to, he'll figure it out... :-Р

 

Roman.:


At the beginning.

...
int init(){
    IsExpertStopped = false;
    if (!IsTradeAllowed())
       {
         Comment("Необходимо разрешить советнику торговать");
         IsExpertStopped = true;
         return (0);
       }
...

What is the purpose of IsExpertStopped variable? And it turns out that every tick in the log will show the message " Expert Advisor must be allowed to trade"...

 
MaxZ:

What is the purpose of IsExpertStopped variable? And it turns out that every tick in the log there will be a message "Expert Advisor must be allowed to trade"...

This is what I do:


F1 press on
IsTradeAllowed()

You'll find out... :-Р

Specifically "

If EA is allowed to trade and thread is free", then trade, otherwise IsExpertStopped = EA stopped, waiting for permission to trade...

 
Roman.:

F1 press on

find out... :-Р

Namely "

if EA is allowed to trade and thread for trade execution is free", then trade, otherwise IsExpertStopped = EA stopped, waiting for permission to trade...

Got it... I'm totally distracted today. I see init() and think of start()! :)))))

 
MaxZ:

It is clear. But it is not clear how 2 (the average between the two volumes) and what is calculated in variable UP12 are related. After all, the dimensions of both are different. The times and the price in the denominators. After all, back at school we were taught that meters and kilograms do not add up in any way! :))))


That's right, that's not right! :)))) It's one thing to have formulas as fractions, it's another thing to put everything in one line and not understand how... That's inattention, not haste...

I also optimized the code wrongly. There again it is a mistake in mathematics. I forgot to use brackets.


MaxZ, hurry up, oh hurry up :))) with conclusions!

I do not add kilometres and kilograms. A real life example. Today's eurodollar, 5 minutes. Just poked at the chart where there are 2 rising candles in a row.

vback1=703, dVolume=696. (vback1+dVolume)/2=699,5.

On the same candlesticks (Close[i]-Open[i+1] )*1000=(1.42911-1.42549)*1000=3.62

(vback1+dVolume)/3.62=386.5

Total: 696+699.5-386.5=1009. Which is what should be drawn. And what exactly 1009 is shown by the indicator in this place. And so on.

Another thing is that I myself have calculated this example here and found out that according to the formula of the code, what I have described in the previous post does not occur. In fact it turned out to be a different ideology, a kind of self-regulation. As long as minus values of vrealUP12 parameter does not exceed the sum of dVolume+vteor12, there will be an addition to the last volume. Or additional parameters have to be entered for calculation of ExtVolumesBuffer[i].

And in the line

double vrealUP12=(dVolume+vback1)/((Close[i]-Open[i+1])*1000);

I just set it back to

double vrealUP12=(dVolume+vback1)/UP12;

so as not to lengthen.

 
Code:


MaxZ, hurry up, oh hurry up :))) with your conclusions!

I did not add up kilometres and kilograms. A real life example. Today's eurodollar, 5 minutes. Just poked at the chart where there are 2 rising candles in a row.

Shit... You do add up, and how! :))

Variable vteor12 has the dimension of Volumes (that's Our meters).

 vteor12=(dVolume+vback1)/2;

Variable UP12 has the dimension of Pips for some currency pair.

UP12=(Close[i]-Open[i+1])*1000

Variable vrealUP12 is dimensional to the ratio of Volumes to Points (that's Our kilograms).

vrealUP12=(dVolume+vback1)/UP12;

And you end up calculating your characteristic, which is the sum of metres and kilograms, which is what it's all about! ;D

ExtVolumesBuffer[i]=dVolume+vteor12-vrealUP12;


Unless 2 is not the 20 points that the Price per two bars should pass in theory! :)) But that's some nonsense already...


Code:


And in the line

double vrealUP12=(dVolume+vback1)/((Close[i]-Open[i+1])*1000);

I changed it back to

double vrealUP12=(dVolume+vback1)/UP12;

so as not to lengthen it.

Lengthening is sometimes useful. It saves computer resources! :))) Why do you need this extra variable?

 
MaxZ:

Oh, man... You are! :))

Variable vteor12 has the dimension of Volumes (that's Our meters).

Variable UP12 has the dimensionality of Price.

Variable vrealUP12 is dimensioned by Volumes and Price (this is Our kilograms).

And in the end you calculate your characteristic, which is the sum of metres and kilograms, which is what it's all about! ;D


OK, let's try another way of looking at it.

vteor12 can be written as (dVolume+vback1)/k1 (factor 1)

vrealUP12 can be written as (dVolume+vback1)/k2 (factor 2)

As I tried to describe the indicator ideology, it consists in comparison of some theoretical and actual levels. To obtain these levels I compare (i.e. divide) the same value (dVolume+vback1) with some theoretical value (k1) and actual value (k2). It's clear that k1 I'm just making it up, to put things in their proper names. Or, if you like, making an assumption. Now this has to be compared to something. Nothing is more objective and true than the graph itself in this case. So I take the opening and closing differences, taking them as the bottom line of a given time period. And the only task here is to bring it to the same digit, which is why it is multiplied by 1000.

Try to calculate several different variants of neighbouring candlesticks on a calculator and you may be surprised by the variety of results according to this very simple formula.

And in terms of school logic you are right. I add Volume + Volume/Price, you can't do that at school. :))

Reason: