stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Fractals Script
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=329
Page 1 of 1
Author:  gaheitman [ Mon Feb 06, 2012 10:35 pm ]
Post subject:  Fractals Script

I wasn't really sure where to put this script. I really like the indicator 10.1 Daily S&R Daily, but I like messing with the S/R lines after they are drawn, and the indicator doesn't like that very much. So, I wrote a script to do a similar thing as the indicator, except I use the actual time frame for the fractal instead of the chart time frame. Also, I'd like to have at least 4 lines above and 4 below for each time frame, so I keep going back in time until I have 4 above and 4 below. That usually means I have four on one side of the price and many more than four on the other.

The real reason I decide to post this is I added code to check the time frame I'll be scanning for fractals before I scan it so that Empty4 has a chance to download history data. I call this code for each period that I will be accessing:

Code: Select all

void CheckCurrency(int Per) {

   double d = iClose(NULL,Per,Bars);
   int err = GetLastError();

   //wait up to 20 seconds for the data to load   
   int stop=GetTickCount() + 20000;
   
   while(err == 4066 && stop > GetTickCount()) {
      Print("waiting for data ",Symbol()," ", PerToStr(Per));
      Sleep(MathRand() / 100);
      d = iClose(NULL,Per,Bars);
      err = GetLastError();
   }
}  
I think it works. ;) It writes to the log saying it is downloading data, but I can't get it to go through the loop more than once.

George
All times are UTC Page 1 of 1