GMMA Code error
Forums › ProRealTime English forum › ProOrder support › GMMA Code error
- This topic has 3 replies, 3 voices, and was last updated 2 months ago by JC_Bywan.
-
-
08/30/2024 at 5:29 AM #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
ENDIFCould you please check where the error in this code
08/30/2024 at 6:48 AM #236881Hi. 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.
08/30/2024 at 7:17 AM #236883Hi,
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:
12345678910111213141516171819202122232425262728293031323334353637383940// Define the GMMA groupsshortGuppy1 = 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 averagesbuyCondition = 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 averagessellCondition = shortGuppy1 < longGuppy1 AND shortGuppy2 < longGuppy2 AND shortGuppy3 < longGuppy3 AND shortGuppy4 < longGuppy4 AND shortGuppy5 < longGuppy5 AND shortGuppy6 < longGuppy6// Execute the buy ordersif buyCondition thenBUY 1 CONTRACTS AT MARKETSET TARGET pPROFIT 10ENDIF// Conditions to exit long positionsIf sellCondition thenSELL AT MARKETENDIF// Execute the short sell ordersif sellCondition thenSELLSHORT 1 CONTRACTS AT MARKETSET TARGET pPROFIT 10ENDIF// Conditions to exit short positionsif buyCondition thenBUY AT MARKETENDIF1 user thanked author for this post.
08/30/2024 at 8:44 AM #236885I 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:
-
AuthorPosts
Find exclusive trading pro-tools on