Double top function

Back to topics list To post a new topic, please log in or register
avatar
8
Brt88 2016.08.02 16:15
 

Hi all

I trying to code the condition of finding DT. I want to check previous 40 bars starting from 6th bar to find the one(H1) with max equals to previous d1 bar.
Then I want to check if neck of double bottom is over 20% of average daily range
if conditions are met return True.


Plz help

bool DT ()
{ 
  int i;
  double ATRd = iATR(Symbol(),1440,14,0);

     for (i=1; i<40;i++)
           {
          if(iHigh(NULL,PERIOD_D1,1)==iHighest(NULL,PERIOD_H1,MODE_HIGH,i,6))
              {  break;
                   
               if( iHigh(NULL,PERIOD_D1,1)- iLowest(NULL,PERIOD_H1,MODE_LOW,i,6)>0.2*ATRd)
               return(true);
               else return(false);
               }}
}


avatar
108
eddie 2016.08.02 19:24 #
 

You have to be really lucky to get a DT with totally equal hights.

Better you define a range for the values.

avatar
13012
WHRoeder 2016.08.02 21:02 #
 
  1. eddie: You have to be really lucky to get a DT with totally equal hights.
    They won't be exact, not even close, and even if they were you still have to handle: The == operand. - MQL4 forum

  2. if( iHigh(NULL,PERIOD_D1,1)- iLowest(NULL,PERIOD_H1,MODE_LOW,i,6)>0.2*ATRd)
    return(true);
    else return(false);
    is
    if(condition) return true;
    else          return false;
    same as
    if(condition) return condition;
    
    sam as
    return condition;
    Simplify your code.
    return iHigh(NULL,PERIOD_D1,1)- iLowest(NULL,PERIOD_H1,MODE_LOW,i,6)>0.2*ATRd;

  3.  iLowest does not return a price.What do you think 1.2345 - 5 means?
avatar
8
Brt88 2016.08.03 13:16 #
 
WHRoeder:
  1. eddie: You have to be really lucky to get a DT with totally equal hights.
    They won't be exact, not even close, and even if they were you still have to handle: The == operand. - MQL4 forum

  2. is
    same as
    sam as
    Simplify your code.

  3.  iLowest does not return a price.What do you think 1.2345 - 5 means?


Huge thanks, I have corrected the code according to ur suggestions. Now it seems that finally working :))

bool DT ()
{ 
  int i;
  double ATRd = iATR(Symbol(),1440,14,0);

     for (i=1; i<40;i++)
           {
          if(iHigh(NULL,PERIOD_D1,1)==  iHigh(Symbol(),PERIOD_H1,  NormalizeDouble(iHighest(NULL,PERIOD_H1,MODE_HIGH,i,6),0) )         )
              {                    
               return iHigh(NULL,PERIOD_D1,1)- iLow(Symbol(),PERIOD_H1,  NormalizeDouble(iLowest(NULL,PERIOD_H1,MODE_LOW,i,0),0) ) >  prAtrDTDB*ATRd;
              }}



// prAtrDTDB - extern var
avatar
13012
WHRoeder 2016.08.03 14:22 #
 
Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
Back to topics list  

To add comments, please log in or register