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

 
I can't find the command that redraws the custom indicator. If anyone knows, please tell me. Thanks in advance =)
 
tesla-pip:
I can't find the command that redraws the custom indicator. If anyone knows, please tell me. Thanks in advance =)

I already found it. Thank you all =)
 

Good afternoon.

Can you help me come up with a formula?

I have a refill step SD=100;

if the price is 25, then for it the topping out level will be DE=100

if the price is 102, its rate of units will be UD=200

if the price is 215, then the rate of topping up is BP=300

the price fell to 135 again, the topping out level will be UD=200

 
TarasBY:

And this order of things is normal (these are the principles of the terminal).

If you want indicator B to change its indications when parameters of indicator A change, make information exchange between indicators (may be a file, global variables of the terminal, computer RAM): indicator A passes its initializable parameters during initialization and indicator B periodically checks possible parameter changes of indicator A. When it detects changes, indicator B should also perinitialize with new parameters (forced init()).

Thank you for your reply, but I can't use it as I don't understand everything and am not very good at programming, could you please make the necessary changes to my indicator codes.



The first code is indicator A.

Second code-indicator B.

//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Black
#property  indicator_color2  Green
#property  indicator_color3  Red
#property  indicator_width2  2
#property  indicator_width3  2
#property  indicator_level1 0.0

//---- input parameters
extern int FastPeriod =5;
extern int LowPeriod  =34;
//---- indicator buffers
double     ExtBuffer0[];
double     ExtBuffer1[];
double     ExtBuffer2[];



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   //---- drawing settings
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   IndicatorDigits(Digits+1);
   SetIndexDrawBegin(0,34);
   SetIndexDrawBegin(1,34);
   SetIndexDrawBegin(2,34);
//---- 3 indicator buffers mapping
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("My_AO");
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Awesome Oscillator                                               |
//+------------------------------------------------------------------+
int start()
  {
      
  
   int    limit;
   int    counted_bars=IndicatorCounted();
   double prev,current;
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd
   for(int i=0; i<limit; i++)
      ExtBuffer0[i]=iMA(NULL,0,FastPeriod,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,LowPeriod,0,MODE_SMA,PRICE_MEDIAN,i);
//---- dispatch values between 2 buffers
   bool up=true;
   for(i=limit-1; i>=0; i--)
     {
      current=ExtBuffer0[i];
      prev=ExtBuffer0[i+1];
      if(current>prev) up=true;
      if(current<prev) up=false;
      if(!up)
        {
         ExtBuffer2[i]=current;
         ExtBuffer1[i]=0.0;
        }
      else
        {
         ExtBuffer1[i]=current;
         ExtBuffer2[i]=0.0;
        }
        
       
     }
//---- done
   return(0);
  }
#property indicator_separate_window
#property indicator_minimum -1.5
#property indicator_maximum 1.5
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property  indicator_width1  2
#property  indicator_width2  2
#property indicator_level1 0.0

//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,ExtMapBuffer2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {  
      
       
    double UP,DN;     
  
  
    int counted_bars=IndicatorCounted(),
       limit;  
       
    if(counted_bars>0)
      counted_bars--;
   
      limit=Bars-counted_bars;
//----
   for(int i=0;i<limit;i++)
       
      { 
        UP=iCustom(NULL,0,"My_AO",1,i+1);               
        DN=iCustom(NULL,0,"My_AO",2,i+1);    
             
        
       if(UP>0)       
         {ExtMapBuffer1[i+1]=1;
          ExtMapBuffer2[i+1]=0;
         }
         
       if(UP<0)       
         {ExtMapBuffer1[i+1]=-1;
          ExtMapBuffer2[i+1]=0;
         }  
         
                              
       if(DN>0)            
         {
          ExtMapBuffer1[i+1]=0;
          ExtMapBuffer2[i+1]=1;
         }
              
       if(DN<0)            
         {
          ExtMapBuffer1[i+1]=0;
          ExtMapBuffer2[i+1]=-1;
         }
               
                       
    
    }
//----
   return(0);
 
   }
   
//+------------------------------------------------------------------+    
   

 

The last question was solved, the new one is

I have the refill level recalculated on each bar.

How do I remember the level on the last bar

and use it to open a trade

 
MK07:
Thank you for your reply, but I can't use it as I don't understand everything and am not very good at programming.

You are suggesting that I should do for you what you 'play with'. Sorry, not interested.

And, if you are learning to program, it is an interesting task for you.

 
Good day to all. I have a problem with the "CurrencyPowerMeter" indicator and I can't move it to another position in the terminal window. If you can help, I'd be very happy to do it.
 
I decided to ask you a question, maybe you can tell me. I am writing an indicator, in the indicator I process ticks on tick timeframe (which opens autonomously,this one). My buffer array does NOT process EVERY tick, but selectively (e.g., a tick every 60 seconds, but it's not necessary). Instead of
int    counted_bars=IndicatorCounted();

I understand the following construction:

extern int sec=60;//объявляем количество секунд
int i;//будет индексом текущей "свечи" (тика)
int i_prev;//будет индексом предыдущей "свечи" (тика), отстоящего от теущего на sec секунд назад
double MyBuffer[];//этот будет на чарте
double MyTemp[];//этот только для подсчётов

int init(){
   IndicatorBuffers(2);
   SetIndexBuffer(0,MyBuffer)
   SetIndexBuffer(1,MyTemp)
   SetIndexDrawBegin(0,14);
   i=Bars-1;
   while(Volume[i]-Volume[Bars-1]<sec) i--;//потому что в Volume[] на тиковом у нас время сервера точностью до секунды (а в Time[] - моделируемое для предоставления тиков на чарте)
   i_prev=Bars-1;//отошли от первого исторического тика на чарте на заданное количество секунд, запомнили его, запомнили первый, уходим в start()
   return(0);
}

int start(){
   double deltaHigh,deltaLow;
   int counted_bars=IndicatorCounted();//честно говоря, не уверен, т.к. считаем мы не все "свечи" (тики)
   if(counted_bars>=i) i=Bars-counted_bars-1;//аналогично
   while(i>=0){//цикл обработчика
      deltaHigh=High[i]-High[i_prev];//к примеру
      deltaLow=Low[i_prev]-Low[i];
      //и дальше код обработчика (формируем предварительный массив MyTemp[]). В конце цикла:
      i_prev=i;//запоминаем теперь текущий индекс как индекс предыдущего тика
      while(Volume[i_prev]-Volume[i]<sec){//и уходим вперёд на заданное количество секунд
         i--;
      }
   }
...

Now the question. In the pure M1 version, the next thing is standard.

   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;//принтовал, при первом обращении limit=Bars-2, при последующих limit=2
   for(i=0; i<=limit; i++){
      MyBuffer[i]=iMAOnArray(MyTemp, 0, 14, 0, MODE_EMA, i);

What to replace limit and counted_bars with? My understanding is,

int counted_bars=ArraySize(MyTemp)-1;//сразу после цикла while

(because the number of ticks in 60 seconds is not constant, i.e., just write int counted_bars=IndicatorCounted()/_number_of_ ticks_in_60_seconds_ will not work).

Or am I wrong about everything?

p.s. ahead of a possible question, I will answer: I know that on forex sec!=60 is not applicable, and sec=60 makes no sense, but I trade not on forex either.

 
MK07:
Thank you for your reply, but I can't use it as I don't understand everything and am not good at programming, could you please make the necessary changes to my indicator codes.
Excuse me, do you have a car? If you have one, you don't consider it a luxury, just a necessity, do you? If not, you're not going to leave it like that for the rest of your life, are you? This is the age, you have to know how to drive a car. I'm just a farmer, but I do what I do, for me programming is no different from yard work, like locksmith work, the same work with my hands (I live in the countryside). A wheelbarrow, a wheelbarrow or MQL4 are just tools for me. Maybe it's perceived differently for city dwellers, I don't know. Global variables in manual here, standard file functions here, faster these ones, but through WinAPI. I wanted to answer yesterday, but didn't.
 

Good afternoon everyone!

I am learning to use arrays.

I have an array .I have initialized it with strings i.e. double mass [3567]={0.85374 , 0.85694 , 0.85974 , .... };

And the program read the array and executed it.

Now I have initialized the same array into one column

double massi[3567]

{

mass [ 0] = 0.85374;
mass [ 1] = 0.85694;
mass [ 2] = 0. 85974;
mass [ 3] = 0.86174;
mass [ 4] = 0.86474;
mass [ 5] = 0.86494;
mass [ 6] = 0.86504;

mass [ 7] = 0.86524;

}

The compiler does not generate any errors but generates a warning.

'{' - expression on global scope not allowed C:\Program Files\Alpari NZ MT4(2)\experts\include\MASSIV.mqh (4, 2)

The array is declared globally as before (when it was initialized with strings and worked fine).

 #include <MASSIV.mqh> 


 
int start()
{
 double Price=iOpen (Symbol (),0,0);         
 double SL=NormalizeDouble (Price+3000*Point, Digits);         
 double TP=NormalizeDouble (Price-100*Point, Digits);   

 double value =  Bid ;//параметру value функции ArrayBsearch присваивается значение  цены последнего тика
 double ld_Delta = 0.0010;
 int S = ArrayBsearch(  mass,  value, WHOLE_ARRAY,  0, MODE_ASCEND);//функция возвращает индекс значения цены макс. близкой к цене последнего тика 
 

 int last_order_bar = 0;
int ot = OrdersTotal();
...............................(остальной код опустил,но он  не изменился)

There are only 2 entries in the log.

2013.04.12 16:14:44 XXX test started

2013.04.12 16:14:36 XXX EURUSD,H1: loaded successfully


QUESTION.WHY IS THE PROGRAM NOT READING AN ARRAY INITIALIZED IN ONE COLUMN.

Thank you.