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

 
Thank you!!!!
 
int start()
  {
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(Period() > 240)  return(-1);

int LastPrevDay = iBars(Symbol(), PERIOD_D1);
int barnH= iBars(Symbol(),PERIOD_H1);

for (int i = LastPrevDay-1; i >= 0; i--)
{
datetime NowDay = iTime(Symbol(), PERIOD_D1, i);
int PrevDay = iBarShift(Symbol(), PERIOD_D1, NowDay);
datetime x_time= StrToTime(TimeToStr(NowDay, TIME_DATE)+" "+shift_time); 
int x_shift= iBarShift(Symbol(),PERIOD_H1,x_time);
double CL= iClose(Symbol(),PERIOD_H1,x_shift);

int LastDay = iBarShift(Symbol(), PERIOD_D1,iTime(Symbol(), PERIOD_D1, i))-1;
if(LastDay>0)   // тут я запутался 
buffer[i]= CL;
}
return(0);

Please help me figure this out. I want the line to be correct. But the buffer gives just a line, it should be flat in the middle of the day, like the pivot line.... I have a line coming from the level of X hour of the previous day.

PLEASE UNDERSTAND.... I can't make it out.

 
nlp2311:

Please help me figure this out. I want the line to be correct. But the buffer gives just a line, it should be flat in the middle of the day, like the pivot line.... I have a line coming from the level of X hour of the previous day.

PLEASE FIGURE IT OUT.... i can't figure it out(((

Well, let's say you need to take a muving at 5 o'clock on any timeframe, of course not on the daily, but on a smaller one. Let's say starting at one o'clock or less.

And draw it to 5 o'clock the next day. Here's how it's done.

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue
#property indicator_width1 2
//==============================
extern int    hour = 5;
extern int    hrma = 4;
//==============================
double fx[];
double mai;
int p,hr,hrp;
//************************************************************
int init()  
{   
   SetIndexBuffer(0,fx);
   
   p=hrma*60/Period(); // пересчет периода мувинга на любой таймфрейм
   
   return(0);
}
//************************************************************
int start()
{
   int cbi=Bars-IndicatorCounted()-1; if (cbi<0) return(-1);
   if (cbi==1) cbi--;
   if (cbi>1) cbi=Bars-p-1;
   //-------------------------------
   for(int i=cbi; i>=0; i--)
   {
      hrp=TimeHour(Time[i+1]); 
      hr=TimeHour(Time[i]);
      
      if (hr==hour && hrp!=hr) mai=iMA(NULL,0,p,0,0,0,i); // сам простой мувинг, в момент, когда час равен нашему и не неравен на предыдущем баре
      
      fx[i]=mai; // просто приравнивание индикаторного буффера к глобальной переменной 
   }
  
   return(0);
}
//***************************************************************
 

Yes I did, same answer... what with

ti=Time[i]; // время текущего бара
      
      tiip=tii; // предыдущее состояние времени
      tii=(ti-dth)/dtd*dtd;// время начала суток сдвинутое на нужный нам час
      
      if (tiip!=tii)

BUT THE RESULT IS WRONG!!!!!!!!!!!!!!! I took an example from the python through

if(TimeDay(Time[i]) != TimeDay(Time[i+1]))
The general view is like this

int start()
  {
double LastHigh,LastLow;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(Period() > 240)  return(-1);

int LastPrevDay = iBars(Symbol(), PERIOD_D1);
int barnH= iBars(Symbol(),PERIOD_H1);

for (int i = LastPrevDay-1; i >= 0; i--)
{
datetime NowDay = iTime(Symbol(), PERIOD_D1, i);
int PrevDay = iBarShift(Symbol(), PERIOD_D1, NowDay);
datetime LastD =  iTime(Symbol(), PERIOD_D1, i+1);
int LastDay = iBarShift(Symbol(), PERIOD_D1, LastD);

if(TimeDay(Time[i]) != TimeDay(Time[i+1]))
{ 
datetime x_time= StrToTime(TimeToStr(NowDay, TIME_DATE)+" "+shift_time); 
int x_shift= iBarShift(Symbol(),PERIOD_H1,x_time);
double CL= iClose(Symbol(),PERIOD_H1,x_shift);
}

buffer[i]= CL;
}

return(0);
}

IT IS STILL NOT THE RIGHT RESULT.

The problem is simple to put a line HOW pivot is flat, but not by pivot level, but from a value of some hour. That's it!!! And I'm struggling and don't understand how...RIGHT the line from X hour to Time[0] !!!!!!!!!!!!!!!!

 
nlp2311:

Yes I did, same answer... what with

BUT THE RESULT IS WRONG!!!!!!!!!!!!!!! I took an example from the python through

The general view is like this

IT IS STILL NOT THE RIGHT RESULT.

The problem is simple to put a line HOW pivot is flat, but not by pivot level, but from a value of some hour. That's it!!! And I'm struggling and don't understand how to...RANGE the line from X hour to Time[0] !!!!!!!!!!!!!!!!

Well I wrote a simpler example there.

If we have written some value at the point of the required hour, then it simply equates to this value.

for(int i=cbi; i>=0; i--)
{
hrp=TimeHour(Time[i+1]);
hr=TimeHour(Time[i]);

if (hr==hour && hrp!=hr) x=

fx[i]=x; // just equate indicator buffer with global variable
}

Same for anything, pivot or whatever. Simply, if it is a daily Pivot, then daily levels are calculated at this point for the daily amount of bars.

Here is the daily highs at 5 o'clock, for example. The same can be done with all other levels. Copy the code into an empty indicator, compile and see, I think this is about right.

And if you don't need to draw all the days, but only the last one, it's done a little differently. I'm just suggesting a more professional approach.

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue
#property indicator_width1 2
//==============================
extern int    hour = 5;
extern int    hrma = 24;
//==============================
double fx[];
double hm;
int p,hr,hrp;
//************************************************************
int init()  
{   
   SetIndexBuffer(0,fx); SetIndexEmptyValue(0,EMPTY); 
   
   p=hrma*60/Period();
   
   return(0);
}
//************************************************************
int start()
{
   int cbi=Bars-IndicatorCounted()-1; if (cbi<0) return(-1);
   if (cbi==1) cbi--;
   if (cbi>1) cbi=Bars-p-1;
   //-------------------------------
   for(int i=cbi; i>=0; i--)
   {
      hrp=TimeHour(Time[i+1]); 
      hr=TimeHour(Time[i]);
      
      if (hr==hour && hrp!=hr) 
      {
         fx[i+1]=EMPTY;
         hm=High[iHighest(NULL,0,MODE_HIGH,p,i+1)];
      }
      
      fx[i]=hm; 
   }
  
   return(0);
}
//***************************************************************
 
Hi all. How do you add indicators to the chart? I.e., I have an Expert Advisor that calculates a certain value of, say, iMA. How does one draw the indicator on the chart? I think so, using the special function or "manually" through the trendline? Is there an easier way to display the indicator with parameters from the EA?
 
Pyro:
Hi all. If I wanted to place them on the chart, I would not have to draw them myself. I.e., I have an EA where I calculate some values like iMA. How does it draw the indicator on the chart? I think so, using the special function or "manually" through the trendline? Is there an easier way to display the indicator with parameters from the EA?

I have not met, maybe someone wrote a forum search for mapping buffers through trendline.

Or write it yourself, there is nothing complicated.

 
Pyro:
Hello there. How do I add indicators to the chart? I.e., I have an Expert Advisor that calculates some values like iMA. How does one draw the indicator on the chart? I think so, using the special function or "manually" through the trendline? Is there an easier way to display the indicator with parameters from the EA?


If the EA is attached to the chart and there is something inside it, then to see what it is, we need to create an indicator with exactly the same function and set the same parameters as in the EA and apply them to the chart. Or if it is a standard MT function, such as a muving, it also has to be applied to a chart and the same parameters as in the Expert Advisor have been set. The Expert Advisor itself does not draw indicators on the chart. It is drawn in the Strategy Tester only after testing. It will not do it during trading. Another way, but bothersome, is to draw objects, like dashes ObjectCreate(name+Time[0],OBJ_ARROW,0,Time[0],price); ObjectSet(name+Time[0],OBJPROP_ARROWCODE,4); or trendline segments, but then the function state on the previous bar must be saved. But it is when the indicator cannot be applied, for example, when something must be drawn by Askas and MT does not store the array of Askas or some synthetic of two pairs. That's why you have to make a twist to control it.

Well, you can also make a template (tpl) on which to attach what you need. But practically it is better to make a custom indicator, and manually set and write a new profile and when you want to trade, just call the appropriate profile. It is a technics on the verge of fantasy.

 
It's a pain in the ass, if the parameters are constantly changing in the Expert Advisor. OK, thanks colleagues, now there is certainty.
 
Transfer from the EA to the indicator via GV.
Reason: