Conditions to enter positions – AND / OR

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #111002 quote
    sulimaster
    Participant
    Average
    // Conditions to enter long positions
    
    IF (x > y) AND (x > 70) AND (sslUp > sslDown) THEN
    BUY 1 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    
    IF (sslUP < sslDown) OR (y > x) THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    
    IF (sslDown > sslUp) AND (y > 70) AND (y > x) THEN
    SELLSHORT 1 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    
    IF (sslUP > sslDown) OR (x > y) THEN
    EXITSHORT AT MARKET
    ENDIF

    Hi

    In the above code to enter long positions, I want to use AND and OR e.g.

    // Conditions to enter long positions
    
    IF ((x > y) AND (x > 70)) OR (sslUp > sslDown) THEN
    BUY 1 PERPOINT AT MARKET
    ENDIF

    Is my above code modification correct? Do I need to put OR onto the next line? Do I need to use ELSIF? Any suggestions please?

    Thanks

    Sachin

    #111003 quote
    robertogozzi
    Moderator
    Master

    Your conditions seem fine. If they work as you expect then they are fine!

    There’s no need to use ELSIF, I think it’s more readable the way you wrote it.

    I can only suggest that you add “AND LongOnMarket” at line 9:

    IF ((sslUP < sslDown) OR (y > x)) AND LongOnMarket THEN

    and “AND ShortOnMarket” at line 21:

    IF ((sslUP > sslDown) OR (x > y)) AND ShortOnMarket THEN

    but it’s not mandatory.

    sulimaster thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Conditions to enter positions – AND / OR


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
sulimaster @sulimaster Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
6 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/24/2019
Status: Active
Attachments: No files
Logo Logo
Loading...