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

 

Good evening.

I'm a bit of a "crucian" when it comes to coding :) I am building an Expert Advisor based on Fibonacci indicator. I am not paying attention to the strategy so far. The problem is 7 Fibonacci levels, how to make each level crossed set only 2 different pending orders and no more.

I would appreciate any tips.

Sorry for my awkward russian.

Files:
 
Usual_Trader:


As I understand it, doesRefreshrates( ) work on the current instrument or does it update data on all instruments?


For all instruments.
 
Sarguss:

Good evening.

I'm a bit of a "crucian" when it comes to coding :) I am building an Expert Advisor based on Fibonacci indicator. So far, no attention to strategy. The problem is 7 Fibonacci levels, how to make each level crossed set only 2 different pending orders and no more.

I would appreciate any tips.

Sorry for my awkward russian.


Work

P.S. "A pike for a crucian carp do not doze" (Russian proverb).

 
Roll:


Work

P.S. "A pike for a crucian carp" (Russian proverb).


Thanks for the proverb:))) Right on topic -

Any rookie question, so as not to clutter up the forum. Professionals, do not pass by. Without you nowhere - 4.

Finish it - any answer Profi!

 

Hello experts, please help me to create a script. There are two MA(Moving Average) indicators on the chart, MA1 is marked red and MA2 is marked blue. The task of the script: to cross MA1 and MA2 so that the red line crosses the blue one from top to bottom. We will call this point A and if the red line crosses the blue one from top to bottom, it will be point B. So, at point A, we need the scrip to close a sell order and open a buy order and at point B to close a buy order and open a sell order. This loop should be infinite. Attached a similar code, please help, I will be very grateful

Files:
 
Lisi4ka330:
In order not to make the confusion worse, I want to correct the mistake I made in the previous answer - the notation "array1[Bars*6-60,60][0]" is not correct, because Bars*6 is the total number of elements in array1.Each bar has 6 properties, let's assume we have 30 bars, multiplying by 6 we get the number of elements in the first array - 180. The second array has only 60 free "cells" (i.e. 10 x 6 properties), so we must select only 60 elements from the first array to copy. By using expression [Bars*6-60,60] we subtract 60 from total, i.e. 180 - 60 = 120, i.e. 120 elements of the first array will be copied into zero element of the second, 121 into the first one, and so on. Another question is how it turns out that information about the last formed bars is written not at the beginning of the first array, but at the end ... But apparently the answer lies in the function code, and it makes no sense to dig any deeper...


Well, I have a database, it has nothing to do with it. Natalya wrote logically correctly. And even in the case where we have 30 bars, thearray1 index value is 120. Correspondingly, the value of corresponding index ofarray2 is already declared as 10 during initialization.

https://docs.mql4.com/ru/array/ArrayCopy

double array2[10][6];

In a C book I read that:

The C language does not control array overruns, which means that technically youyou canwrite something in an element with a non-existent index, for example in A[345] or in A[-12].But in doing so you will erase some cell in memory not belonging to the array, sothe consequences of such a step are unpredictable and the program hangs in many cases.

It turns out that the index of array1(the source array) is greater than the corresponding index ofarray2 (the destination array). And consequently you shouldn't do it that way! That's what I meant...

 

Hi all!

I tried to write my first EA :-), but some difficulties arose.

The logic behind it is the following, there is an indicator that shows max and min for the last n bars, when it breaks a maximum or minimum an order should open.

When I attach the EA to the chart, it opens a SELL position. I do not know why it happens that way.

I think the error is in the iCustom() function, which sends indicator parameters.

I have attached the EA and the indicator.

Files:
xox.mq4  10 kb
 
And here's the indicator.
Files:
go_go_1.mq4  2 kb
 
Pacman:

Hi all!

I tried to write my first EA :-), but some difficulties arose.

The logic behind it is the following, there is an indicator that shows max and min for the last n bars, when it breaks a maximum or minimum an order should open.

When I attach the EA to the chart, it opens a SELL position. I do not know why it happens that way.

I think the error is in the iCustom() function, which sends indicator parameters.

I have attached the Expert Advisor and the indicator.

You don't fill the 0th index of the indicator arrays,

   for(k=1; k<=Quant_Bars; k++)
      {
       Line_1[k]= Minimum;
       Line_2[k]= Maximum;
      }

but you access it:

   double L_1= iCustom(NULL,0,"Go_go",K,0,0);  //Линия минимума
   double L_2= iCustom(NULL,0,"Go_go",K,1,0);  //Линия максимума 

It is a bit (structurally) awkward, but it will do for the first time. My advice: "Get used to correct approaches to writing code right away. For example, using this condition in your code:

       if(Total==0 && Opn_B==true)              //Открытых ордеров нет + 
It is illiterate, because sooner or later, you will switch from tester to on-line trading, and there are several Expert Advisors working in parallel, and this code will not work.
 
Pacman:
And here's the indicator.

What is your problem with iHighest() and iLowest()?