Monday, December 01, 2008
Login
|
Register
Home
Overview
Tutorials
Products
Special Offers
Forums
Contacts
User Login
Suggestions
Traders Resources
Click To Buy
TradersStudio 2.5
Now!
TradersStudio Forums
Unanswered
Active Topics
Forums
Search
Forums
>
TradersStudio 2.x
>
TradersStudio Basic
Subject: Using GetEntryDate function in loop
You are not authorized to post a reply.
Author
Messages
Oldest First
Newest First
tbengtsson
Posts:9
04-17-2008 4:25 PM
Alert
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?
murray
Posts:431
04-18-2008 4:26 PM
Alert
It should work , I will check into it and get you a answer Monday or so. It could be a bug.
tbengtsson
Posts:9
04-22-2008 9:32 PM
Alert
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.
Technical Trading
--Advanced Topics
--Technical Analysis
--Free Trading Tools
--Developing Trading Systems
--Trade Plans, Money Management & Risk Control
Welcome TradeStation Users
--Welcome TradeStation Users Questions
--Migrating TradeStation Code To TradersStudio
Membership Forum
--Gold Members
--Platinum Members
Forums
>
TradersStudio 2.x
>
TradersStudio Basic
> Using GetEntryDate function in loop
ActiveForums 3.6
TradersStudio® Copyright 2004-2008 All Rights Reserved
|
Privacy Statement
|
Terms Of Use