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

 
PapaYozh:

PriceDelta = Point * 30;

Comparing real numbers


Thanks again so much

ps although I still don't understand why you can't compare doubles

 

Good afternoon! Here's what I don't understand. Turned on the tester. It's been about forty-five minutes and it's actually been over an hour, I've turned off the internet, thunderstorm.

I can't see if something is going on or a glitch ???? Something seems to be wrong, I dare not turn it off.

 
sdm:


Thanks so much again

ps although I still don't understand why you can't compare double numbers

You can still compare constants, but you can't compare numbers after you calculate them. For example, after calculation, you can get two identical numbers with different values. This is not a paradox if you consider the accuracy set in EPSILON.
 
sdm ! The point is that the number can easily be 1000.00001 and 1000.000001, and they are different numbers. In the program it could easily be, but you can't see it at first glance. Of course you can compare the numbers beforehand, but it's better to be careful.
 
So what's with the tester, please!? That there are no numbers above the bar at all, the usual 3\64668 or whatever?
 
Dimka-novitsek:
What about the tester, please? That there are no numbers above the bar at all, the usual 3\64668 or whatever?

Until the first pass is completed, there will be no numbers. :(

You'd better write to the CD.

 

Thank you!!! Got it.

What's SD?

 
Dimka-novitsek:

Thank you!!! Got it.

What's SD?

"Service Desk"
 

Good afternoon colleagues!

Please advise if the logic in the code is correct.

The gist of the code is the formula:

TRIN = (Growing pairs/Decreasing pairs)/ (Volume of growing pairs/Decreasing pairs)

double Index[];
double instr_up, instr_dn, vol_dn, vol_up;
//+------------------------------------------------------------------+
int init()
{
   SetIndexBuffer(0,Index);
   SetIndexStyle(0,DRAW_LINE);   
   string Tf;
   if(Period()==1) Tf="M1";
   if(Period()==5) Tf="M5";
   if(Period()==15) Tf="M15";
   if(Period()==30) Tf="M30";
   if(Period()==60) Tf="H1";
   if(Period()==240) Tf="H4";
   if(Period()==1440) Tf="D1";
   if(Period()==10080) Tf="W1";
   if(Period()==43200) Tf="MN";         
        string short_name="TRIN("+Depth+","+Tf+")";
        IndicatorShortName(short_name);
   IndicatorDigits(0);
   return(0);
}

//---- функция проверки цены закрытия на максимум Доллара США за период Depth
int newh(string symbol,int i)
      {
         datetime time_bar = Time[i];
         int bar_no = iBarShift(symbol, Period(), time_bar, false);
                
         if(symbol=="EURUSD" || symbol=="GBPUSD" || symbol=="AUDUSD" || symbol=="NZDUSD")
            {

               int j=iLowest(symbol,Period(),MODE_CLOSE,Depth,bar_no);
               if (iClose(symbol,Period(),bar_no)==iClose(symbol,Period(),j))                    
                  {
                     int nh=1;                                                 
                  }
               else                                                                 
                  {
                     nh=0;                                              
                  }       
            }
         else
            {
               j=iHighest(symbol,Period(),MODE_CLOSE,Depth,bar_no);
               if (iClose(symbol,Period(),bar_no)==iClose(symbol,Period(),j))                    
                  {
                     nh=1;                                                 
                  }
               else                                                                 
                  {
                     nh=0;                                              
                  }             
            }
         return(nh);      
      }

//---- функция проверки цены закрытия на минимум Доллара США за период Depth
int newl(string symbol,int i)
      {
         datetime time_bar = Time[i];
         int bar_no = iBarShift(symbol, Period(), time_bar, false);      
      
         if(symbol=="EURUSD" || symbol=="GBPUSD" || symbol=="AUDUSD" || symbol=="NZDUSD")
            {
               int j=iHighest(symbol,Period(),MODE_CLOSE,Depth,bar_no);
               if (iClose(symbol,Period(),bar_no)==iClose(symbol,Period(),j))                    
                  {
                     int nl=1;                                                 
                  }
               else                                                                 
                  {
                     nl=0;                                              
                  }       
            }
         else
            {
               j=iLowest(symbol,Period(),MODE_CLOSE,Depth,bar_no);
               if (iClose(symbol,Period(),bar_no)==iClose(symbol,Period(),j))                    
                  {
                     nl=1;                                                 
                  }
               else                                                                 
                  {
                     nl=0;                                              
                  }             
            }
         return(nl);      
      }
//+------------------------------------------------------------------+
int start()
{
   int limit=Bars-IndicatorCounted();
   for(int i=1; i<limit; i++)
          {       
            if (newh("EURUSD",i) > 0                              //-- Если пара росла, то
             {instr_up=instr_up+1;vol_up+=iVolume("EURUSD",0,i);}   //-- instr_up - увеличиваем на 1 и vol_up - увеличиваем на Volume по этой паре   
           else //if (newl("EURUSD",i) > 0)                         //-- иначе
              {instr_dn=instr_dn+1;vol_dn+=iVolume("EURUSD",0,i);}  //-- instr_dn - увеличиваем на 1 и vol_dn - увеличиваем на Volume по этой паре
              
            if (newh("GBPUSD",i) > 0)
             {instr_up=instr_up+1;vol_up+=iVolume("GBPUSD",0,i);}
           else //if (newl("GBPUSD",i) > 0)
              {instr_dn=instr_dn+1;vol_dn+=iVolume("GBPUSD",0,i);}
            
            if (newh("USDCHF",i) > 0)
             {instr_up=instr_up+1;vol_up+=iVolume("USDCHF",0,i);}
           else //if (newl("USDCHF",i) > 0)
              {instr_dn=instr_dn+1;vol_dn+=iVolume("USDCHF",0,i);}
            
            if (newh("USDJPY",i) > 0)
             {instr_up=instr_up+1;vol_up+=iVolume("USDJPY",0,i);}
           else if (newl("USDJPY",i) > 0)
              {instr_dn=instr_dn+1;vol_dn+=iVolume("USDJPY",0,i);}
            
            if (newh("AUDUSD",i) > 0)
             {instr_up=instr_up+1;vol_up+=iVolume("AUDUSD",0,i);}
           else //if (newl("AUDUSD",i) > 0)
              {instr_dn=instr_dn+1;vol_dn+=iVolume("AUDUSD",0,i);}
            
            if (newh("USDCAD",i) > 0)
             {instr_up=instr_up+1;vol_up+=iVolume("USDCAD",0,i);}
           else //if (newl("USDCAD",i) > 0)
              {instr_dn=instr_dn+1;vol_dn+=iVolume("USDCAD",0,i);}
            
            if (newh("NZDUSD",i) > 0)
             {instr_up=instr_up+1;vol_up+=iVolume("NZDUSD",0,i);}
           else //if (newl("NZDUSD",i) > 0)
              {instr_dn=instr_dn+1;vol_dn+=iVolume("NZDUSD",0,i);}   
     
     if (instr_dn == 0)instr_dn=EMPTY;  // -- Если 
     if (vol_dn == 0)vol_dn=EMPTY;      // -- значения
     if (instr_up == 0)instr_up=EMPTY;  // -- нулевые
     if (vol_up == 0)vol_up=EMPTY;
     
     Index[i]=(instr_up/instr_dn)/(vol_up/vol_dn);  // -- TRIN
     
     instr_up=0;instr_dn=0;vol_up=0;vol_dn=0;  // -- Обнуление
     }
     
        return(0);
}

This is what came out:

TRIN

Thank you!

 

Is it possible to determine from the code in which window/subwindow the object was created?

Reason: