Results 1 to 4 of 4
 0 Attachment(s)    

Thread: Function call problem

  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    5

    Default Function call problem

    Hello, Funyoo,

    Could you please help?

    I defined a function like this:


    int CalculateBars(int LastBar, int PastBars)
    {
    datetime _time = StrToTime(FixedDateTime), _time0 = StrToTime(FixedDateTime0);
    int LastBar = iBarShift(NULL, Period(), _time, false), PastBars= iBarShift(NULL, Period(), _time0, false);

    return(LastBar, PastBars);
    }

    function call: int CalculateBars(int LastBar, int PastBars)

    When compiling, it showes an error for return, How to return the values?


    Thanks.


    Jean

  2. #2
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by jeandl View Post
    Hello, Funyoo,

    Could you please help?

    I defined a function like this:


    int CalculateBars(int LastBar, int PastBars)
    {
    datetime _time = StrToTime(FixedDateTime), _time0 = StrToTime(FixedDateTime0);
    int LastBar = iBarShift(NULL, Period(), _time, false), PastBars= iBarShift(NULL, Period(), _time0, false);

    return(LastBar, PastBars);
    }

    function call: int CalculateBars(int LastBar, int PastBars)

    When compiling, it showes an error for return, How to return the values?


    Thanks.


    Jean
    Hi jeandl and welcome,

    I don't see the interest of your parameters.

    It should be something like this :

    Code:
    void CalculateLastBar()
    {
    datetime _time = StrToTime(FixedDateTime), _time0 = StrToTime(FixedDateTime0);
    int LastBar = iBarShift(NULL, Period(), _time, false);
    
    return(LastBar);
    }
    
    void CalculatePastBars()
    {
    datetime _time = StrToTime(FixedDateTime), _time0 = StrToTime(FixedDateTime0);
    int PastBars= iBarShift(NULL, Period(), _time0, false);
    
    return(PastBars);
    }

  3. #3
    Junior Member
    Join Date
    Feb 2009
    Posts
    5

    Default

    Hi, Funyoo,

    Thank you for your reply.

    I'm new to this forum and I was looking forward to your reply, only by 'Search' did I found your message. Thank you.

    It should be int or void, as I know, void return no value? I found this in an file:

    void FD(double& w, double& m, double& c, double& s)

    it returns several values at the same time! And the 'double&' I don't know what's that?

    Could you explain?

    Thank you,

    Jean

  4. #4
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by jeandl View Post
    It should be int or void, as I know, void return no value? I found this in an file:

    void FD(double& w, double& m, double& c, double& s)

    it returns several values at the same time! And the 'double&' I don't know what's that?

    Could you explain?
    Hi jeandl,

    You are right,

    It is int, not void.

Similar Threads

  1. What’s a Margin Call and Should I be Afraid of one?
    By painofhell in forum Trading discussion
    Replies: 5
    Last Post: 11-27-2014, 15:14
  2. Replies: 8
    Last Post: 04-12-2011, 18:28
  3. Function Call from MQL to Excel fields
    By Dutchess in forum MQL programming
    Replies: 3
    Last Post: 08-19-2010, 13:44

Tags for this Thread

funyoo, how to, time

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •