If longonmarket, needed or not?
Forums › ProRealTime English forum › ProOrder support › If longonmarket, needed or not?
- This topic has 7 replies, 5 voices, and was last updated 7 years ago by
AVT.
-
-
09/26/2017 at 1:04 PM #47393
Bonjour!
I noticed most people here use the following conditional statement in their codes. I think lines 1 and 3 are redundant. According to PRT help Sell command has no effect if there is no long position. Same with Exitshort.
- If longonmarket Then
- Sell At Market
- Endif
09/26/2017 at 1:42 PM #4739509/26/2017 at 2:00 PM #47396I have tested it and it seems true!
I am not aware of any drawbacks.
09/26/2017 at 2:07 PM #47397First, you have to obey the syntax in a programming language. And in PRT the syntax for simple IF is:
IF condition THEN
action
ENDIF
wheras in other languages syntax might be:
if(condition) action;
So far for syntax.
Now for contents: IF conditions are written for every, really every imaginable case that could eventually happen. This does not mean, those cases must all happen. It is just an insurance for the case we have such an event.
Example: There is a box where a user should enter his age. We write an IF condition:
IF userinput != Number THEN
print “I want your age as a number, not as a joke”
ENDIF
Now think about your argumentation; right, if the user enters a number we don’t have to tell him to do what we want. And maybe it is so obvious that people will never get the idea to enter anything else than for example 19 or 56.
But is it therefore redundant? No. Because there might be a case where someone enters twenty or just middleage or whatever he wants.
Same applies to long on market. If there’s no long position, ok nothing to sell. But you never know what happens, so for the case that there is a long position we sell it and are safe.
09/26/2017 at 2:19 PM #47399@Mansoor, you are probably right, however, I tend to agree with @AVT, just because something works doesn’t mean it is good practice.
Especially with large pieces of code with multiple entry/exit conditions various points, a rogue piece of sell at market code can really mess things up.
So for me personally it simply comes down to good coding standards and habits.
09/26/2017 at 2:54 PM #47408Usually the underlying, executing program (in this case PRT) should return an error code, if it receives a command which cannot be exectuted. With a simple Sell at Market where there is no Long position to sell, the answer should be something like “no existing long position to sell”. To avoid such a case we need the IF statement. Don’t know whether PRT returns such error codes.
09/26/2017 at 5:31 PM #4742509/26/2017 at 6:28 PM #47429 -
AuthorPosts
Find exclusive trading pro-tools on