PDA

View Full Version : SymbolInfoDouble with no account logged in



RoboTradingFx
07-10-2014, 06:38 PM
hi

I've tried the sample script described in SymbolInfoDouble docs





Dim exeResult


Dim rst


Dim symbolName



Public Sub main()



symbolName="EUR/USD"



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_STOP_OFFSET,rst) ,
"SYMBOL_STOP_OFFSET",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_ASK,rst) , "SYMBOL_ASK",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_BID,rst) , "SYMBOL_BID",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_High,rst) , "SYMBOL_High",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_LOW,rst) , "SYMBOL_LOW",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_VOLUME_MIN,rst) , "SYMBOL_VOLUME_MIN",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_VOLUME_MAX,rst) , "SYMBOL_VOLUME_MAX",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_COMMISSION,rst) , "SYMBOL_COMMISSION",cstr(symbolName)


ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_LIMIT_OFFSET,rst) , "SYMBOL_LIMIT_OFFSET",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_MARGIN_INITIAL,rst) , "SYMBOL_MARGIN_INITIAL",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_CONTRACT_SIZE,rst) ,
"SYMBOL_CONTRACT_SIZE",cstr(symbolName)


MsgBox
cstr(exeResult)


End Sub



Public Sub
ShowResult(isTrue,enumDescription,symName)


if isTrue then



exeResult=exeResult & CSTR(enumDescription) & " for " & CSTR(symName) &
" is : " & rst



else



exeResult=exeResult & "Error
during Get " & CSTR(enumDescription) & "
due to error code " & ErrorDescription(GetLastError())



end if



exeResult=exeResult & vbNewLine



rst=""


End Sub




It works good, but when I leave the script running and close the platform and open it again an exception occurs in SymbolInfoDouble because there is no account logged in.
the problem happens with some of the propIds not all

is there a way around this besides starting the script again?

thank you

Hassan-HS
07-11-2014, 08:39 AM
Hello,


Sure because some data does not fetched yet from the server.


You can add this condition to avoid that or you can put your code on AllDataLoaded sub-procedure.



Public Sub main()

If AccountInfoInteger(ACCOUNT_LOGIN) = -1 Then ' Check if account is selected
FontSize = 6
ObjColor = RGBColor(255,00,00)
ObjID = "lblText" ' ID of the label object
XPos = 10 ' X position on chart
YPos = 25 ' Y position on chart
ObjText="Please select an account first" ' Sets the text of the label.
CreateObjectLabel 0,0,CSTR(ObjID),CINT(XPos),CINT(YPos),ObjText 'Creates the label with the selected Parameters
ObjectSetText 0, CSTR(ObjID),CINT(FontSize),,CLNG(ObjColor) ' Sets the label properties.
Objectset Clng(0),Cstr(ObjID), 1,false
Exit Sub
end if

End sub

RoboTradingFx
07-11-2014, 01:21 PM
thank you

could you point me to an example script of AllDataLoaded? I'm not being able to put it to work

regards

RoboTradingFx
07-11-2014, 02:49 PM
hello again

another problem when I add the code to the sample script




Public Sub main()

If AccountInfoInteger(ACCOUNT_LOGIN) =
-1 Then ' Check if account is selected
FontSize =
6
ObjColor = RGBColor(255,00,00)
ObjID =
"lblText" ' ID of the label object
XPos = 10 ' X position on
chart
YPos = 25 ' Y position on chart

ObjText="Please select an account first" ' Sets the text of the
label.
CreateObjectLabel
0,0,CSTR(ObjID),CINT(XPos),CINT(YPos),ObjText 'Creates the label with the
selected Parameters
ObjectSetText 0,
CSTR(ObjID),CINT(FontSize),,CLNG(ObjColor) ' Sets the label
properties.
Objectset Clng(0),Cstr(ObjID), 1,false

Exit Sub
end if

End sub


is that while it solves the problem I described, after the account is logged in, the script can't acess the values anyway and throws an exception anyway

that exception is sent with no information at all about the error (while the first exception send the message "Invalid account")

thank you for you time

Hassan-HS
07-11-2014, 03:46 PM
Hello,


Check the following code that will avoid your problem, If no account is selected the script will notify you to select account, other wise the proprites of the symbol will pop-up in msgbox.




Dim exeResult


Dim rst


Dim symbolName
Public Sub main()

If AccountInfoInteger(ACCOUNT_LOGIN) = -1 Then ' Check if account is selected
FontSize = 6
ObjColor = RGBColor(255,00,00)
ObjID = "lblText" ' ID of the label object
XPos = 10 ' X position on chart
YPos = 25 ' Y position on chart

ObjText="Please select an account first" ' Sets the text of the label.
CreateObjectLabel 0,0,CSTR(ObjID),CINT(XPos),CINT(YPos),ObjText 'Creates the label with the selected Parameters
ObjectSetText 0, CSTR(ObjID),CINT(FontSize),,CLNG(ObjColor) ' Sets the label properties.
Objectset Clng(0),Cstr(ObjID), 1,false
Exit Sub
else
ObjectDelete 0,CSTR(ObjID)
end if


symbolName="EUR/USD"



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_STOP_OFFSET,rst) , "SYMBOL_STOP_OFFSET",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_ASK,rst) , "SYMBOL_ASK",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_BID,rst) , "SYMBOL_BID",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_High,rst) , "SYMBOL_High",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_LOW,rst) , "SYMBOL_LOW",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_VOLUME_MIN,rst) , "SYMBOL_VOLUME_MIN",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_VOLUME_MAX,rst) , "SYMBOL_VOLUME_MAX",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_COMMISSION,rst) , "SYMBOL_COMMISSION",cstr(symbolName)


ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_LIMIT_OFFSET,rst) , "SYMBOL_LIMIT_OFFSET",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_MARGIN_INITIAL,rst) , "SYMBOL_MARGIN_INITIAL",cstr(symbolName)



ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_CONTRACT_SIZE,rst) , "SYMBOL_CONTRACT_SIZE",cstr(symbolName)


MsgBox cstr(exeResult)


End Sub



Public Sub ShowResult(isTrue,enumDescription,symName)


if isTrue then



exeResult=exeResult & CSTR(enumDescription) & " for " & CSTR(symName) & " is : " & rst



else



exeResult=exeResult & "Error during Get " & CSTR(enumDescription) & " due to error code " & ErrorDescription(GetLastError())



end if



exeResult=exeResult & vbNewLine



rst=""


End Sub

RoboTradingFx
07-13-2014, 03:46 PM
Thank you for the suggestion

it solves the problem of accessing the SymbolInfoDouble function while the user is not logged in

but my problem is that after we see the "Please select an account first" message and we do try to log in, the script runs again and now the user is logged in but MsgBox still shows an error and the function throws an exception.

this 2nd exception doesn't gives the code "Invalid account" (and correctly, I suppose, because the account is selected now), doesn't show any error code, so I have no idea why it throws an exception

352

doesn't this happen to you?

Hassan-HS
07-13-2014, 04:55 PM
Hello,


Please check this article (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2669).


Any time you get an exception can invoke this method to know the reason of the exception .

RoboTradingFx
07-13-2014, 11:03 PM
yes. I know about that method (I'm using it in the script)

My point is that the ErrorDescription(GetLastError()) returns a blank string, that is why I said it showed no error code

So even when the account is selected, the script isn't able to access the values.

Can you reproduce the situation? And is that how it is supposed to behave?

I really appreciate your time

Hassan-HS
07-14-2014, 09:02 AM
Hello,


You are welcome :)

I've noticed that this problem occurs when the system is in waiting state, I will open a ticket to our development team to check and solve this problem directly.


I will update you soon please standby

Hassan-HS
07-14-2014, 11:46 AM
Hello,


I am pleased to tell you that the problem has been solved in the next patch.

RoboTradingFx
07-14-2014, 01:52 PM
thank you


____