long-short when Moving average changed color
Forums › ProRealTime English forum › ProOrder support › long-short when Moving average changed color
- This topic has 23 replies, 5 voices, and was last updated 7 years ago by Dave.
-
-
01/30/2017 at 7:42 PM #23141
how can i tell t0 backtest that must BUY when Quadruple Exponential Moving Average is green and sell when Quadruple Exponential Moving Average is red?
Thanks in advance
1234567891011121314151617181920<span class="token comment" spellcheck="true">//PRC_QEMA | indicator</span><span class="token comment" spellcheck="true">//23.01.2017</span><span class="token comment" spellcheck="true">//Nicolas @ www.prorealcode.com</span><span class="token comment" spellcheck="true">//Sharing ProRealTime knowledge</span><span class="token comment" spellcheck="true">//--- parameters</span><span class="token comment" spellcheck="true">// period = 14</span><span class="token comment" spellcheck="true">// method = MOVING AVERAGE TYPE</span><span class="token comment" spellcheck="true">// ---</span>Price<span class="token operator">=</span>customcloseMA1<span class="token operator">=</span><span class="token indicators">Average</span><span class="token punctuation">[</span>period<span class="token punctuation">,</span>method<span class="token punctuation">]</span><span class="token punctuation">(</span>Price<span class="token punctuation">)</span>MA2<span class="token operator">=</span><span class="token indicators">Average</span><span class="token punctuation">[</span>period<span class="token punctuation">,</span>method<span class="token punctuation">]</span><span class="token punctuation">(</span>MA1<span class="token punctuation">)</span>MA3<span class="token operator">=</span><span class="token indicators">Average</span><span class="token punctuation">[</span>period<span class="token punctuation">,</span>method<span class="token punctuation">]</span><span class="token punctuation">(</span>MA2<span class="token punctuation">)</span>MA4<span class="token operator">=</span><span class="token indicators">Average</span><span class="token punctuation">[</span>period<span class="token punctuation">,</span>method<span class="token punctuation">]</span><span class="token punctuation">(</span>MA3<span class="token punctuation">)</span>MA5<span class="token operator">=</span><span class="token indicators">Average</span><span class="token punctuation">[</span>period<span class="token punctuation">,</span>method<span class="token punctuation">]</span><span class="token punctuation">(</span>MA4<span class="token punctuation">)</span>QEMA<span class="token operator">=</span><span class="token number">5</span><span class="token operator">*</span>MA1<span class="token number">-10</span><span class="token operator">*</span>MA2<span class="token operator">+</span><span class="token number">10</span><span class="token operator">*</span>MA3<span class="token number">-5</span><span class="token operator">*</span>MA4<span class="token operator">+</span>MA5<span class="token keyword">RETURN</span> QEMA <span class="token keyword">as</span> <span class="token string">"Quadruple Exponential Moving Average indicator"</span>01/31/2017 at 8:01 AM #23192Hi Enzo, Nicolas did this for me a couple of weeks ago, https://www.prorealcode.com/topic/place-orders-when-a-curve-change-colour/ it is for a single ma but i’m sure the condition could be added to incorperate all types of ma as per the indicator. hope it helps.
dave
1 user thanked author for this post.
01/31/2017 at 11:14 AM #2322101/31/2017 at 12:56 PM #23248HI, SOME TIME WORKS ..SOME TIMES NOT….WHY? LOOK AT THE PIC
THANKS
THE CODE IS:
12345678910111213141516171819202122// Definizione dei parametri del codiceDEFPARAM CumulateOrders = false // Posizioni cumulate disattivate// Condizioni per entrare su posizioni longindicator3 = CALL "MM Quatruple EXP"[cinq, uno](close)indicator4 = CALL "MM Quatruple EXP"[cinq, uno](close)c2 = indicator3 > indicator4[1] and indicator4[1] < indicator3IF c2 THENBUY 1 CONTRACT AT MARKETENDIF// Condizioni per entrare su posizioni shortindicator8 = CALL "MM Quatruple EXP"[cinq, uno](close)indicator9 = CALL "MM Quatruple EXP"[cinq, uno](close)c5 = indicator8 < indicator9[1] and indicator9[1]> indicator8IF c5 THENSELLSHORT 1 CONTRACT AT MARKETENDIF01/31/2017 at 2:25 PM #2327501/31/2017 at 3:05 PM #2328401/31/2017 at 3:17 PM #23286hi DAVE, i tried..but it is the same….very strange
12345678910111213141516171819202122// Definizione dei parametri del codiceDEFPARAM CumulateOrders = false // Posizioni cumulate disattivate// Condizioni per entrare su posizioni longindicator3 = CALL "MM Quatruple EXP"[150, 4](close)c2 = indicator3 > indicator3[1] and indicator3[1] < indicator3[2]IF c2 THENBUY 1 CONTRACT AT MARKETENDIF// Condizioni per entrare su posizioni shortindicator8 = CALL "MM Quatruple EXP"[150, 4](close)c5 = indicator8 < indicator8[1] and indicator8[1]> indicator8[2]IF c5 THENSELLSHORT 1 CONTRACT AT MARKETENDIF01/31/2017 at 3:40 PM #2328801/31/2017 at 3:45 PM #23292// Definizione dei parametri del codice
DEFPARAM CumulateOrders = false // Posizioni cumulate disattivate// Condizioni per entrare su posizioni long
indicator3 = CALL “MM Quatruple EXP”[cinq, uno](close)
c2 = indicator3 > indicator3[1] and indicator3[1] < indicator3[2]
IF c2 THEN
BUY 1 CONTRACT AT MARKet// Condizioni per entrare su posizioni short
indicator8 = CALL “MM Quatruple EXP”[cinq, uno](close)
c5 = indicator8 < indicator8[1] and indicator8[1]> indicator8[2]
IF c5 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF01/31/2017 at 10:02 PM #2335202/01/2017 at 9:58 AM #2337902/01/2017 at 10:39 AM #2339102/01/2017 at 10:46 AM #2339302/01/2017 at 7:59 PM #2346602/02/2017 at 2:09 PM #23605 -
AuthorPosts
Find exclusive trading pro-tools on