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 avatarAVT.
Viewing 8 posts - 1 through 8 (of 8 total)
  • #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.

    1. If longonmarket Then
    2. Sell At Market
    3. Endif
    #47395

    I haven’t tested this myself. I could be wrong!

    #47396

    I have tested it and it seems true!

    I am not aware of any drawbacks.

    #47397
    AVT

    First, 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.

    #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.

    #47408
    AVT

    Usually 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.

    #47425

    I guess leaving the if statement out of the equation will lead to a sell order after the first bar being long on the market.

    If that’s what you want then stick to it.

     

    #47429
    AVT

    @Derek good point! We just looked onto one aspect of it, forgetting the other – you never know what happens, even here :-))

Viewing 8 posts - 1 through 8 (of 8 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login