Register Login
Forums    February 9, 2012
TradersStudio Forums
Using GetEntryDate function in loop
Last Post 04-22-2008 09:32 PM by Thomas Bengtsson. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Thomas Bengtsson
New Member
New Member
Posts:11

--
04-17-2008 04:25 PM
    I am trying to loop through the all entry dates and exit dates at the end of a session. I am somewhat experienced in using VB so I am surprised that I can't get this to work and I would really appreciate any help to get this to work.

    I have the following abbreviated code (as part of a session):

    Dim iDateDiff As Integer
    Dim iExitDate
    Dim iEntryDate
    Dim counter As Integer
    Dim iTradesNo

    '------
    'Start of code
    'Misc code to generate entries and exits.
    '----
    counter = 0

    If BarNumber = LastBar Then 'THIS WORKS FINE

     iTradesNo = LiveTradeCount()   'THIS RETURNS 3, SO FAR SO GOOD
         
           If iTradesNo > 0 Then 'THIS WORKS AS INTENDED AS WELL
       
                For counter = 0 To iTradesNo - 1

                    iEntryDate = GetEntryDate(counter) 'DOES NOT WORK .JUST RETURNS "EMPTY" FOR EACH VALUE FOR THE COUNTER VARIABLE
                    iExitDate = GetExitDate(counter)      'DOES NOT WORK .JUST RETURNS "EMPTY" FOR EACH VALUE FOR THE COUNTER VARIABLE
                                 
                Next

            End If

    End If

    'End of code
    '-----

    However, if I use the GetExitDate and GetEntryDate function and hardcode a number e.g.

    iExitDate = GetExitDate(0)
    iEntryDate = GetEntryDate(1)

    then both functions return the correct dates, that match the Trade by Trade report tab.
    I have stepped through the code and confirmed that the counter variable changes values (from 0 to 1, from 1 to 2 etc) but the GetExitDate and GetEntryDate functions return "Empty"

    Any suggestions for how I can get this to work in a loop?
    mur ang
    Advanced Member
    Advanced Member
    Posts:525

    --
    04-18-2008 04:26 PM
    It should work , I will check into it and get you a answer Monday or so. It could be a bug.
    Thomas Bengtsson
    New Member
    New Member
    Posts:11

    --
    04-22-2008 09:32 PM
    I managed to get it to work. Even though "counter" variable was declared as Integer, GetEntryDate function did not seem to treat it as such. However, if I explicitly convert "counter" to Integer by writing it as CInt(counter) then the GetEntryDate function works fine. The abbreviated code that works would look like:

    For counter = 0 to iTradesNo - 1

    iDate = GetEntryDate(CInt(counter))

    Next

    Seems a bit odd the GetEntryDate function would work this way, but I am just happy I got it to work.
    You are not authorized to post a reply.


     TradersStudio, Inc. ® Copyright 2004-2012 All Rights Reserved   Terms Of Use  Privacy Statement