GMMA Code error

Viewing 4 posts - 1 through 4 (of 4 total)
  • #236880

    // Define the GMMA groups
    shortGuppy1 = average[3](close)
    shortGuppy2 = average[5](close)
    shortGuppy3 = average[8](close)
    shortGuppy4 = average[10](close)
    shortGuppy5 = average[12](close)
    shortGuppy6 = average[15](close)

    longGuppy1 = average[30](close)
    longGuppy2 = average[35](close)
    longGuppy3 = average[40](close)
    longGuppy4 = average[45](close)
    longGuppy5 = average[50](close)
    longGuppy6 = average[60](close)

    // Buy signal: All short-term moving averages above all long-term moving averages
    buyCondition = shortGuppy1 > longGuppy1 AND shortGuppy2 > longGuppy2 AND shortGuppy3 > longGuppy3 AND shortGuppy4 > longGuppy4 AND shortGuppy5 > longGuppy5 AND shortGuppy6 > longGuppy6

    // Sell signal: All short-term moving averages below all long-term moving averages
    sellCondition = shortGuppy1 < longGuppy1 AND shortGuppy2 < longGuppy2 AND shortGuppy3 < longGuppy3 AND shortGuppy4 < longGuppy4 AND shortGuppy5 < longGuppy5 AND shortGuppy6 < longGuppy6

    // Execute the buy and sell orders
    if buyCondition then
    BUY 1 CONTRACTS AT MARKET
    SET TARGET pPROFIT 10
    ENDIF

    // Conditions to exit long positions
    If sellCondition then
    SELL AT MARKET
    // Define the GMMA groups
    shortGuppy1 = average[3](close)
    shortGuppy2 = average[5](close)
    shortGuppy3 = average[8](close)
    shortGuppy4 = average[10](close)
    shortGuppy5 = average[12](close)
    shortGuppy6 = average[15](close)

    longGuppy1 = average[30](close)
    longGuppy2 = average[35](close)
    longGuppy3 = average[40](close)
    longGuppy4 = average[45](close)
    longGuppy5 = average[50](close)
    longGuppy6 = average[60](close)

    // Buy signal: All short-term moving averages above all long-term moving averages
    buyCondition = shortGuppy1 > longGuppy1 AND shortGuppy2 > longGuppy2 AND shortGuppy3 > longGuppy3 AND shortGuppy4 > longGuppy4 AND shortGuppy5 > longGuppy5 AND shortGuppy6 > longGuppy6

    // Sell signal: All short-term moving averages below all long-term moving averages
    sellCondition = shortGuppy1 < longGuppy1 AND shortGuppy2 < longGuppy2 AND shortGuppy3 < longGuppy3 AND shortGuppy4 < longGuppy4 AND shortGuppy5 < longGuppy5 AND shortGuppy6 < longGuppy6

    // Execute the buy orders
    if buyCondition then
    BUY 1 CONTRACTS AT MARKET
    SET TARGET pPROFIT 10
    ENDIF
    // Conditions to exit long positions
    If sellCondition then
    SELL AT MARKET
    ENDIF

    // Execute the short sell orders
    if sellCondition then
    SELLSHORT 1 CONTRACTS AT MARKET
    SET TARGET pPROFIT 10
    ENDIF
    // Conditions to exit short positions
    if buyCondition then
    BUY AT MARKET
    ENDIF

    Could you please check where the error in this code

    #236881

    Hi. I get:

    ERROR: Line 1:  One of the following characters would be more suitable than “end of code”. ENDIF

    On line 29, There an IF statement block which is not terminated by its own ENDIF command.

    As a solution, I placed an additional ENDIF at the end of the code to remove error.

     

    #236883

    Hi,

    it looks like 2 redundant copy-paste blocks, with the second partially deleting the end of the first one, hence a missing endif.

    Worth trying deleting all the first few lines from line 1 (the first “// Define the GMMA groups”) until the first occurence of “SELL AT MARKET”, and keeping the rest from the next line (again a “// Define the GMMA groups”) until the end. So what’s left to try running is this smaller code:

     

     

    1 user thanked author for this post.
    #236885

    I don’t edit the above post, as its purpose was just to extract the appropriate part of a presumed double copy-paste, not to make further changes, but if your purpose in its line 37 is to exit short positions, then the keyword in line 39 shouldn’t be BUY, it should be EXITSHORT at market:

    https://www.prorealcode.com/documentation/exitshort/

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

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