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

 
peace1984:

I tried changing to your version again... still doesn't work... it's in the EA, and it's visible as an EA...


Or did I get it wrong?

Files:
11_1_1.mq4  8 kb
 
AlexeyVik:


Or did I misunderstand something???



i understand the message "sys should not be 1" will pop up if sys!=1, but if you change the user from 0, it should be 1. and "sys should be 1" should appear

in your version of the EA, during testing in the upper left corner it says sys=0 and this should not be the case...

 
peace1984:

i understand the message "sys should not be 1" will pop up if sys!=1 and if you change the user from 0, it should be 1 and "sys should be 1" should pop up

Here's a look at the new launch. Lines up from the bottom.


Expert is loaded.

List of external variables: Sys = 0

Initialization passed.

next 3 lines print from EA.

Deinitialization reason 5(Input parameters were changed by the user)

External variable list: Sys = 1

Initialization passed

The following 3 lines, the print from the Expert Advisor.

Deinitialization reason 1(Program has been removed from the chart)


What do you want to clarify? I don't understand what is not working...

ps: don't pay attention to such symbols. It's an options account that's why such symbol names.

 
AlexeyVik:

That's not the point. Nobody wants your full secret code. Just write a full test piece of code with the misunderstanding. How about this?

when did you clear the highlighted line? Telepaths won't help, mere mortals even less...

Then there's this part.

I don't know what programmer wrote it, but it's completely inadequate... It's not your fault. You, like many others, just took the code and try to fix it...

If the counted_bars variable is equal to the number of bars remained unchanged since the last indicator call (the first line)

How it can become less than zero if(counted_bars < 0) I will never be able to understand...

The rest is nonsense too, but I'm too lazy to take it apart...


I totally agree with you. Why didn't you think of that? )

I am attaching the code and the file of such a wretched indicator.

Throw on graph, terminal naturally hangs, leave for 10 minutes (depending on PC performance. I have i5 3.1 Ghz), forcibly close MT, open log file with name "bug log.csv", observe the fact of bug IndicatorCounted().

#property indicator_separate_window
#property indicator_buffers 1

double Buffer_1[];

bool busy=false;
int han;

int init()
{
   han=FileOpen("bug log.csv", FILE_CSV|FILE_WRITE);
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1);       
   SetIndexBuffer(0,Buffer_1); 
   return(0);
}

int deinit()
{
   FileClose(han);
   return(0);
}

int start()
{
   //if(busy) return(0);
   int limit=3000;
   if(IndicatorCounted()>0) limit=1;
   
   for (int i=0; i<limit; i++)
   { 
      busy=true;
      FileWrite(han, TimeToStr(TimeCurrent(), TIME_MINUTES|TIME_SECONDS), DoubleToStr(i, 0), DoubleToStr(IndicatorCounted(), 0));
      FileFlush(han);
      
      for(int j=1; j<7000; j++)
        for(int k=1; k<7000; k++)
          double var=2*0.34*MathArccos(0.5)+1.33*MathArcsin(0.23)+1.53*MathArctan(0.11)+2.33*MathCos(0.23)+1.22*MathLog(12)+1.22;
      
      Buffer_1[i]=var;
   }
   
   busy=false;
   return(777);
}
Files:
bugqtest.mq4  2 kb
 

Hi all, can you advise what is missing in the script, if it closes all open orders if(AccountProfit()>1) condition is met, now it closes only part of the orders until the condition i

f(AccountProfit()>1)

{ for (i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUY)
{ OrderClose(OrderTicket(),OrderLots(),Bid,10,Green); return(0);
} else { OrderClose(OrderTicket(),OrderLots(),Ask,10,Red); return(0);
}}}
 
Expert:


I completely agree with you. Why didn't you think of that? )

I am attaching the code and the file of the woe-is-me indicator itself.

Throw on graph, terminal hangs of course, leave it for 10 minutes (depending on speed of PC. I have i5 3.1 Ghz), forcibly close MT, open log file with name "bug log.csv", observe the fact of bug IndicatorCounted().

I don't know. I've got this indicator that recorded a file like this.

Files:
test.zip  21 kb
 
AlexeyVik:

I don't know. I had this indicator write a file like this.




Thank you very much for your feedback!

Tried your version - same result ((

Do you have any idea why this is happening?
It's not just me. I've tried another PC, more powerful than mine, and it's the same problem.

Files:
bugflog.zip  122 kb
 
i999i:

Hi all, can you advise what is missing in the script, if it closes all open orders if(AccountProfit()>1) condition is met, now it closes only part of the orders until the condition i

f(AccountProfit()>1)

{ for (i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUY)
{ OrderClose(OrderTicket(),OrderLots(),Bid,10,Green); return(0);
} else { OrderClose(OrderTicket(),OrderLots(),Ask,10,Red); return(0);
}}}
return(0); was redundant, thank you all
 
Expert:


Thank you very much for your feedback!

Tried your version - same result ((

Any idea why this is happening?
I'm not the only one. I've tried it on another PC, more powerful than mine, and it's the same problem.

Either I can't understand you, or you don't understand something... What's wrong with the .csv file? Until the first bar is counted prev_calculated or IndicatorCounted() (in the old version) will be zero and this is correct.
 
AlexeyVik:
Either I can not understand you or you do not understand something ... What's wrong with the .csv file? As long as the first bar is not counted prev_calculated or IndicatorCounted() (in the old version) will be zero and this is correct.


Yes. It's understandable. I have attached my log. It turns out that when I get to the end from 20000th bar to 0th bar, it's like it starts to churn all 20000 bars again. That is, it either does not complete OnCalculate, or returns zero instead of rates_total.

But for some reason this bug didn't affect you. Everything is working fine in your case.

So, I can't understand what's wrong with my machine/system?