[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 406

 
Thank you! But it didn't work with all the examples given in the link either...
 
int start()
  {
   int i, limit;
   int counted_bars=IndicatorCounted();
//---- 
   if( counted_bars>0) counted_bars--;
   limit=Bars- counted_bars;
//---- 
   for( i= limit; i>=0; i--) 

      if (Close[ i+1]>0) 

         Buffer0[ i]=Close[ i]/Close[ i+1];

   for( i= limit; i>=0; i--) 

      double StdDev=iStdDevOnArray( Buffer0,Bars,16,0,MODE_SMA, i);

      Buffer1[ i]= StdDev;
      

   return(0);
  }
It's not working for some reason, help me figure out what the problem is! Thank you!
 
Mr-Franklyn >>:
Почему-то не работает, помогите разобраться в чём проблема! Спасибо!

brackets are missing

 

Trying to make an Equity trawl to fix it before the extra orders come in:


wrote this code:

int init(){
      //Наиль - фиксируем сумму средств на начало работы советника
       EquityStart=AccountEquity();
       StartBalance=AccountBalance();
       if(GlobalVariableSet("EquityStart", EquityStart)==0)
       if(GlobalVariableSet("StartBalance", StartBalance)==0)
       return(false);
       //---- продолжение обработки
//===============

//трал у  меня выведен в отдельную функцию:
bool fPrEquity(){
   if(! PrEquity)return(true);
   static bool ClAllFlag=false;
   double Pr2=0;

      StartBalance=GlobalVariableGet("StartBalance");
      Pr2=AccountEquity()- StartBalance;
      
       if( Pr2>= ProcentToclose/100.0*AccountEquity()){
      Print ("Средстава возросли. Закрываем все!!!");
         ClAllFlag=true;
            StartBalance=AccountEquity();
            GlobalVariableSet("StartBalans", StartBalance);
         
       }
      if( ClAllFlag){
         if( fOrderCloseMarket(true,true)==0){
            ClAllFlag=false;

            return(true);
         }
         else{
            return(false);
         }
      } 
   return(true);           
}

But the EA starts working like this:


Who can tell me what the problem is?

 
Nail_Saby >>:

Пытаюсь сделать трал Эквити, чтобы зафиксировать его раньше, чем наберет лишние ордера:


написал такой код:

Но советник начинает работать так:


Кто подскажет, в чем проблема?

You seem to be making the wrong comparison:

if(Pr2>=ProcentToclose/100.0*AccountEquity())
and you should
if(Pr2>=ProcentToclose/100.0*StartBalance)
 
alsu >>:

Вы, кажется, не с тем сравниваете:

Fixed it, but it didn't help...

By the way, the log always says that

Средстава возросли. Закрываем все!!!

and writes the amount of equity.

Maybe it's something to do with cycles?

 
Nail_Saby писал(а) >>

Trying to make an Equity trawl to fix it before the extra orders come in:

wrote this code:

But the EA starts working like this:

Who can tell me what the problem is?

After the first execution of the function, the value of the ClAllFlag variable takes the value true and does not change its value. The variable type should be simply bool.

 

Explain what I'm doing wrong



I get the error that there is no directory on the ftp server, but I know for sure it is there, where did I go wrong?

 
Vinin >>:

После первого запуска функции значение переменной ClAllFlag принимает значение true и больше не меняет своего значения. Надо бы тип переменной сделать просто bool.

you mean to remove static before bool ClAllFlag ?

But this variable is used in other places in the code as well... where all orders are closed.

I've tried this - it doesn't help.

Confused by the constant messages in the log...Maybe somewhere

return
is it worthless?
 
Nail_Saby писал(а) >>

you mean remove static before bool ClAllFlag ?

But this variable is used in other places in the code... where all the orders are closed.

I tried this - it doesn't help.

I'm confused by constant messages in the log... Maybe it's somewhere

>> is it worthless?

What is Pr2 equal to?

Probably you have to just reprinter the values.

Reason: