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

 
FAQ:

I don't understand, are you testing us all here?

If there's a problem, describe it.

Why would I do that? I'm asking a question, is it really necessary to troll for an answer?

The question is: how do you search for minutes within a high timeframe and get information about their (minutes') opening price?

 
dzhini: Why would I do that. I'm asking a question, is it really necessary to troll for an answer first?

Ask the question correctly.

dzhini:The question is: how do you go over a minute inside a senior timeframe with information about their (minute's) opening price?
iOpen(Symbol(),PERIOD_M1,shift);

Will give you an answer.

 
Guys, can you give me a hint? This site has a script called "SendOrderMultiLock". I'm interested in whether it can be made to turn on at a given time?
 
dzhini:

Since you have taken the initiative, let's try to come up with a code that would signal us every minute with information about the opening price of a one-minute candle on a five-minute chart (with the possibility of working in a tester). I propose my own variant:

This option is better.
 
Thanks for that, too.
 
dzhini:
Thank you.
// функция записывает в массив result[] цены открытия минутных баров 
// внутри бара с индексом shift текущего таймфрейма. Возвращаемое значение - количество соответствующих минутных баров
// 

int M1_OpenPrices(int shift, double &result[])
{
   int n=0;
   ArrayResize(result,n);
   
   int sh, sh1 = iBarShift(0, PERIOD_M1, Time[shift]);
   
   for(sh=sh1;sh>=0;sh--)
   {
      if(iBarShift(0, 0, iTime(0,PERIOD_M1,sh))!=shift) break;
      n++;
      ArrayResize(result,n);
      result[n-1] = iOpen(Symbol(),PERIOD_M1,sh1);
   }

   return(n);
}
I think so, check...
 
Who knows how to make the colour of take profit lines differ on the chart from the colour of stop loss automatically? and how to make an icon appear on the chart in the place where the order is placed?
 

Help me to understand. I build the MACD on the previous bar (i+1). I find max and min values visible in the MACD chart window. I put in Comment max, min and current values of the main and signal lines. Can someone help me figure it out.

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
#property  indicator_width1  2
//--- buffers
double Macd1Buffer[];
double Signal1Buffer[];

//--- for one bar
datetime last; 

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   //---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Macd1Buffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Signal1Buffer);
   
   IndicatorDigits(Digits+1);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
  Comment(""); 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    if(last>=Time[0]) return;
    
   double max_M1=-0.01,min_M1=0.01,
          max_S1=-0.01,min_S1=0.01,
          max1=-0.01,min1=0.01;
   
   int bars_counted=WindowBarsPerChart()-1,
       limit;  
       limit=bars_counted;
       
//---- macd counted in the 1-st buffer        
   for( int i=0; i<limit; i++)
              
   { 
      Macd1Buffer[i]=iMA(NULL,0,6,0,MODE_EMA,PRICE_CLOSE,i+1)-iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,i+1);
     
       max_M1=MathMax(Macd1Buffer[i],max_M1);
       min_M1=MathMin(Macd1Buffer[i],min_M1);
     
   }  
     
//---- macd counted in the 2-nd buffer       
   for( i=0; i<limit; i++)
           
   {
      Signal1Buffer[i]=iMAOnArray(Macd1Buffer,Bars,5,0,MODE_SMA,i);
      
       max_S1=MathMax(Signal1Buffer[i],max_S1);
       min_S1=MathMin(Signal1Buffer[i],min_S1);
            
   } 
   
       max1=MathMax(max_M1,max_S1);
       min1=MathMin(min_M1,min_S1);
   
   
   Comment( "\n"," Баров = ",WindowBarsPerChart()-1,
            "\n"," max1 = ",max1,
            "\n"," min1 = ",min1, 
            "\n"," Macd1Buffer = ",Macd1Buffer[i],
            "\n"," Signal1Buffer = ",Signal1Buffer[i]);
       
    last=Time[0];
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
MK07:

Help me to understand. I build the MACD on the previous bar (i+1). I find max and min values visible in the MACD chart window. I put in Comment max, min and current values of the main and signal lines. Can someone help me figure it out.

The data type double is printed with 4 decimal digits after the point. To output numbers with greater precision, you must use the DoubleToStr() function.

Example:

   Comment( "\n"," Баров = ",WindowBarsPerChart()-1,
            "\n"," max1 = ",max1,
            "\n"," min1 = ",min1, 
            "\n"," Macd1Buffer = ",DoubleToStr(Macd1Buffer[i],5),
            "\n"," Signal1Buffer = ",DoubleToStr(Signal1Buffer[i],5));
 
r772ra:

Data of type double is output with 4 decimal digits after the point. To output numbers with higher precision, use the DoubleToStr() function.

... and in your case, MK07, IndicatorDigits() means the number of digits in the data window and on the graph itself.