A chronologically dependant condition?

Forums ProRealTime English forum ProOrder support A chronologically dependant condition?

Viewing 9 posts - 1 through 9 (of 9 total)
  • #187402

    Hello everyone! I’m basically a noobie when it comes to coding so I’m expecting that my problem is “easily” solvable for some coders here.

    My problem is that I want to make a condition for my strategy that is chronologically dependant. Meaning this indicator needs to be at a value at FIRST and then cross a line thereafter and then after it crossed the line the indicator do not need to be at that value later since it already was there. I know my english is severly incomprehensible but I’m trying my best. Sincerely//julopax

    #187408
    JS

    You can use the statement “ONCE”
    Your code is executed at the end of each bar, but “once” is only executed the first time hence “once”

    Example from the documentation:

    #187411

    Well… I did read the documentation on the ONCE instruction and it turns out it’s not my case at all. The ONCE instruction is only going to run a command ONCE. And in my case I need my condition to follow a chronological order meaning it can repeat indefinitely but only in a specific order

    #187413

    Can you post an example?

     

    #187426
    JS

    You’re welcome, noobie?

    #187488

    I’m going to post an example since it’s too hard to explain in plain text.

    Let’s say my strategy is based off the Adaptive Moving Average indicator and the Stochastic indicator exclusively.

    The first screenshot is what it looks like in a 30min chart (1k candles)

    My code (example, used probuilder):

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated

    // Conditions to enter long positions
    indicator1 = AdaptiveAverage[20,2,3000](close)
    indicator2 = AdaptiveAverage[70,2,3000](close)
    c1 = (indicator1 CROSSES OVER indicator2)
    indicator3 = Stochastic[100,50](close)
    c2 = (indicator3 < 20) IF c1 AND c2 THEN BUY 1 CONTRACT AT MARKET ENDIF // Conditions to exit long positions indicator4 = AdaptiveAverage[20,2,3000](close) indicator5 = AdaptiveAverage[70,2,3000](close) c3 = (indicator4 CROSSES UNDER indicator5) IF c3 THEN SELL AT MARKET ENDIF // Conditions to enter short positions indicator6 = AdaptiveAverage[20,2,3000](close) indicator7 = AdaptiveAverage[70,2,3000](close) c4 = (indicator6 CROSSES UNDER indicator7) indicator8 = Stochastic[100,50](close) c5 = (indicator8 > 80)
    My problem lies in c2 and c5 where I only need it the stochastic K% line to be under 20 when the “faster, black” adaptive MA crosses over the “slower, red” one. The K% line doesn’t need to be under 20 if the K% line keeps being over the D% line, meaning if the K% line crosses under the D% line before the K% line hits the value 80 only then can the system halt buying new contracts. If not then the system can solely rely on the adaptive MA indicators as long as the K% line keeps being over the D% line

    IF c4 AND c5 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF

    // Conditions to exit short positions
    indicator9 = AdaptiveAverage[20,2,3000](close)
    indicator10 = AdaptiveAverage[70,2,3000](close)
    c6 = (indicator9 CROSSES OVER indicator10)

    IF c6 THEN
    EXITSHORT AT MARKET
    ENDIF

    #187602

    Your code is a mess, can you tide it up and post it as plain text?

    #187604

    Just in case it is difficult for julopax with the blue button lacking :

     

     

    #187812

    It’s not clear enough.
    I’ll ask you one question at a time.
    Let’s talk only about LONG trades (Short is just the reverse). Question #1: what are the conditiuons to enter a LONG trade?

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

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