Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 323

 
artmedia70:

Shit, Boris. I've written before. Well, make a simulated floating spread right in your EA. What's stopping you from adding a random number in the floating spread range to the bid and opening with stop orders. And close by value, not by stop orders. It's more difficult than just setting a larger static spread, but if you really need it, you can do it. At the same time, in the tester, set the minimum spread.

This is just ... This is just a way of thinking.

I checked it, and unfortunately, this is not the solution! Error 138! It is quite clear that now the tester and the Expert Advisor have different Ask! That's why it rakwot! Adjusting the algorithm to the spread makes no sense!

I will use the increased constant spread for now. Maybe the developers will make an imitation of the varying spread and delays in order execution!

If I was in Moscow I would invite you to pancakes! :))

And here I have only crepes. :(( But I would have invited you anyway!

 

Greetings forum users!

Can you advise a newbie why the above code deletes every other object? Half of it remains. What's wrong with it?

int deinit()
  {
  int    obj_total=ObjectsTotal();
  
  for(int i=0;i<obj_total;i++)
      {
      ObjectDelete(ObjectName(i)); 
      }
   return(0);
  }
 
Parkhom:

Greetings forum users!

Can you advise a newbie why the above code deletes every other object? Half of it remains. What's wrong with it?

And so:

int deinit()
  {
  ObjectsDeleteAll();
  return(0);
  } 
 
r772ra:

And so:


OK, put it on reserve :) If you can't do it any other way.

ObjectsDeleteAll() - deletes everything. I want it to be beautiful and delete objects drawn by the indicator.

 
Parkhom:


For example: "Ok, left it on standby :) If there is no other way.

ObjectsDeleteAll() - deletes everything. But I want it to be nice and delete objects drawn by the indicator.

int deinit() {
// -------- Блок удаления всех объектов, построенных на графике --------
   string Name_Del[1]; 
   int Quant_Del=0;                    
   int Quant_Objects=ObjectsTotal();   
   int LenPref=StringLen(Prefix);
   ArrayResize(Name_Del,Quant_Objects);
   for(int k=0; k<Quant_Objects; k++) {
      string Obj_Name=ObjectName(k);   
      string Head=StringSubstr(Obj_Name,0,LenPref);
      if (Head==Prefix) {                              
         Quant_Del+=1;        
         Name_Del[Quant_Del-1]=Obj_Name;
         }
     }
   for(int i=0; i<Quant_Del; i++) ObjectDelete(Name_Del[i]); 
// ----- Конец блока удаления всех объектов, построенных на графике -----
   return(0);
}

In init(), you also need to initialize the Prefix variable declared globally

For example:

int init() {
   IndicatorShortName("IB_"+Symbol());
   Prefix="IB_"+Symbol();
//-----------------------------
   SetIndexBuffer(0, isbup);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,181);
   SetIndexEmptyValue(0,0.0);
   SetIndexLabel(0,"Long Signal");
//-----------------------------
   SetIndexBuffer(1, isbdn);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,181);
   SetIndexEmptyValue(1,0.0);
   SetIndexLabel(1,"Short Signal");
//-----------------------------
   SetIndexBuffer(2, arrup);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexArrow(2,159);
   SetIndexEmptyValue(2,EMPTY_VALUE);
   SetIndexLabel(2,"Long Level");
//-----------------------------
   SetIndexBuffer(3, arrdn);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexArrow(3,159);
   SetIndexEmptyValue(3,EMPTY_VALUE);
   SetIndexLabel(3,"Short Level");
//-----------------------------
   return(INIT_SUCCEEDED);
}
 
borilunad:

Checked it, and unfortunately, that's not the answer! Error 138 appears! It's quite understandable that the tester and the expert now have different Asks! That's why it rakevotes! Adjusting the algorithm to the spread makes no sense!

I will use the increased constant spread for now. Maybe the developers will make an imitation of the varying spread and delays in order execution!

If I was in Moscow I would invite you to pancakes! :))

And here I have only crepes. :(( But I would have invited you anyway!

I told you not to open on the market, but using stop orders. I told you right away.

And thanks for the pancakes. You can Skype them to me. ;)

 
Parkhom:


I put it on hold :) If there is no other way.

ObjectsDeleteAll() - deletes everything. But I want to have a nice look and remove objects drawn by the indicator.


Would you like to search and delete them by name? Or maybe you have half a thousand objects there?


And if in a loop, it's worth trying the reverse sequence in a loop

 for(int i=obj_total-1;i>=0;i--)
      {
      ObjectDelete(ObjectName(i)); 
      }
 
I've started to test my Expert Advisor, I started to have problems with the tester, I would like to ask experienced testers how much the tester can aggravate? I'm not sure how much of a problem the tester is having, but I'd like to know how much the tester is having.
 
Burger:
I've started to test my Expert Advisor, I started to have problems with the tester, I would like to ask experienced testers how much the tester can aggravate? I don't know, I started to test my tester, it started to have problems with it, I would like to ask experienced "testers" how much the tester can make worse.
What does the tester have to do with it?
 
evillive:

Is it better to search by name and delete? Or are there half a thousand objects in there?

And if by loop, it is worth trying the reverse sequence in the loop


Thank you. It worked.

PS: Not half a thousand, but a hundred will do. Name unique set - easier to find and remove everything through the loop.

artmedia70:
Thank you.
Reason: