[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 319

 
happybuddhist:

Anyway, I need help with writing a function to close orders for my TS (point 3) and adapting existing code to the function.

See here. ;)

Files:
ln_3.mq4  4 kb
 
hoz:

But there is a point. There, in any case, one change in the expression output will not solve the problem. After all, at the point where zeroing occurs, the opening and closing prices have to be "swapped out".


You seem to be mistaken. After all, +(a-b)=a-b, -(a-b)=-a-(-b)=-a+b=b-a. With a change of sign they do change places.

hoz:

Vadim wrote some time ago that putting a function inside the loop slows down code execution by an order of magnitude.


As far as I understood Vadim, he meant the call of a user function in a loop.

Vinin:

Maybe you should open your own branch. Why do you need "A branch for newbies"?
Yeah, why would a beginner need to know the anatomy and periods of a mashka)))) I am no different from beginners, maybe only because I am illiterate, so I try to get to everything with my own brain.

hoz:

I made thecntUp andcntDn counters different, because it may have one value at once and then another when calculation is done through the loop by calculated bars. And the counter can sum up one value and continue summing up another one. And if there is one variable, the number of bars of one attribute will be added to the counter of bars of another attribute.


The counter is different there. If the candlestick goes in the opposite direction, the counter is reset by the formula. Or maybe I did not understand you. The only thing is that it may work slower. I'll test it when I get around to it.

 
gyfto: ... I have such a question about optimization. I'm dealing with EMA algorithm...
Now, why do I need to take the last weight if I can simply wrap the power function if the next weight is more important than the previous one? I'm not even asking anymore why use recursion when the final weights after recursion can be derived by a formula (see F(n,x) and y(n,x)).
Vinin : Maybe you should start your own branch. Why do you need a "Beginner's Branch"?
gyfto: ... Yeah, well, why should newbies have to understand anatomy and periods of the waving)))) I'm no different from beginners, maybe only that I'm illiterate, so I'm trying to get to everything with my brain. ...
Go ahead, go ahead and open a thread like "Questions on EMA" and attach the Matcad file. Your post will just get lost here. In a separate thread, the math gurus should be able to break it all down.
 
GaryKa:
Go ahead and start a thread like "EMA Questions" and attach a Matcad file. Your post will just get lost here. In a separate thread, the math gurus should be able to break it down.

You probably mean the answer to the question will get lost. Okay, I'll open a thread, edit that post, I'll write moved.
 
TarasBY:

Watch this. ;)


Hmm, thanks. Are these results from optimisation?
 
gyfto:

You seem to be mistaken. Because +(a-b)=a-b, -(a-b)=-a-(-b)=-a+b=b-a. With a change of sign, they do change places.

So from mathematics we know that minus to minus gives plus. And Plus to minus gives minus. But this is the first time I've heard of variables swapping places.

gyfto:

As far as I understood Vadim, he meant call of user function in the loop.

I have a user function there. Here is the initial function itself in its unshortened form since it does not work as I want it to for now, so I decided not to make it universal:

//+-------------------------------------------------------------------------------------+
//| Расчитываем количество идущих один за одним баров одного признака                   |
//+-------------------------------------------------------------------------------------+
int LastCandlesType(int directionMA)
{
   int cntUp,                                                                            // Счётчик идущих друг за другом свечей с..
       cntDn;                                                                                // .. требуемыми признаками
       
   for (int i=i_AnyBarsToHistory; i>=1; i--)
   {
      if (directionMA == CROSS_UP)
      {
         if ((Open[i] - Close[i]) >= i_sizeOfSequentialCorrectionBar * pt)              // Если бар соответствует требуемым признакам..
             cntDn++;                                                                     // .. прибавим 1 к счётчику

         if ((Close[i] - Open[i]) >= i_sizeOfTrandBar * pt)                             // Если бар, не соответствует основному признаку..
             cntDn = 0;                                                                   // .. счётчик обнуляем

         if (cntDn == i_sequentBarsСount)                                                   // Если cnt баров в подряд медвежьи..
             return (REQUIRED_SEQUENTIAL_BEARS_GOT);                                         // .. Выходим из функции
      }

      if (directionMA == CROSS_DN)
      {
         if ((Close[i] - Open[i]) >= i_sizeOfSequentialCorrectionBar * pt)              // Если бар соответствует требуемым признакам..
             cntUp++;                                                                     // .. прибавим 1 к счётчику

         if ((Open[i] - Close[i]) >= i_sizeOfTrandBar * pt)                             // Если бар, не соответствует основному признаку..
             cntUp = 0;                                                                   // .. счётчик обнуляем
     
         if (cntUp == i_sequentBarsСount)                                                   // Если cnt баров в подряд бычьи..
             return (REQUIRED_SEQUENTIAL_BULLS_GOT);                                         // .. Выходим из функции
      }
   }
}

Inside the loop, from a function that receives a common signal, this variable gets its value and is passed by parameter:

int directionMA = GetStateOfMA();

gyfto:
Well yes, why would newbies need to understand the anatomy and periods of a waving machine))) I am no different from beginners, maybe only because I am illiterate, so I am trying to get to everything with my brain.

You are wrong. In fact, there is no question of illiteracy. You have such thoughts here that many newbies don't understand...

gyfto:

There's a different counter there. If the candle goes the other way, the formula resets the counter. Or am I misunderstanding you. The only thing is that it might work slower. I'll test it when I get a chance.

Yes. But we have a counter where the values are calculated by the order of bars appearing from the bar with indexi_AnyBarsToHistory to the bar with index 1. It follows that if the condition will be fulfilled on the bars from index 30 to index 15:

directionMA == CROSS_UP

and then for example at cnt=2 the condition will be fulfilled:

directionMA == CROSS_DN

Then cnt will be incremented to the previous value. If we had 2, the new condition will increment with 1, then cnt=3 and we will exit the function with value 3. Do you see what I mean? Look closely, the logic is basically obvious here.

 

Good afternoon.

Does anyone have any experience of changing indicator parameters in an EA

depending on volatility (e.g. MA parameters) ?

Or can you give me a link to read

 
Stells:

Good afternoon.

Does anyone have any experience of changing indicator parameters in an EA

depending on volatility (e.g. MA parameters) ?

Or can you give me a link to read


If you understand what a muving is, such questions will disappear on their own.
 
hoz:
If you understand what muving is, such questions disappear on their own.
You can't just live beautifully...

Adaptive MA
 
Good day, I need help writing a simple script or an Expert Advisor' if the script can't do it myself I have never programmed the script The essence of the script Login - receive prices (current Ask and Bid) - determine the future buy/sell price (as a multiple of its number "for example 30") - find out if there are no open/postponed orders at these prices - if no orders, place pending orders with stoploss and take profit - if there are orders check the next buy price that for buying is higher by a multiple number, for sell - smaller by a multiple - check ceiling current price +-100*fold - wait 5 minutes and go to "get price" wait can be replaced by go to "get price" after any tick
Reason: