How do I check if Trade.ModifyPosition() was successful?
How do I check if Trade.ModifyPosition() was successful?
22 Oct 2012, 19:54
hi upon testing Trade.ModifyPosition(); I see that the call took 1millis; which indicate this method is asynch.
so how do I find out if the position was modified successfully; and if not; how do I check for errors?
Replies
scalptastic
23 Oct 2012, 11:32
RE:
The event OnError is triggered if the operation is not successful.
e.g.
protected override void OnError(Error error)
{
Print("There has been an Error");
}
@scalptastic
admin
23 Oct 2012, 12:15
Error is an Enum type and you can use it to identify which was the error.
For example you can use this statement:
switch (error.Code)
{
case ErrorCode.BadVolume: Print("Bad Volume");
break;
case ErrorCode.TechnicalError:Print("Technical Error");
break;
case ErrorCode.NoMoney: Print("No Money");
break;
case ErrorCode.Disconnected: Print("Disconnected");
break;
case ErrorCode.MarketClosed: Print("Market Closed");
break;
}
If the error is technical then there is a problem with ModifyPosition.
We will add more event handlers very soon, including one to handle the position having been modified. Stay tuned!
@admin
scalptastic
24 Oct 2012, 18:49
RE:
Error is an Enum type and you can use it to identify which was the error.
For example you can use this statement:
switch (error.Code)
{
case ErrorCode.BadVolume: Print("Bad Volume");
break;
case ErrorCode.TechnicalError:Print("Technical Error");
break;
case ErrorCode.NoMoney: Print("No Money");
break;
case ErrorCode.Disconnected: Print("Disconnected");
break;
case ErrorCode.MarketClosed: Print("Market Closed");
break;
}
If the error is technical then there is a problem with ModifyPosition.
We will add more event handlers very soon, including one to handle the position having been modified. Stay tuned!
@scalptastic
admin
26 Oct 2012, 13:12
If you mean prevent any new requests from the server if there is a current request like to modify or open a position, then you can use this statement:
if (Trade.IsExecuting) return; This will exit the method call each time until the server has responded and thus prevent any further requests from the server.
Otherwise can you give me an example of what you mean?
@admin
admin
23 Oct 2012, 09:46
The event OnError is triggered if the operation is not successful.
e.g.
protected override void OnError(Error error)
{
Print("There has been an Error");
}
@admin