top of page

Daily SP500 with MACD

Updated: Jun 15, 2023

13 lines of code for the SP500 index on the daily timeframe.



The code


entrycondition1 = MACD[12,26,9][0] < MACD[12,26,9][1] and MACD[12,26,9][1] < MACD[12,26,9][2] and MACD[12,26,9][2] < MACD[12,26,9][3] and MACD[12,26,9][3] < MACD[12,26,9][4]

entrycondition2 = MACD[12,26,9][0] < 0 and close[0] < close[1]

entrycondition3 = (close - low) / (high - low) < 0.13

IF entrycondition1 and entrycondition2 and entrycondition3 THEN
BUY 1 CONTRACTS AT MARKET
ENDIF

exitcodition = close[0] > high[1]

If LongOnMarket AND exitcodition THEN
SELL AT MARKET
ENDIF

1件のコメント


Herman Unema
2022年6月21日

Small add on with reinvestment of gains 😎


//PRA Signal SP500 MACD Mean 21062022

//Daily time frame

//Spread 0.4p

//https://twitter.com/prorealalgos/status/1539270841535545345

//Added reinvestment


defparam cumulateorders = false


// TAILLE DES POSITIONS

REINV = 1

LEVIER = 1


IF REINV = 0 THEN

n = levier

ELSIF REINV = 1 THEN

capital = 500 + strategyprofit

n = (capital / 500)*levier

IF n < 1 THEN

n = 1

ENDIF

//n = round(n)

ENDIF


entrycondition1 = MACD[12,26,9][0] < MACD[12,26,9][1] and MACD[12,26,9][1] < MACD[12,26,9][2] and MACD[12,26,9][2] < MACD[12,26,9][3] and MACD[12,26,9][3] < MACD[12,26,9][4]

entrycondition2 = MACD[12,26,9][0] < 0 and close[0] < close[1]

entrycondition3 = (close - low) / (high - low) < 0.13


IF entrycondition1 and entrycondition2 and entrycondition3 THEN

BUY n CONTRACTS AT…


いいね!

Try the products free for 7 days

Easy setup • full version • get-started support

ProRealTime made easy

CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. On average 74% of retail investor accounts lose money when trading CFDs. Past performance is no guarantee of future results. You should consider whether you understand how CFDs work before starting.

Read full terms and conditions

ProRealTime™ is a trademark registered by the third-party entity ProRealTime SAS

We have no link with the ProRealTime™ entity that offers the ProRealTime™ trading software

Copyright ProRealAlgos 580648-4231
Harju maakond, Tallinn, Kesklinna linnaosa, Pille 13, 10173

bottom of page