Problem with EMPTY_VALUE - page 2

 
"I don't believe you. Print the values and show the log." Stop telling us what you THINK you have and show us the printout of what you ACTUALLY have (both variables,) before the IF and put a print statement inside the IF showing it doesn't execute.
 

TerminalCode

I donno what log you are talking about, so I decided to upload the screenshots. As you see, Here1 or Here2 message never gets printed (I waited for long dont worry) but the values of slope_up and slope_dn are as I reported above.

 
mkheidzedavid: I donno what log you are talking about, so I decided to upload the screenshots.
  1. You run the EA under the TESTER and your PRINT statments appear in the JOURNAL tab.
  2. next time

    Play video
    Please edit your post.
    For large amounts of code, attach it.

  3. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a cludge, don't use it.Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
 
int j = 0;
      double su = 0.0, sd = 0.0, su_prev = 0.0, sd_prev = 0.0;
      
      while(true)
      {
         su = iCustom(Symb, MajorPeriod, "Slope_Direction_Line", SlopePeriod, SlopeMethod, SlopePrice, 0, j);
         sd = iCustom(Symb, MajorPeriod, "Slope_Direction_Line", SlopePeriod, SlopeMethod, SlopePrice, 1, j);
         su_prev = iCustom(Symb, MajorPeriod, "Slope_Direction_Line", SlopePeriod, SlopeMethod, SlopePrice, 0, j + 1);
         sd_prev = iCustom(Symb, MajorPeriod, "Slope_Direction_Line", SlopePeriod, SlopeMethod, SlopePrice, 1, j + 1);
         
         if((!(su > EMPTY_VALUE - Point) && (sd > EMPTY_VALUE - Point) && (su_prev > EMPTY_VALUE - Point) && !(sd_prev > EMPTY_VALUE - Point))
            || (su > EMPTY_VALUE - Point) && !(sd > EMPTY_VALUE - Point) && !(su_prev > EMPTY_VALUE - Point) && (sd_prev > EMPTY_VALUE - Point))
         {
            Sub_Ind_Min = ArrayMinimum(Low, SubFiboBars, MajorPeriod * j / Period());
            Sub_Ind_Max = ArrayMaximum(High, SubFiboBars, MajorPeriod * j / Period());

            break;
         }
         
         j++;
      }
Thanks guys for your answers. The code above never enters into the if scope. I donno why. The Slope_Direction_Line draws a line with green and red colors. When the greenBuffer obtains the value RedBuffer obtains the value of EMPTY_VALUE and vise versa. Can you help me find out the reason why the if scope is never reached? Thank you
 
Don't double post and don't hijack someone else's thread
 
Sorry I made a mistake there. (deleted...) Anyone?...
 

You don't need to normalize EMPTY_VALUE.

int start()
  {
//----
   double val = 0;
   int goodcnt = 0;
   int badcnt = 0;
   
   for(int i=0; i<1000000; i++)
   {val = 2147483647;
    if(val == EMPTY_VALUE)
    {goodcnt++;
    }
    else
    {badcnt++;
   }}
   Print ("val was not equal to EMPTY_VALUE ",badcnt," times.");
   Print ("val was equal to EMPTY_VALUE ",goodcnt," times.");
   Print ("EMPTY_VALUE is ",EMPTY_VALUE);
//----
   return(0);
  }

output:

2013.08.16 22:41:42 EmptyValue test EURUSD,M1: EMPTY_VALUE is 2147483647
2013.08.16 22:41:42 EmptyValue test EURUSD,M1: val was equal to EMPTY_VALUE 1000000 times.
2013.08.16 22:41:42 EmptyValue test EURUSD,M1: val was not equal to EMPTY_VALUE 0 times.


 

Actually I had done such but the result was still the same (it didn't enter the if block). That's why I blamed it on EMPTY_VALUE equality and decided to normalize that value. If the script was like this:

int j = 0;
      double su = 0.0, sd = 0.0, su_prev = 0.0, sd_prev = 0.0;
      
      while(true)
      {
         su = iCustom(Symb, MajorPeriod, "Slope_Direction_Line", SlopePeriod, SlopeMethod, SlopePrice, 0, j);
         sd = iCustom(Symb, MajorPeriod, "Slope_Direction_Line", SlopePeriod, SlopeMethod, SlopePrice, 1, j);
         su_prev = iCustom(Symb, MajorPeriod, "Slope_Direction_Line", SlopePeriod, SlopeMethod, SlopePrice, 0, j + 1);
         sd_prev = iCustom(Symb, MajorPeriod, "Slope_Direction_Line", SlopePeriod, SlopeMethod, SlopePrice, 1, j + 1);
         
         if((su != EMPTY_VALUE && sd == EMPTY_VALUE && su_prev == EMPTY_VALUE && sd_prev != EMPTY_VALUE)
            || (su == EMPTY_VALUE && sd != EMPTY_VALUE && su_prev != EMPTY_VALUE && sd_prev == EMPTY_VALUE))
         {
            Sub_Ind_Min = ArrayMinimum(Low, SubFiboBars, MajorPeriod * j / Period());
            Sub_Ind_Max = ArrayMaximum(High, SubFiboBars, MajorPeriod * j / Period());

            break;
         }
         
         j++;
      }

the result is identical, the if block is skipped. I believe Im getting you confused but I have no idea why it behaves such. What may I be missing?!

 

I dont know maybe you should try it like this to see where it fails.

int j = 0;
      double su = 0.0, sd = 0.0, su_prev = 0.0, sd_prev = 0.0;
      
      while(true)
      {
       su = iCustom(Symb, MajorPeriod, "Slope_Direction_Line", SlopePeriod, SlopeMethod, SlopePrice, 0, j);
       sd = iCustom(Symb, MajorPeriod, "Slope_Direction_Line", SlopePeriod, SlopeMethod, SlopePrice, 1, j);
       su_prev = iCustom(Symb, MajorPeriod, "Slope_Direction_Line", SlopePeriod, SlopeMethod, SlopePrice, 0, j + 1);
       sd_prev = iCustom(Symb, MajorPeriod, "Slope_Direction_Line", SlopePeriod, SlopeMethod, SlopePrice, 1, j + 1);
         
       if(su != EMPTY_VALUE)
       {Alert("1 su = ",su);
        if(sd == EMPTY_VALUE)
        {Alert("2");
         if(su_prev == EMPTY_VALUE)
         {Alert("3");
          if(sd_prev != EMPTY_VALUE)
          {Alert("4");
           Sub_Ind_Min = ArrayMinimum(Low, SubFiboBars, MajorPeriod * j / Period());
           Sub_Ind_Max = ArrayMaximum(High, SubFiboBars, MajorPeriod * j / Period());
           break;
       }}}}
       if(su == EMPTY_VALUE)
       {Alert("5");
        if(sd != EMPTY_VALUE)
        {Alert("6");
         if(su_prev != EMPTY_VALUE)
         {Alert("7");
          if(sd_prev == EMPTY_VALUE)
          {Alert("8");
           Sub_Ind_Min = ArrayMinimum(Low, SubFiboBars, MajorPeriod * j / Period());
           Sub_Ind_Max = ArrayMaximum(High, SubFiboBars, MajorPeriod * j / Period());
           break;
       }}}}
       j++;
      }
 
Thank you very much mate I appreciate your help. It gives me an infinite cycle and the terminal hangs.