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

 
Zhunko:
This is so for BOOL type. That is, for a bool from an older version of MQL4. This is not true for a single-byte bool. An overflow will occur if the value is greater than zero.

I wonder why then.

   bool b=2;

Does it compile without errors or warnings?

 
artmedia70:

I wonder why then.

bool b=2;
compiles without errors or warnings?

The assignment operator must be overloaded for the bool type. It monitors the overflow and if more than 1, it assigns and returns true.

In studio at warning level 4 there are often warnings when trying to insert some illogical type into a logical expression. Or vice versa, when applying a logical type in arithmetic operations.

 
Zhunko:

The assignment operator must be overloaded for the bool type. It monitors the overflow and, if greater than 1, it assigns and returns true.

In studio at warning level 4, there are often warnings when trying to insert some illogical type into a logical expression. Or vice versa, when applying a logical type in arithmetic operations.

It would be more logical to

#property strict

to issue a warning and leave it as in the old version without

 
artmedia70:

is not exactly true, but the gist is correct.

Actually: zero corresponds to false, and any other value other than zero corresponds to true

Without relying on the defaults, I change the init to a boolean variable and then use that only.
 

Well, I'm not a programmer after all...

There is account number 1 - five-digit with a min.lot 0.01 and step 0.01 (build 584); account number 2 - 4-sign with a min.lot 0.1 and step lots of 0.1 (build 584) and account number 3, just the same as the number 2, but the terminal build 509.

And there is a stop loss trawl:

void manageStops()
{ 
   string trailSymbol=Symbol();  
   for( int i = OrdersTotal()-1; i >=0 ; i-- ) 
   {
      if ( OrderSelect( i, SELECT_BY_POS ) == true ) 
      {  
         int trailOrderType = OrderType(); 
         if( OrderSymbol() != trailSymbol || trailOrderType > 1 || OrderProfit() < 0 ) continue; 
         double trailStopLoss = OrderStopLoss();   
         while( true ) {
            double trailStop = TrailingStop; 
            int trailDistance = MarketInfo( trailSymbol, MODE_STOPLEVEL ); 
            if( trailStop < trailDistance ) trailStop = trailStop+trailDistance;  
            bool modifyTrailingStop = false;  
            switch( trailOrderType ) 
            {
               case 0 : 
                  if(trailStopLoss < (Bid - (TrailingStop+TrailingStep) * pipPoints)) 
                  {
                     trailStopLoss = NormalizeDouble(Bid - TrailingStop * pipPoints,digits);   
                     modifyTrailingStop = true;       
                  }
                  break;    
               case 1 :                      
                  if(trailStopLoss > (Ask + (TrailingStop+TrailingStep) * pipPoints)) 
                  {
                     trailStopLoss = NormalizeDouble(Ask + TrailingStop * pipPoints,digits);             
                     modifyTrailingStop = true;             
                  }
               }                               
            if( modifyTrailingStop == false ) break;                       
            double trailTakeProfit = OrderTakeProfit(); 
            double trailPrice = OrderOpenPrice();  
            int trailTicket = OrderTicket();   
            if( ( OrderType() == OP_BUY && trailStopLoss > trailPrice && trailStopLoss < OrderOpenPrice() + ( MaxStop * pipPoints ) ) 
                  || ( OrderType() == OP_SELL && trailStopLoss < trailPrice && trailStopLoss > OrderOpenPrice() - ( MaxStop * pipPoints ) ) )

            OrderModify( trailTicket, trailPrice, trailStopLoss, trailTakeProfit,0);
            break; 
           } 
        }  
     }  
  return;   
} 

Why on account #1 the stoploss is trawled normally, but on accounts #2 and 3 "error 130"??? Although the logic is subverted, but it works in one case...

 
evillive:

Well, I'm not a programmer after all...

There is account number 1 - five-digit with a min.lot 0.01 and step 0.01 (build 584); account number 2 - 4-sign with a min.lot 0.1 and step lots of 0.1 (build 584) and account number 3, just takoe same as number 2, only terminal build 509.

And there is a stoploss trawl:

Why is stop loss on account 1 trailing normally, but accounts 2 and 3 show "Error 130"? Although the logic is subverted, but it works in one case...


The question itself implies that the problem is a 5-digit or 4-digit account. Looking at the code. Where is the pipPoint variable defined and what does it equal? That is most likely where the problem lies.
 
pro_:

The question itself suggests that the issue is about a 5 or 4 digit count. I'm looking at the code. Where is the pipPoints variable defined and what does it equal? That's most likely where the problem lies.

I defined pipPoints = MarketInfo( Symbol(), MODE_POINT) in the init;

I increased the MaxStop value and the trawl should change in increments with larger ones, but it changes in increments of 1 point, at least it starts trawling at 4 digits... I'll still need to modify the logic, I need adjustable pitch.

 
smdm:

Hello!

The question is as follows. I have a Heiken Ashi Smoothed indicator https://www.mql5.com/ru/code/7930.

What changes should I make to the code of the indicator to be able to attach this indicator on a five-minute chart on a higher timeframe, for example on a thirty-minute or one-hour timeframe?

Thank you.


I've asked a similar question - how to apply an indicator from the weekly chart to the H4 chart. I pounded on several forums . and here too, but did not get anything better than to prescribe the size of a large TF-m in the code for a smaller one, no one suggested. although if your indicator has simple logistics and takes for its calculation of simple bar calculations, it is possible. if you can text the code and a screen on n1 a studio with their explanations .
 

and so the indicator should draw a vertical line on the bar on which the price closes in the middle of the bar.....

double close_price(int nomer_bara)
{
if(nomer_bara<1)
{
Alert("нельзя анализировать текущий бар");
}
else
{
if(iClose(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)<iHigh(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)/3)//возвращает 1/3 если цена текущего бара закрылась ниже 1/3 его спреда 
{
return(1/3);
}
if(iClose(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)>iHigh(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)/3&&(iClose(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)<iHigh(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)*2)/3)//возвращает 2/3 если цена текущего бара закрылась ниже 2/3 и выше 1/3 его спреда 
{
return(2/3);
}

if((iClose(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)>(iHigh(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara))*2)/3&&iClose(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)<iHigh(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara))//возвращает 1 если цена текущего бара закрылась выше 2/3 его спреда
{
return(1);
}
}

}

 if(close_price(1)==1/3)// в случае если цена закрылась внизу то нарисовать линию на этом баре
   {
 SetVLine(Red, "", Time[1], STYLE_SOLID, 2);
   }
и так вся проблема заключается в том что линия рисуется на каждом баре не пойму какого черта... помогите пожалуйста

 
a little wrong in the description at first ...it should draw if it closes in 1/3
Reason: