Not placing any trades in back testing.
Y: long sMA
C1 and C2 : sma turning up
C3 and C4 : sma turning down
X : numerical value if difference between current sma and sma 40 periods ago
DEFPARAM FLATBEFORE = 060000
// Cancel all pending orders and close all positions at the "FLATAFTER" time
DEFPARAM FLATAFTER = 220000
X = (average[Y,0] - average[Y,40])
// Conditions to enter long positions
indicator1 = Average[A]
indicator2 = Average[A]
c1 = (indicator1 > indicator2[1])
indicator3 = Average[A]
indicator4 = Average[A]
c2 = (indicator3[1] < indicator4[2])
IF c1 AND c2 AND X > C THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to enter short positions
indicator5 = Average[A]
indicator6 = Average[A]
c3 = (indicator5 < indicator6[1])
indicator7 = Average[A]
indicator8 = Average[A]
c4 = (indicator7[1] > indicator8[2])
IF c3 AND c4 AND X < -C THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Stops and targets
SET STOP pLOSS D
SET TARGET pPROFIT E
Thank you
Have you tried many Markets and many TF’s?
If C=condition (say Close > close[1]) how can X be > or < ?
steynpj – Please give your topics more meaningful titles otherwise we end up with a forum full of ‘Help needed’ topics! I have changed your topic title. Also do not post your question/comments within the PRT code box. Only put actual code in the code insertion box. I have edited your post to tidy everything up.
My mistake.
The capital “C”, is a variable in back testing, any numerical value.
For this line, X = (average[Y,0] – average[Y,40])
The first parameter is the average type, second parameter is the period. I’m not sure if it is expected for period 0?
It’s the other way round with AVERAGE. The first parameter is the PERIODS, the second one, optional, is the average type.
40 is not supported. Read official documentation for allowed types.
Line 5 should read:
X = (average[Y,0] - average[Y,0][40])
- Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.
Don’t worry I will change it for you! I’m so happy to do it! 🙂
Thank you, @robertogozzi for the clarification, my mistake, shame on me. Btw, just my 2 cents, I think could be easier if author just do the GRAPH on several variables to understand where is the problem. As the code is not complete and some typo, then we keep guessing.