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

 
And another question related to the operation of the library.
I created the library file, compiled it, everything went without errors.
I imported the function into the indicator code, compiled it, everything is OK too.
When I start the indicator, the function to be imported is not executed, when I use

indicator code, everything works. Here is the library code.

//+------------------------------------------------------------------+
//|                                                         lib1.mq4 |
//|                                         Copyright © 2012, Fox.RM |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, Fox.RM"
#property link      "http://www.metaquotes.net"
#property library
//+------------------------------------------------------------------+
//| My function                                                      |
//+------------------------------------------------------------------+
double Sredn(double ArrSr[])
{
double a=1,c,step=1/20;
for (int i=0;i<=20;i++)
{if (ArrSr[i]==0){a*=1;}else{a*=MathAbs(ArrSr[i]);}}
c=MathPow(a, step);
  return(c);
}
//+------------------------------------------------------------------+

This is a call in the indicator code:

#import "lib1.ex4"
    double Sredn(double& ArrSr[]);
    void SetText(string name, string name2, string text, string text2, color c, 
int size);
#import

 
Fox_RM:
Good day to all!
I decided to rewrite the code of my indicator for an Expert Advisor to track
I have decided to change the code of my indicator to track the operation of its signals.
I have no errors when compiling it and it works in the Strategy Tester without errors.

I do not know how to use it.

Z.I. I am sure there are a lot of mistakes and stupid, please shoot blanks.

int counted_bars=IndicatorCounted(); 

You yourself write that you have an Expert Advisor and the function is for an indicator.

Count the number of bars you want forcibly and no more.


Secondly, add a check that there has already been an opening by this signal or you will get a new order every tick.

Third, check the iCustom function

 
ilunga:

You yourself write that you have an Expert Advisor, and the function is for an indicator.

Count the number of bars you want forcibly and no more.

And how do you calculate it forcibly?
 
Fox_RM:
Good day to all!
I decided to rewrite the code of my indicator for an Expert Advisor to track
I have decided to change the code of my indicator to track the operation of its signals.
I have no errors when compiling it and it works in the Strategy Tester without errors.

I do not know how to use it.

Z.I. I'm sure there are a lot of mistakes and stupid, please shoot blanks.


Opening price
if (Sredn(TP_UP)>=2.5)OrderSend(Symbol(),OP_SELL,0.1,Close[i],2,50,20);
 if (Sredn(TP_DN)>=2.0)OrderSend(Symbol(),OP_BUY,0.1,Close[i],2,50,20);
 
Fox_RM:
How do you force a count?
Only the signal on the 0th bar is important for Expert Advisors and opening trades, isn't it? So, shorten the calculation cycle from the number of bars to the number required for this calculation
 
r772ra:

Opening price

I.e. use this condition for recalculation of bars?

But in my indicator, at every tick the arrays TP_UP and TP_DN are calculated.Therefore, we should calculate them first of all.

 
ilunga:
For your Expert Advisor and to open trades, the only thing that matters is the signal on the 0th bar, isn't it? So, shorten the calculation cycle from the number of bars to the number needed for this calculation

I tried to open orders on a new bar there using the NewBar() function. If it is used for this purpose?

For example if (NewBar())i++; Something like this.

 
ilunga:
For your Expert Advisor and trade opening it is only the signal on the 0th bar that matters, isn't it? So shorten the calculation cycle from the number of bars to the number required for this calculation
And I still do not quite understand what the fundamental difference between these two calculations is for an Expert Advisor;(
 
Fox_RM:
And another question related to the operation of the library.
I created the library file, compiled it, everything went without errors.
I imported the function into the indicator code, compiled it, everything is OK too.
When I start the indicator, the function to be imported is not executed, when I use

indicator code, everything works. Here is the library code.

This is a call in the indicator code:

Maybe you didn't prepare the array correctly in the indicator init()? Did I understand you correctly - the imported function didn't work there?
 
TarasBY:
Maybe the array was not prepared correctly in the indicator init()? Did I understand you correctly - the imported function did not work there?
No, it didn't. I checked it, everything seems to be correct. And in addition, why does it work correctly when it is used in the program?
Reason: