Hello, I want to introduce you to one of my works. I hope for numerous comments and for one or the other idea whether there is still room for improvement.
The system traditionally acts as a setback in the upward trend. Doubled over a grid with greater loss, but is capped at a maximum of 3 positions. So quite risk-free.
I also added a multi-timeframe, but only to get even better results with the trailing stop.
I have been trading a similar system in the H1 for a long time, with great results.
// Festlegen der Code-Parameter
DEFPARAM CumulateOrders = true // Kumulieren von Positionen deaktiviert
DEFPARAM Preloadbars = 300
//timeframe(15 minute, updateonclose)
gridStep = 20 //20
MAXSHARES = abs(COUNTOFPOSITION) <= 1 //1
// Verhindert das Platzieren von neuen Ordern zum Markteintritt oder Vergrößern von Positionen vor einer bestimmten Uhrzeit
noEntryBeforeTime = 010000
timeEnterBefore = time >= noEntryBeforeTime
// Verhindert das Platzieren von neuen Ordern zum Markteintritt oder Vergrößern von Positionen nach einer bestimmten Uhrzeit
noEntryAfterTime = 233000
timeEnterAfter = time < noEntryAfterTime
// Verhindert das Trading an bestimmten Wochentagen
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// Long
indicator1 = Average[25](close)//25
indicator2 = Average[180](close)//180
c1 = (indicator1 CROSSES UNDER indicator2)
indicator3 = ADX[14]
c2 = (indicator3 > 10)
indicator4 = ADX[14]
c3 = (indicator4 < 30) //30
IF not longonmarket and (c1 AND c2 AND c3) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
//grid
if longonmarket and tradeprice-close>=gridStep*pointsize and maxshares then
buy 2 contract at market
endif
// Longexit
indicator5 = Average[25](close)//25
indicator6 = Average[180](close)//180
c4 = (indicator5 CROSSES OVER indicator6)
IF c4 THEN
SELL AT MARKET
ENDIF
// Stops und Targets
SET STOP pLOSS 75 //75
//timeframe(default) //5 minute
//************************************************************************
//trailing stop function
trailingstart = 8 //8 trailing will start @trailinstart points profit
trailingstep = 1 //1 trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-positionprice>=trailingstart*pipsize THEN
newSL = positionprice+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND positionprice-close>=trailingstart*pipsize THEN
newSL = positionprice-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF