[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 270

 
1Rakso >> :

why is the signal not working?

I wanted to set the filter zone in pips from the highest high and lowest low... the signal does not work what am I doing wrong?

I'm not quite sure what you're looking for here...

double hi_100 = iHigh(Symbol(),tf_100,iHighest(NULL,tf_100,MODE_HIGH,hibar,n_bar)); //поиск хая наибольшего значения
double lo_100 = iLow (Symbol(),tf_100,iLowest (NULL,tf_100,MODE_LOW,lobar,n_bar)); //поиск лоу наименьшего значения

if i have a high and a low of N bars, i look for it like this

double hi_100 = High[iHighest(Symbol(), tf_100, MODE_HIGH, hibar, 1)];
double lo_100 = Low [iLowest (Symbol(), tf_100, MODE_LOW, lobar, 1)];

where hibar and lobar are the number of bars on which the high and low are searched for.

tf_100 - TimeFrame at which max and min are searched.

1 - search starts from 1 bar, if you want it to search on zero bar, you should set 0.

 
Swan >> :


Ohhhh, I'm so embarrassed, I'm so embarrassed.
 
Dimi >> :

Now here is the question; How can I get value 20 of this array into variables?

bind double Max_array[20]; outside the function (globally), if necessary, also static

 
alsu >> :

First, put the code in logical order.

ArraySetAsSeries(Max_array,true) - why?

for(c=1; c <= total_c; c++) - arrays are indexed from 0 to total_c-1.

I honestly don't understand why you don't like the logic... Here ArraySetAsSeries(Max_array,true) Set the indexing direction in the array. Or is there something wrong?

 
Dimi >> :

To be honest, I don't understand why you don't like the logic. ArraySetAsSeries(Max_array,true) set the indexing direction in the array here. Or is it something wrong???


This is not an error of course, just a logically unnecessary string. ArraySetAsSeries makes sense when the array is further increased in size (for example, on each new bar), then the new element will have index 0. In the static case, however, it makes no difference in what order the elements are arranged in memory. Regarding the second note: in an array of size N, the last item has index N-1. Correct code for(c=0; c < total_c; c++)

 
alsu >> :

This is not an error of course, just a logically unnecessary string. ArraySetAsSeries makes sense when the array is further increased in size (for example, on each new bar), then the new element will have index 0. In the static case, however, it makes no difference in what order the elements are arranged in memory. Regarding the second note: in an array of size N, the last item has index N-1. Correct code for(c=0; c < total_c; c++)

Thank you. Now I understand the error. But I still cannot get it with double Max_array[20];... Let me explain a little differently. This function searches for the maximal value of RSI at the last 20 bars. I want it to search for the maximal value on that number of bars which will be calculated by another function. That is, on each new bar this number of calculated bars will change. It can be 10, it can become 20 or 30.... How to implement it in the code? The bar calculation function is ready, how to insert it now instead of this number 20 in this array double Max_array[20]; ????

 
Dimi >> :

Thanks now I understand the error. But this double Max_array[20]; doesn't get to me yet... Let me explain in a slightly different way. This function searches for the maximal value of RSI at the last 20 bars. I want it to search for the maximal value on that number of bars which will be calculated by another function. That is, on each new bar this number of calculated bars will change. It can be 10, it can become 20 or 30.... How to implement it in the code? The function to calculate the bars is ready, how to insert it now instead of this number 20 in this array double Max_array[20]; ????


very simple:

double IsMaxRSI(int total_c) {
   ...
   double Max_array[];  
   ArrayResize( Max_array, total_c);
   ...
}
виноват, код куда-то выпал
 
Dimi >> :

Not quite sure what you're looking for here...

double hi_100 = iHigh(Symbol(),tf_100,iHighest(NULL,tf_100,MODE_HIGH,hibar,n_bar)); //поиск хая наибольшего значения
double lo_100 = iLow (Symbol(),tf_100,iLowest (NULL,tf_100,MODE_LOW,lobar,n_bar)); //поиск лоу наименьшего значения

if max and min for N bars, it is searched like this

double hi_100 = High[iHighest(Symbol(), tf_100, MODE_HIGH, hibar, 1)];
double lo_100 = Low [iLowest (Symbol(), tf_100, MODE_LOW, lobar, 1)];

where hibar and lobar are the number of bars at which the high and low are searched for.

tf_100 - TimeFrame, at which max and min are searched for.

1 - search starts with 1 bar, if you want it to search on zero bar, you have to put 0.

Thank you I will try your variant, about the bars I was looking for 50 to 100 bars level, that's why I put them in external for optimization.

i found the error, i did not insert thef array into global variables and i put thef value in external variables in the order tf))))

extern int tf_100  =   3; //)))

int tf[10]={0,1,5,15,30,60,240,1440,10080,43200};//массив таймфрейма забыл его вставить)))

double hi_100 = High[iHighest(Symbol(), tf[ tf_100], MODE_HIGH, hibar, 1)];
double lo_100 = Low [iLowest (Symbol(), tf[ tf_100], MODE_LOW, lobar, 1)];

I'm really dumb, basic stuff like......

 
alsu >> :

very simply:

Thank you so much!!! Seems to be working!!!

Just like clockwork, thanks again!!! It really was easy.
 

Friends, good afternoon.


If you wouldn't mind telling me how to solve such difficulties:


I'm writing one of my first EAs, and I've encountered these difficulties:


1) Is it possible to "distinguish orders" for the same currency, but made on different TFs?

(For example, I trade an EA on the same currency pair, on H4 and M30... Made a trade on H4, and indicators show movement on this TF, but this trade was closed because of a closing signal on M30... and in my Expert Advisor "using data from multiple TFs" is not provided...)

i.e., could I somehow programmatically distinguish these trades on H4 and M30?


2) While writing the Expert Advisor, I had an obvious thought :) "Signals to close a position, and signals to open the opposite position by reversing" are not always good....

Often, a lot of profits are lost before the opposite signal is generated...

So I decided to use a trailing stop and form a target using Fibonacci.


Can you please advise how to set a target (in an EA) as a reference point for a certain Fibonacci level when placing an order for a trade?


3) There is an indicator: BrainTrend1StopN. Please advise how to "pull" the stops to the level of "points" generated by this indicator.


Thank you very much in advance.
Files:
Reason: