Good morning, I am grateful to this community for the wealth of ideas it provides. As a token of my gratitude, I am posting my first humble contribution: a strategy based simply on the ADX indicator and applied to the 30-minute Nasdaq index (but it can be adapted to other indices by optimising k, u, stop loss and gain). It only operates in the first part of the week and closes on Thursday. Comments and advice are welcome. Thank you.
Here is the code:
//nasdaq 30 minuti
DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
// Condizioni per entrare su posizioni long
K=16
u=26
n=1
s=7
indicator1 = DIplus[s] (CLOSE)
indicator2 = DIminus[s](close)
c3 = (ADX[s]>K)
c5 = INDICATOR1 crosses over u
c2= indicator1>u
c6= adx[s] crosses over k
finestra= (dayofweek=1 or dayofweek=2 or dayofweek=3)
IF ((c3 and c5) or( c6 and c2)) and finestra THEN
BUY n CONTRACT AT MARKET
ENDIF
if currentdayofweek=4 and time >= 175000 THEN
Sell n contract at market
Endif
// Stop e target
SET STOP pLOSS 600
SET TARGET pPROFIT 200
You must be logged in to post a comment.
Thank you very much for the strategy,
i will appreciate a different stop loss and target setting:
SET STOP pLOSS 400 SET TARGET pPROFIT 600
Thank you for sharing your strategy: I dare to change it a bit, adding the complete trailing stop code function and expressing the trailing as % from Close, considering the long time period for simulation. Check it and feel free to test it for other TF or index.
The optimization was done with a minimum drawdown request
//nasdaq 30 minuti PROREALCODE
DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
// Condizioni per entrare su posizioni long
//trailing stop
trailingstop = 0.42*Close/100
//resetting variables when no trades are on market
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif
K=16
u=26
n=1
s=7
indicator1 = DIplus[s] (CLOSE)
indicator2 = DIminus[s](close)
c3 = (ADX[s]>K)
c5 = INDICATOR1 crosses over u
c2= indicator1>u
c6= adx[s] crosses over k
finestra= (dayofweek=1 or dayofweek=2 or dayofweek=3)
IF ((c3 and c5) or( c6 and c2)) and finestra THEN
BUY n CONTRACT AT MARKET
ENDIF
if currentdayofweek=4 and time >= 175000 THEN
Sell n contract at market
Endif
//case LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if MAXPRICE-tradeprice(1)>=trailingstop then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop //set the exit price at the MFE - trailing stop price level
endif
endif
//exit on trailing stop price levels
if onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endif