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

 
FinBuda писал(а) >>

Hello, I'm asking for help from the knowledgeable, my indicator does not want to draw by the flow, I have to constantly switch frames to update it to the last bar, how can I fix this shortcoming? I am very thankful for it.

You can't test it without the second indicator.

 
Vinin >> :

Without a second indicator, there is still no way to check.

Sorry! I stand corrected :)

Files:
indu2.mq4  3 kb
 
FinBuda писал(а) >>

Sorry! I stand corrected :)

It works, of course, but the brakes are terrible. It is necessary to transfer calculations of the auxiliary indicator to the main one. In general it would be better to optimize calculations.

Files:
norms2.1.mq4  4 kb
 
Vinin >> :

It works, of course, but the brakes are terrible. It is necessary to transfer calculations of the auxiliary indicator to the main one. In general, it would be better to optimize the calculations.

Thank you very much for your help! And another question along the way, how can I optimize the calculations, and how best to normalize the MACD to run within certain limits? I'm just far from the details and programming that's why all I could find a more or less suitable is the normalizer seen above :)

 
FinBuda писал(а) >>

Thank you very much for your help! And another question along the way, how can I optimize the calculations, and how best to normalize the MACD to run within certain limits? I'm just far from the details and programming that's why all I could find more or less suitable is the normalizer shown above :)

There may be many optimization options. I didn't really get into the code.

 
FinBuda >> :

Thank you very much for your help! I've got another question, what's the best way to optimise the calculation, and how to normalise the MAKD to keep it within the limits I've defined? I'm just far from the hardware and programming that's why all I could find more or less suitable is the normalizer seen above :)

You are using a variant that was posted on the code base, it is just a concept and is not optimized for performance. For practical purposes I suggest to set the characteristic_period variable manually from external variables, selecting it in such a way, that 3-4 full cycles of the main indicator occur during the given number of periods

//+------------------------------------------------------------------+
//|                                                   Normalizer.mq4 |
//|                                          Copyright © 2008, al_su |
//|                                                  al_su31@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, al_su"
#property link      "al_su31@mail.ru"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_maximum 1
#property indicator_minimum -1
#property indicator_level1 0.25
#property indicator_level2 0.5
#property indicator_level3 0.75
#property indicator_level4 -0.25
#property indicator_level5 -0.5
#property indicator_level6 -0.75
#property indicator_color1 RoyalBlue
//---- input parameters
#define PERIODS_CHARACTERISTIC 3

extern string  Indicator="ind-2";
extern int     mode=0;
extern int     param1=8;//Ну или 9, не важно...
extern int     param2=34;
//extern int param3;Скока надо параметров, стока и задаем
extern double  characteristic_period; //как видите, переменную вынесли вовне

//---- buffers 
double Normalizer[];
double sigma;

//-------------------------------------------------------------------------------
double Indyuk(int shift)
{
   return (iCustom(0,0, Indicator, param1, param2,/*param3, и т.д.:)*/ mode, shift));
}

double MathTanh(double x)
{ 
   double exp;
   if( x>0)  {exp=MathExp(-2* x);return ((1-exp)/(1+exp));}
   else {exp=MathExp(2* x);return ((exp-1)/(1+exp));}
}

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorShortName("Normalized "+ Indicator);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0, Normalizer);
   SetIndexDrawBegin(0, characteristic_period);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int   i, j, limit, counted_bars=IndicatorCounted();
   double S;
   if( counted_bars>0) counted_bars--;
   limit=MathMax(Bars- counted_bars-1,0);
//----
   for( i= limit; i>=0; i--)
   {
      S=0;
      for( j=0; j< characteristic_period; j++) S+=MathPow( Indyuk( i+ j),2);
      S/= characteristic_period;
      S=MathSqrt( S);
      if( S>0) Normalizer[ i]= Indyuk( i)/ S;
      Normalizer[ i]= MathTanh( Normalizer[ i]);
   } 
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
alsu >> :

Another option - which I personally use more often - is to specify the number of days for the run from the outside and convert them to characteristic_period in the indicator's body

...

extern double days_for_normalization=3;   // например, смотрим за три дня

...

int init()
{

...


characteristic_period=1440./Period()* days_for_normalization;   // 1440 - это количество минут в сутках
}
 
In general, Vinin is right, the calculation is really faster if the code of the second indicator is inserted in the first one. The disadvantage here is that you have to do more coding (and what you took from kodobase was one of the purposes of showing how to simplify this work), plus the second indicator takes up buffers of the first one, which is not always acceptable.
 
Thank you all for your help!!! Let's give it a try :)
 

It's not working out...when you read all these EAs here, but I only have MM, I would like to have a little maturity expectation of +.... eh...


Is the mathematical expectation -0.12 normal without optimization in a long time interval? I mean everybody gets it without optimisation and then expectation goes up by fitting, or it is not an option and I should change EA completely?

Reason: