English

## Double top function

 8 Brt88 2016.08.02 16:15   Hi allI 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 rangeif 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);                }} }```
 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.
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?
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```
 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 SL/TP (stops) need to be normalized to tick size (not Point.) (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 forum Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum Lot size must also be adjusted to a multiple of LotStep. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.