Enter trades on multiple conditions – help needed please

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #188218 quote
    RaspberriRaspberri
    Participant
    New

    Hi all,

    apologies if this is a basic question that was answered before, but I am trying to create a strategy that enters long/short depending on Fib retracement crossings and MA and am struggling to find the right code.

    Basically, I am defining 20 conditions (10 for long, 10 for short). 1 and 11 are conditions that I always want to be met (c1 for long, c11 for short). For long entry, I want c1 AND either of c2-c10 met, for short c11 AND either of c12-20. I have tried everything from using OR, ELSIF or separate IF ENDIF statements but nothing works.

    Does anyone know how to write this?

    Thanks a lot in advance! šŸ™‚

    #188220 quote
    GraHalGraHal
    Participant
    Master

    You would need to post your code else we all be guessing what / how you have coded.

    Raspberri thanked this post
    #188221 quote
    RaspberriRaspberri
    Participant
    New

    Absolutely, makes sense! I found my mistake myself, the answer is to include the AND statement in the condition definition itself before starting IF statement. At least it works for me now. Example below:

    // Conditions to enter long positions
    indicator1 = Average[100](close)
    c1 = (close > indicator1)
    // c2 as indicator2 AND c1
    indicator2 = (((DHigh(1) + DLow(1) + DClose(1))/3 – (DHigh(1)-DLow(1)))+((DHigh(1) + DLow(1) + DClose(1))/3 – (.618 * (DHigh(1)-DLow(1))))) /2
    c2 = (close CROSSES OVER indicator2 AND c1)

    #188228 quote
    GraHalGraHal
    Participant
    Master

    Make sure you test your strategy on Demo Account ONLY until you are happy it makes money on a regular basis / over 50 to 100 trades at least!

    #188231 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go (you may also add Not Onmarket + Trading hours and Days to General Conditionms):

    GeneralConditions = c2 AND c3 AND c4 AND c5 AND c6 AND c7 AND c8 AND c9 AND c10
    LongConditions    = GeneralConditions  AND c1
    ShortConditions   = GeneralConditions  AND c11
    IF LongConditions THEN
       BUY 1 Contract at Market
    ELSIF ShortConditions THEN
       SELLSHORT 1 Contract at Market
    ENDIF
    GraHal thanked this post
Viewing 5 posts - 1 through 5 (of 5 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

Enter trades on multiple conditions – help needed please


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Raspberri @raspberri Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by robertogozzirobertogozzi
4 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/14/2022
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...