Date and time issue on indior
Page 1 of 612 12 LastLast
Results 1 to 10 of 12

Thread: Date and time issue on indior

  1. #1
    Hi coders this is my first time posting in the Platform tech so I'm not sure how it goes.

    I managed to alter this indior for my needs and it was functioning very well.

    Now I'm working on a off line chart.

    The data I have on background begins on 01-04-1999 and ends on 03-06-2014.

    When I start the indior it paints rectangles as it is supposed to.

    The problem is that it begins on 04-14-2011

    I'd love to know if someone could assist me up solving this problem

    Thanks.

    Inserted Code #property Hyperlink #property indior_chart_window extern int NumberOfDays = 10; extern string EurBegin = 00:00; extern string EurEnd = 10:00; extern color EurColor = Green; extern bool ShowPrice = True; extern color clFont = Magenta; extern int SizeFont = 3; extern int OffSet = 10; // ------------------------------------------------------------------ //| Custom indior initialization function | // ------------------------------------------------------------------ void init() for (int I=0; ilt;NumberOfDays; I ) CreateObjects(EU I, EurColor); // ------------------------------------------------------------------ // ------------------------------------------------------------------ void CreateObjects(string no, color cl) ObjectCreate(no, OBJ_RECTANGLE, 0, 0,0, 0,0); ObjectSet(no, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(no, OBJPROP_COLOR, cl); ObjectSet(no, OBJPROP_BACK, True); // ------------------------------------------------------------------ void start() datetime dt=CurTime(); for (int I=0; ilt;NumberOfDays; I ) if (ShowPrice I==0) DrawPrices(dt, EU I, EurBegin, EurEnd); DrawObjects(dt, EU I, EurBegin, EurEnd); dt=decDateTradeDay(dt); while (TimeDayOfWeek(dt)gt;5) dt=decDateTradeDay(dt); // ------------------------------------------------------------------ // ------------------------------------------------------------------ void DrawObjects(datetime dt, string no, string tb, string te) datetime t1, t2; double p1, p2; int b1, b2; t1=StrToTime(TimeToStr(dt, TIME_DATE) tb); t2=StrToTime(TimeToStr(dt, TIME_DATE) te); b1=iBarShift(NULL, 0, t1); b2=iBarShift(NULL, 0, t2); p1=High#91;Highest(NULL, 0, MODE_HIGH, b1-b2, b2)#93;; p2=Low #91;Lowest (NULL, 0, MODE_LOW, b1-b2, b2)#93;; ObjectSet(no, OBJPROP_TIME1, t1); ObjectSet(no, OBJPROP_PRICE1, p1); ObjectSet(no, OBJPROP_TIME2, t2); ObjectSet(no, OBJPROP_PRICE2, p2); // ------------------------------------------------------------------ // ------------------------------------------------------------------ void DrawPrices(datetime dt, string no, string tb, string te) datetime t1, t2; double p1, p2; int b1, b2; t1=StrToTime(TimeToStr(dt, TIME_DATE) tb); t2=StrToTime(TimeToStr(dt, TIME_DATE) te); b1=iBarShift(NULL, 0, t1); b2=iBarShift(NULL, 0, t2); p1=High#91;Highest(NULL, 0, MODE_HIGH, b1-b2, b2)#93;; p2=Low #91;Lowest (NULL, 0, MODE_LOW, b1-b2, b2)#93;; if (ObjectFind(no pd)lt;0) ObjectCreate(no pd, OBJ_TEXT, 0, 0,0); ObjectSet(no pd, OBJPROP_TIME1, t1 400000); ObjectSet(no pd, OBJPROP_PRICE1, p1); ObjectSet(no pd, OBJPROP_COLOR, Red); ObjectSet(no pd, OBJPROP_FONTSIZE, 15); ObjectSetText(no pd, DoubleToStr ((p1-p2)/0.0001,1 )); // ------------------------------------------------------------------ // ------------------------------------------------------------------ datetime decDateTradeDay (datetime dt) int ty=TimeYear(dt); int tm=TimeMonth(dt); int td=TimeDay(dt); int th=TimeHour(dt); int ti=TimeMinute(dt); td--; if (td==0) tm==7 return(StrToTime(ty . tm . td th : ti)); // --------------------------------------------------------

  2. #2
    You can Do this:
    In function Launch (), Alter
    Inserted Code datetime dt=CurTime(); to
    Inserted Code datetime dt=Time#91;093;;

  3. #3
    Quote Originally Posted by ;
    You can do this: In function start(), change datetime dt=CurTime(); to datetime dt=Time[0];
    Thank you for the response, but still starting in the exact same date

  4. #4
    Quote Originally Posted by ;
    quote Thank you for the response, but starting in precisely the same date
    It is unclear as to what your difficulty is. The indior begins from the current time ( server time) and brings stuff'NumberOfDays' back.

    Quote Originally Posted by ;
    The challenge is that it begins on 04-14-2011
    So you mean that the chart shows data from 1999 to 2014 and the indior starts on 04-14-2011 and shows things for 10 days back?

    What stage are you using the indior on and what should you set NumberOfDays to?

  5. #5
    Quote Originally Posted by ;
    quote It is unclear as to exactly what your problem is. The indior starts from the current time ( server time) and draws stuff'NumberOfDays' back. quote So you mean that the chart shows data from 1999 to 2014 and the indior starts on 04-14-2011 and displays things for 10 days back? What timeframe are you currently using the indior and what have you put NumberOfDays to?
    Thank you very much for helping me on this

    Yes I now have an off line metatrader only for research. It is not on the internet in any way.

    There I have moment data from 01-04-1999 until 03-06-2014.

    This indior just draws a 10 hour rectangle for the number of days I enter in.

    Until a few days ago it was functioning correctly starting the drawing march and back lets say 20 days.

    Suddenly it ceased working. I could not see the rectangles anymore.

    I went to metatrader series objects and found that it was drawing the rectangles.
    But rather than the most recent date, it starts on 04-14-2011.

    It still draws 10 rectangles when I enter it but it starts in 2011 thats the problem.

    So I guess something changed from the pub 0 or time 0 or something.

    I made the changes that you proposed with no success it still draws on 2011

    The indior works on timeframes from 1 minute till 4 hours and generally I put it to draw 10 or 20 rectangles.

    Allow me to point again that the indior IS WORKING.
    The dilemma is that the beginning date that's assumed to be at roughly 03-06-2014 but was shifted back to 2011.

  6. #6
    can it be in the Tools/Options /Chart?

  7. #7
    Quote Originally Posted by ;
    can it be in the Tools/Options /Chart? image
    I put it to the maximum typing 99999999999999

    Thanks Emmanuel.

  8. #8
    Quote Originally Posted by ;
    quoteUntil a few days ago it was working properly starting the drawing march and back lets say 20 days. Suddenly it stopped functioning. I could not understand the rectangles anymore.
    It would not stop working suddenly without reason. Did you do something which affected the information? Did you do anything in any way? Did MT4 update to a newer version? etc..
    - What did you do before it stopped functioning!

    Quote Originally Posted by ;
    Yes I have an off line metatrader Just for research. It isn't connected to the internet in any way.
    Edition of MT4? Yes, it is relevant. The 600 assembles have a lot of new bugs.
    - Suggestion: Upgrade or downgrade to another edition.

    Quote Originally Posted by ;
    01-04-1999 till 03-06-2014.
    That is a massive quantity of 1 minute information. In my experience MT4 isn't particularly good at working with a lot of information.
    - Suggestion: Reduce the'variety of pubs on chart' parameter to find out if it works with a smaller data set.

    - Debugging: For build 509- insert Print statements to print out the date in relevant areas in the code and then see what it writes. 'variety of bars chart' parameter to find out if it functions with a smaller data set. For build 600 : Set breakpoints and execute the indior through the debugger to check the date value in related areas in the code Inserted Code void start() datetime dt=TimeCurrent(); for (int I=0; ilt;NumberOfDays; I ) if (ShowPrice I==0) DrawPrices(dt, EU I, EurBegin, EurEnd); DrawObjects(dt, EU I, EurBegin, EurEnd); Print(Id : Period = TimeToStr(dt); dt=decDateTradeDay(dt); while (TimeDayOfWeek(dt)gt;5) dt=decDateTradeDay(dt);
    edit: fixed code

  9. #9
    Quote Originally Posted by ;
    quoteYes I have an off line metatrader just for research. It's not on the net. There I have minute data from 01-04-1999 till 03-06-2014.
    The indior uses the current server time as the beginning point. If the MT4 instance is offline then the current server time is not the current date and time. What is your current server time?

    If the matter is the server time, the fix I suggested should solve it. Are you sure the file changed? When using multiple cases of MT4, metaeditor doesn't necessarily get the folders right and may set progr it circulates from the wrong folder. Check the date on the ex4 file to see if it's accurate.

  10. #10
    Now that you mentioned. I add the past weeks information every week to keep it current.I may got to a limit as what MT4 can handle.

    The total number of information is currently 307 MB. Can it be too much for MT4?

    How do I check the previous server time? Because metatrader is offline I thought it used the latest minute bar as the previous server time.

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.