Conditions to enter positions – AND / OR

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #111002 quote
    sulimastersulimaster
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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 robertogozzirobertogozzi
6 years, 11 months ago.

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