Forums › ProRealTime Deutsch forum › ProOrder Support › Kleines GAP TRADEN › Reply To: Kleines GAP TRADEN
10/15/2025 at 3:38 PM
#252635
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
// --- System Parameters --- DEFPARAM CumulateOrders = FALSE // --- User-defined variables --- slPercentage = 1.5 stFactor1 = 3 stPeriod1 = 10 stFactor2 = 2 stPeriod2 = 8 // --- Variable Initialization --- once trailstop = low once target2R = high // --- Entry Logic --- IF NOT ONMARKET THEN // Reset the day counter when not in a position daysOntrade = 0 // Reset the buy signal at the start of each new day IF IntradayBarIndex = 0 THEN buySignalToday = 0 ENDIF // 1. Check the entry condition at 09:00 IF opentime = 090000 THEN percDiff = (close / DHigh(1) - 1) * 100 IF percDiff >= 0.5 AND percDiff <= 1 THEN buySignalToday = 1 ENDIF ENDIF // 2. Execute the buy order at 10:00 if the signal was triggered IF opentime = 100000 AND buySignalToday = 1 THEN BUY 1 CONTRACT AT MARKET ENDIF ENDIF // --- Position and Exit Management --- IF LONGONMARKET THEN // This block runs only once per trade, on the entry bar, to set initial values IF LONGONMARKET[1] = 0 THEN initialStopPrice = POSITIONPRICE * (1 - slPercentage / 100) trailStop = initialStopPrice initialRiskPoints = POSITIONPRICE - initialStopPrice target2R = POSITIONPRICE + (2 * initialRiskPoints) trailingState = 0// State 0: Initial SL, 1: Trailing ST(3,10), 2: Trailing ST(2,8) ENDIF // Priority check: Switch to aggressive trailing if 2:1 R:R target is hit IF close >= target2R AND trailingState < 2 THEN trailingState = 2 // Switch to aggressive trailing ENDIF // Check the "day after next" trailing condition (daysOntrade >= 2) // This is evaluated only once at 09:00 if still in the initial SL state (state 0) IF daysOntrade >= 2 AND opentime = 090000 AND trailingState = 0 THEN st1 = Supertrend[stFactor1, stPeriod1] IF POSITIONPERF > 0 AND close > st1 THEN trailingState = 1 // Start trailing with ST(3,10) ELSE SELL AT MARKET // Condition not met, close the position ENDIF ENDIF // Apply the Stop Loss based on the current state IF trailingState = 0 THEN // State 0: Initial fixed Stop Loss SET STOP PRICE trailStop ELSIF trailingState = 1 THEN // State 1: Trailing Stop with Supertrend (3,10) st1 = Supertrend[stFactor1, stPeriod1] trailStop = st1 SET STOP PRICE trailStop ELSIF trailingState = 2 THEN // State 2: Aggressive Trailing Stop with Supertrend (2,8) after hitting 2R target st2 = Supertrend[stFactor2, stPeriod2] trailStop = st2 SET STOP PRICE trailStop ENDIF // Increment the day counter at the start of each new day in the trade IF IntradayBarIndex = 0 THEN daysOntrade = daysOntrade + 1 ENDIF ENDIF // --- Chart Visualization --- graphonprice trailStop as "TrailStop" coloured("red") graphonprice target2R as "Target" coloured("green") graph percDiff as "%diff" coloured("red") graph 0.5 as "% min" coloured("blue") graph 1 as "% max" coloured("blue") graph 0 as "zero" |