Object to Buffer (Help coders)

To add comments, please log in or register
Renato Jose
156
Renato Jose  

Hi,

How do I convert this object to a buffer? As this object is in sequential number I would also like to know how to put his name only as a prefix, can someone help me?

PS .: I tried very very hard so I am asking for your help, thanks in advance.



My last tried:

double SRZ = ObjectGet("PERFZONES_SRZHLL",i);


https://drive.google.com/drive/folders/1b3_U2Dv-n_Y0fLocXxQ-u4j239sfoOn7

put dfx_perfectzones.key in MQL4/Files


<ex4 file deleted>

William Roeder
20808
William Roeder  
Renato Jose: How do I convert this object to a buffer? … PS .: I tried very very hard
  1. Stop creating objects. Add a buffer of type DRAW_ARROW and use that.
  2. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help
Vyacheslav Nekipelov
6013
Vyacheslav Nekipelov  

Hi, you can try this:

string prefix;

for (int i=0; i<=ObjectsTotal();i++) {

        string name=ObjectName(i);
        if (ObjectType(name)==OBJ_HLINE) {
                
                if(StringSubstr(name,(StringFind(name, "PERFZONES_SRZHLL", 0)),16) == "PERFZONES_SRZHLL") prefix=name;
        }
}
Renato Jose
156
Renato Jose  
William Roeder:
  1. Stop creating objects. Add a buffer of type DRAW_ARROW and use that.
  2. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help
  for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(50000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   

            double SRZ = ObjectGet("PERFZONES_SRZHLL",OBJ_ARROW);          
            double SRZ1 = ObjectGet("PERFZONES_SRZHLU",OBJ_ARROW);   
             
      //Indicator Buffer 1
      if(SRZ!=0
      )
       
       {Buffer1[i] = Close[i] - iATR(NULL, PERIOD_CURRENT, 14, i);if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Buy Rule 1"); time_alert = Time[0]; }}                 
           
       
      else {Buffer1[i] = 0;}
        
      //Indicator Buffer 2
      if(SRZ1!=0
      )
       
       {Buffer2[i] = Close[i] + iATR(NULL, PERIOD_CURRENT, 14, i);if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Sell Rule 1"); time_alert = Time[0]; }}                 
 
      else { Buffer2[i] = 0; }
This is my code, now i want pass PERFZONES_SRZHLL and PERFZONES_SRZHLU (+_SEQUENTIAL NUMBER) to buffer and give me a signal.
Renato Jose
156
Renato Jose  
Vyacheslav Nekipelov:

Hi, you can try this:

i try, but dont make a buffer

Renato Jose
156
Renato Jose  
Vyacheslav Nekipelov:

Hi, you can try this:

I try  this too

   //--- main loop
   string prefixb;
   string prefixs;
   
for (int i=0; i<=ObjectsTotal();i++)
for(int is=0; is<=ObjectsTotal();is++) {

        string nameb=ObjectName(i);
        if (ObjectType(nameb)==OBJ_ARROW) continue;
        if (StringSubstr(nameb,(StringFind(nameb, "PERFZONES_SRZHLL", 0)),16) == "PERFZONES_SRZHLL") prefixb=nameb;
        
        string names=ObjectName(is);
        if (ObjectType(names)==OBJ_ARROW) continue;
        if (StringSubstr(names,(StringFind(names, "PERFZONES_SRZHLU", 0)),16) == "PERFZONES_SRZHLU") prefixs=names;
        
                 
            double SRZB = ObjectGet(nameb,i);       
            double SRZS = ObjectGet(names,i);   
             
      //Indicator Buffer 1
      if(SRZB>0.00000001&&SRZB<99999999
      )
       
       {Buffer1[i] = Close[i] - iATR(NULL, PERIOD_CURRENT, 14, i);if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Buy Rule 1"); time_alert = Time[0]; }}                 
           
       
      else {Buffer1[i] = 0;}
        
      //Indicator Buffer 2
      if(SRZS>0.00000001&&SRZS<99999999
      )
       
       {Buffer2[i] = Close[i] + iATR(NULL, PERIOD_CURRENT, 14, i);if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Sell Rule 1"); time_alert = Time[0]; }}                 
 
      else { Buffer2[i] = 0; }
      

and nothing

Renato Jose
156
Renato Jose  
like the images
Renato Jose
156
Renato Jose  
no more idea?
Seng Joo Thio
1759
Seng Joo Thio  
Renato Jose:
no more idea?

You need to be care with the use of 'i' - do you mean 'bar', or 'object index'?

Anyway here're some lines to retrieve the latest "PERFZONES_SRZHLU"... customize them to suit your needs:

      string lastUName = "";
      int lastUSerial = 0;
      string strMatchU = "PERFZONES_SRZHLU_";
      
      for (int i=ObjectsTotal()-1; i>=0; i--)
      {
         string oName = ObjectName(i);
         if (StringFind(oName,strMatchU)==0)
         {
            int oSerial = int(StringToInteger(StringSubstr(oName,StringLen(strMatchU))));
            if (lastUSerial==0 || lastUSerial<oSerial)
            {
               lastUSerial = oSerial;
               lastUName = oName;
            }
         }
      }
      
      datetime lastUTime = datetime(ObjectGet(lastUName,OBJPROP_TIME1));
      int lastUBar = iBarShift(_Symbol,_Period,lastUTime);
      Print ("Latest U name = ", lastUName,
             ", time of occurrence = ", TimeToStr(lastUTime,TIME_DATE|TIME_MINUTES),
             " (bar ", string(lastUBar), ")");
Renato Jose
156
Renato Jose  
Seng Joo Thio :

Do you need to be careful about using 'i' - do you mean 'slash' or 'object index'?

Anyway, here are some lines to retrieve as the last "PERFZONES_SRZHLU" ... customizable to meet your needs:

<Deleted - English please>



Renato Jose
156
Renato Jose  
here is my code, thanks everybody try help, more someone?
Files:
dforex.mq4 8 kb
12
To add comments, please log in or register