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

 

1) Make templates with preset EA and indicator parameters

2) Transfer parameters to indicators using GV

3) Call indicators to chart from EA using WINAPI

I prefer to draw an indicator chart from an EA via Arrow object

 

Salute!!!

I can't understand why Open=Close=High=Low - no difference, all prices are the same, four columns of the same prices in the file being created. Below is the code for the EA unloading the data.

int init()  
  {
   int h=FileOpen("H"+(Period()/60)+".csv",FILE_CSV|FILE_WRITE|FILE_READ,";");
    if(h<1)
      {
      Print("Файл не найден : ", GetLastError());
      return(false);
      }
   FileSeek(h, 0, SEEK_END);
   FileWrite(h,"Date","DayOfWeek","CLOSE","OPEN","High","LOW" );
   FileClose(h);        
  }
int start()
  {
   int h=FileOpen("H"+(Period()/60)+".csv",FILE_CSV|FILE_WRITE|FILE_READ,";");
    if(h<1)
      {
      Print("Файл не найден : ", GetLastError());
      return(false);
      }
      string Wtime=TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES);
      string Wday=DoubleToStr(DayOfWeek(),0);
      FileSeek(h, 0, SEEK_END);
      FileWrite(h,Wtime,Wday,DoubleToStr(iClose("GBPUSD",0,0),MarketInfo(Symbol(),MODE_DIGITS)),
                             DoubleToStr(iOpen("GBPUSD",0,0),MarketInfo(Symbol(),MODE_DIGITS)),
                             DoubleToStr(iHigh("GBPUSD",0,0),MarketInfo(Symbol(),MODE_DIGITS)),
                             DoubleToStr(iLow("GBPUSD",0,0),MarketInfo(Symbol(),MODE_DIGITS)));
      FileClose(h);   
      Print("Close=",Close[0]);
      Print("Open=",Open[0]);
      Print("Low=",Low[0]);
      Print("High=",High[0]);
     
   return(0);
  }
 

Good afternoon Gentlemen Programmers! Please take a look at this very interesting Expert Advisor! I want to fix something, namely: I really want to attach to it (preferably switchable) customizable trawl on take profit. I think (and hope) it will not be too difficult for a specialist to do!

/*Decompiling on this forum is against the law. first time warning. repeat - eternal ban (FAQ)*/

 
Andrew1001:

Good afternoon Gentlemen Programmers! Please take a look at this very interesting Expert Advisor! I want to fix something, namely: I really want to attach to it (preferably switchable) customizable trawl on take profit. I think (and hope) it will not be too difficult for a specialist to do!

/*Decompiling on this forum is against the law. first time warning. repeat - eternal ban (FAQ)*/



There you go! And how code then lay out that it would be possible to see it, improve it? (question to moderators)
 
ANG3110:

Well, I wrote a simpler example there.

***

And if you don't want to draw all the days, just 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=Close[i]; // я вставил закрытие оно работает на нижних таймфремах

//КАК ТУТ вставить High Low для  hour = 5 для ВСЕХ таймфремов ниже ограниченного таймфрема???????????

      }
      
      fx[i]=hm; 
   }
  
   return(0);
}
//***************************************************************

ONLY it is NOT clear how to insert iHigh and iLow for a particular hour, the same hour = 5; ??????????? you get the same eggs again...

PROFESSIONALLY I was using iClose iHigh iLow, but I forgot how the code was written for this variant... I remember the principle, but I forgot the details.

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 LastD =  iTime(Symbol(), PERIOD_D1, i-1); 
int LastDay = iBarShift(Symbol(), PERIOD_D1, LastD);

if(PrevDay>LastDay)  /// что было дальше НЕПОМНЮ!!!!, НО вариант ЛУЧШЕ, можно непарясь ставить уровни iHigh iLow iClose iOpen
{ 
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);
}

please help me to understand how to do it???????????????????

 

Once again, please help PLEASE!!!!

How to correctly put iHigh iLow iClose???? of a specific (H1) timeframe into the buffer, so that it reads correctly on the charts below????

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 LastD =  iTime(Symbol(), PERIOD_D1, i-1); 
int LastDay = iBarShift(Symbol(), PERIOD_D1, LastD);

if(PrevDay>LastDay)  
/// что было дальше НЕПОМНЮ!!!!, НО вариант ЛУЧШЕ, можно непарясь ставить уровни iHigh iLow iClose iOpen
{ 
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);
}
 

Hi, could you please tell me how to write it correctly?

The thing is, ObjectSetText doesn't do anything, so I get text instead of vertex caption.

ObjectCreate( "вершина",  OBJ_TEXT , WindowOnDropped( ) , Time[бар_вершина],  вершина+(10*Point)) ;  
       ObjectSet(  "вершина",  OBJPROP_COLOR, Crimson) ;
    ObjectSetText( "вершина", "вершина", 5, NULL, CLR_NONE) ;   
 
orb:

I can't understand why in the file being created Open=Close=High=Low - no difference, all prices are the same, four columns of the same prices. Below is the code of the Expert Advisor that unloads the data.


No relevant data for instrument and timeframe -- open the correct charts.

Uncorrected entry in the code:

FileWrite(h,Wtime,Wday,DoubleToStr(iClose("GBPUSD",0,0),MarketInfo(Symbol(),MODE_DIGITS)),..

Correct:

FileWrite(h,Wtime,Wday,DoubleToStr(iClose("GBPUSD",0,0),MarketInfo("GBPUSD",MODE_DIGITS)),..

The code works if the conditions are met.

 
Roll:


No relevant data for instrument and timeframe -- open the correct charts.

Incorrect entry in the code:

Correct:

As long as the conditions are met, the code works.

OK, I'll give it a try!)
 
nlp2311:

ONLY it is NOT clear how to insert iHigh and iLow for a specific hour, the same hour = 5; ??????????? it turns out the same eggs again...

PROFESSIONALLY I was using iClose iHigh iLow, but I forgot how the code was written for this variant... I remember the principle, but I forgot the details.

please help me understand how to do it???????????????????


You can draw hourly timeframe bars on hourly charts and below without taking prices from another timeframe. Linking with iHigh etc is not very useful as it slows down the indicator and needs to bump the other timeframe.

If it is possible to do everything on a single timeframe, that is preferable.

And how do you practically draw lines with hourly data on a smaller timeframe? It goes something like this.

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Gold
#property indicator_color4 Lime
//==============================
double H[],L[],O[],C[];
double hm,lm,om,cm;
int hr,hrp,di,f=0;
//************************************************************
int init()  
{   
   SetIndexBuffer(0,H);
   SetIndexBuffer(1,L);
   SetIndexBuffer(2,O);
   SetIndexBuffer(3,C);
   
   if (Period()>1440) f=1;
   
   di=60/Period();
   
   return(0);
}
//************************************************************
int start()
{
   if (f==1) {Comment("Период больше H1!"); return(0);}
   //-------------------------------
   int cbi=Bars-IndicatorCounted()-1; if (cbi<0) return(-1);
   if (cbi==1) cbi--;
   if (cbi>1) 
   {
      cbi=Bars-1;
      hm=High[cbi]; 
      lm=Low[cbi]; 
      om=Open[cbi]; 
      cm=Close[cbi]; 
   }
   //-------------------------------
   for(int i=cbi; i>=0; i--)
   {
      hrp=TimeHour(Time[i+1]); 
      hr=TimeHour(Time[i]);
      
      if (hrp!=hr) 
      {
         for (int j=i+1; j<=i+di; j++)
         {
            H[j]=hm;
            L[j]=lm;
            O[j]=om;
            C[j]=cm;
         }
         
         hm=High[i];
         lm=Low[i];
         om=Open[i];
         cm=Close[i];
      }
      else
      {
         if (High[i]>hm) hm=High[i];
         if (Low[i]<lm) lm=Low[i];
         cm=Close[i];
      }
      
      H[i]=hm;
      L[i]=lm;
      O[i]=om;
      C[i]=cm;
   }
   
   return(0);
}
//***************************************************************