Hi,
I opened a forex position with SL and TP. It happened that the position hit the TP level. How could I know in my browser API that the position was closed automatically by hitting either SL or TP?
The "signalstatus" command still brings me the same information as before hitting SL or TP for this trade…
Thanks!
Look at the C2DSAPI’s “checkin” command. See if this gives you what you need.
Hi Matthew ,
Before getting into “checkin” signal I want to make sure that the “signalstatus” is not appripriate for my scope. If I closed manually a trade and afterwards issue a signalstatus command with its ID I’m getting the same information as before closing it. Is this normal? there is no attribute in the reply saying that the trade has already been closed??
Thanks again!
Tomasz:
I want to make sure that I understand your question. The signalstatus command is used to request the status of a particular signalID. Are you saying that you are observing a case where you know that a particular signalid has been executed, but this execution is not reflected in the results reported by signalstatus? That seems very unlikely to me, and so I suspect it may be one of the following two problems:
1) Are you “testing” behavior of the api by using a web browser? If so, you should be aware that many browsers cache response locally. This means that when testing via a browser, you need to add a random component to the url each time you request status so that the browser actually bothers to send requests to C2. (Example: add &garbage=76376376276 to your request, where each “garbage” parameter is a random, unique number.)
2) Is it possible you are mixing up the concept of signals and open positions? (Forgive me if this is not the issue… but just in case…) Let me explain what I mean by using an example. Imagine you open a long position of 10 shares of IBM stock, and then issue the following signal: STC IBM LIMIT 101. You will know the signalid for that last limit-order signal – for the sake of example, let’s say that is signal id #1234. This means you can now request signalstatus for signal 1234. The signalstatus will remain the same (unfilled) until and unless that particular limit order (signal 1234) gets executed. If you close the IBM position in any other way (for example, through a second signal #9876, or via the web interface at c2, or whatever) then signal #1234 will not appear to have been executed, even if the IBM position is closed by some other means.
Does any of this information help?
Hi Matthew,
Let me come up with some details:
Step1: I issue a long position in EURUSD at the market and I get back the ID 12345. I can see the position working now…good.
Step2: I issue a "signalstatus" command with ID 12345 and getting back the response. In the response I can find the TradePrice attribute…good…
Step3: I close the position from Step1 with a short signal. I can see that the position was closed now…good
Step 4. I repeat Step2 again with the same ID 12345 and I get back the same response as at Step 3 but the position is already closed now! Is there any notification present that the position is already closed now?? it appears to me as still working…So my question was how could I find out from a "signalstatus" command that the position is closed??
Thanks again!
Two questions:
1) Are you using a web browser to test this? Please answer this question. It will inform my other answers.
2) The "signalstatus" command does use some internal caching to prevent people from periodically polling the signals every second. If you need a very fast response, that is what the checkin command is for. But have you tried running the test you describe above, but delay step 4 by, say, 30 seconds? That would be a good test to help figure out why you are having these issues.
- Yes I’m using IE as web browser with caching disabled. moreover I’m using Wireshark application to sniff the incoming/outgoing HTTP messages through the network interface.
2. I delayed Step 4 by 10 minutes! and I had issued again the signalstatus command see below:
GET /cgi-perl/signal.mpl?cmd=signalstatus&signalid=50196686&c2email=admin2@signals-forex.com&pw=qwerty12&showrelated=children&showdetails=1 HTTP/1.1\r\n
I received again the same answer from the server:
<collective2>\n
<signal>\n
<signalid>50196686</signalid>\n
<systemname>test_01</systemname>\n
<postedwhen>2010-06-11 01:33:51:000</postedwhen>\n
…
<tradedwhen>2010-06-11 01:33:51:000</tradedwhen>\n
…
I issued the signalstatus command at 1:44 your time… The response data comes from the wireshark sniffer so that I can make sure that there is no caching mechanism on my side.
Thanks!
Tomas:
I deleted your forum post with your DSAPI password in it.
But the example you showed me in that post as evidence of a problem actually looks fine to me. The critical bit that is returned is:
<collective2>\n
<signal>\n
<signalid>50196686</signalid>\n
<systemname>test_01</systemname>\n
<postedwhen>2010-06-11 01:33:51:000</postedwhen>\n
…
<tradedwhen>2010-06-11 01:33:51:000</tradedwhen>\n
This means the signal was traded at time 1:33:51. In other words, the signal was executed … so now I’m very confused about why you think this is not what you expected to receive?! You issued a signal; C2 reported it as traded.
Matthew , thanks for deleting my message. Yes exactly the signal is executed but in order to understand my problem I define two states for a signal:
State 1 - the position is opened and working so that I can see how its price moves up or down. I can issue a signalstatus command and get back the traded time.
State 2 - the position is closed (its price reaching a TP or SL) so that I can take my profit or loss now. the position is not working any more. I issue another signalstatus command and get back the same info.
Good, now I would like to know how I can distinguish the transition from State 1 to State 2 in my web API if the signalstatus command gives me the same answer in both states? I would expect an attribute like "ClosedWhen" along with "TradedWhen" here…
thank you!
I think you are confusing the concept of signal (or "order") and position.
Signals get executed only once. A signal can open a position (or increase its size) or a signal can close a position (or decrease its size).
You can use signalstatus to learn whether or not a particular signal has been executed.
You can use getopenpositions to learn whether a particular position is still open. (Alternately, you can use the establishstatus and checkin commands.)
Once a signal has been executed (i.e. once the <tradedwhen> field is greater than zero) that signal status will always remain the same … regardless of any change in the position that resulted from that signal.
To take an example: If signal #100 opens a position in EURUSD, and then you subsequently close that position in EURUSD, the subsequent closing of the EURUSD position will not change anything about signal #100. Signal #100 was executed at time T and it opened the position. Whatever happened subsequently to time T is immaterial to signal #100.
I think the key concept to keep in mind is that you use signals to build (or close) positions. You can poll about the status of a signal (i.e. has it been traded?) or the status of a position (does it still exist?). Positions are the result of one or several signals being executed.