Download MetaTrader 5
To add comments, please log in or register
Publish your article and get a reward!
turtle1000
70
turtle1000 2014.09.27 13:17 

Hi...I was hoping someone would know the answer to what I thought would be obvious  ;-)

When I run in an Ea, Test 1 only,   Hrcnttot   increases according to my sendemail details received.  But if I run only test 2 or 3 , Hrcnttot  never changes....  I assume I have misunderstood the ilow shift ... thanks in advance....

 // ############ TEST 1 ###########
  if( iLow(NULL,PERIOD_H1,0)
    > 0.00001 )
     {Hrcnttot=Hrcnttot+1;}

 // ############ TEST 2 ###########
  if( iLow(NULL,PERIOD_H1,-2)
    > 0.00001 )
     {Hrcnttot=Hrcnttot+1;}

 // ############ TEST  3###########
  if( iLow(NULL,PERIOD_H1,-3)
    > 0.00001 )
     {Hrcnttot=Hrcnttot+1;}

whroeder1
13641
whroeder1 2014.09.27 13:55  
fastbucks: I have misunderstood the ilow shift
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Post all the relevant code. What is Hrcnttot? Is it initialized? Is it a static or globally declared?
  3. Bar numbers (all shifts) start at zero (currently forming bar) and increase going back in time. What are you passing?
turtle1000
70
turtle1000 2014.09.28 11:37  

Hi WH..

 double Hrcnttot;  // is globally declared as shown here.

I understand all shifts start at zero, and test 1 works fine. it increments  Hrcnttot every tick so the total becomes into the thousands eventually. Tests 1,2&3 are purely tests because I realised shifts -1 -2 -3 etc etc being hourly bars back in time from the current bar zero, were not incrementing.  Hrcnttot represents hour count total in this example and could be used for many purposes..such as counting how many hourly lows in past 3hours or whatever were in a specific price range(determined by other parts of an Ea) I wouldn't be incrementing their...I increment only for this test to try to prove shift -1,-2 etc don't seem to work.

The problem is shift 0 increments but all minus shifts such as -1,-2,-3 etc don't increment.....I hope that's a bit clearer.

Thanks in advance...
 

whroeder1
13641
whroeder1 2014.09.28 11:47  
fastbucks: I realised shifts -1 -2 -3 etc etc being hourly bars back in time
What part of "start at zero and increasing going back in time" was unclear?
turtle1000
70
turtle1000 2014.09.30 11:11  

Hi WH ... to put it another way...if you run this in experts ...test 0 sends an email...but test -1...never does. The only difference I can see is the -1   ....thanks in advance....

//+------------------------------------------------------------------+
//|                                                         test.mq4 |
//|EA THAT TESTS IF SHIFT -1 IN TEST -1 PRODUCES A VALUE   fastbucks |
//|                                                        fastbucks |
//+------------------------------------------------------------------+
#property copyright "fastbucks"
#property link      "fastbucks"
#property version   "1.00"
#property strict
  
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
     // ############ TEST 0  ###########
  if( iLow(NULL,PERIOD_H1,0)  > 0.00001 ) 
        
   {  SendMail("Forex Account : " +AccountName()+ " Details",
      "##### TEST 0 #####Date and Time : "+TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS)+" \n"+
      "SYMBOL "+ string (Symbol())   +"" );     
       Sleep(30000)
    ;}
     // ############ TEST-1  ###########
  if( iLow(NULL,PERIOD_H1,-1)  > 0.00001 ) 
        
   {  SendMail("Forex Account : " +AccountName()+ " Details",
      "##### TEST -1 #####Date and Time : "+TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS)+" \n"+
      "SYMBOL "+ string (Symbol())   +"" );     
       Sleep(30000)
   ;}
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
whroeder1
13641
whroeder1 2014.09.30 16:13  
fastbucks: I have misunderstood the ilow shift
Bar numbers (all shifts) start at zero (currently forming bar) and increase going back in time. What are you passing?
fastbucks: I realised shifts -1 -2 -3 etc etc being hourly bars back in time
What part of "start at zero and increasing going back in time" was unclear?
fastbucks: test -1...never does. The only difference I can see is the -1
-1 is decreasing from zero - BOGUS

Asked and answered three times.

turtle1000
70
turtle1000 2014.10.04 02:38  
anyway ...after all the bogus .... I obviously missed the obvious...I changed -1 to +1 etc and it worked ;-))   ....bottle of whisky to you WH for your persistence ;-))
/
To add comments, please log in or register