Dear All,
I am new to this forum so I don’t know if I am at the right place here so please forgive me if I am wrong. I attatched an printscreen of a FDAX 5′ PRT chart from 14-15/01/2019.
I have an idea for an indicator and someone helped me to code it in PRT but has no more time and the code doesn’t work properly and I don’t know anything about coding and unfortunately, at the moment, don’t have the time to learn it.
I have the following variables: LOW1, LOW2 and LOW3, CLOSE1, CLOSE2 and CLOSE3, RSI1, RSI2 and RSI3
1. With the red candle at 1 the RSI goes below 29 (RSIBottom1). Then the “system” starts and I get a 1st value for the variable RSI1 = the rsi value of that current candle, nml 28.93 so RSI1 = 28.93 This is also linked to a low nml LOW1 = low value of that current candle, here 10881 and also a value for the current close = CLOSE1 = here 10883.5.
2. The following candle has a lower low but a higher close (1 point higher close is enough) and that close is also higher than the “open”. Here the current candle is low <LOW1 and so the value of the variable LOW1 becomes the new low of the current green candle, here 10876.5. So LOW1 = 10876.5 The rsi is not lower so RSI1 remains the same (RSI1 = 28.93). From that close current bar> = CLOSE1 +1 point the candleteller also starts to run (numberofbars) CLOSE1 also remains at the same value (CLOSE1 = 10883.5)
3. With the third candle we have no lower low nor rsi so the values for RSI1 and LOW1 remain the same
4. In the fourth candle the index is about 10896.5 and therefore more than 20 points difference with LOW1 (moveupafterlow). From now on we will search / see if we get a new low that <LOW1 (10881) with a close that <CLOSE1 and rsi> RSI1. The variables CLOSE1, RSI1 and LOW1 remain the same. (Note: If from now on the index should rise so fast that the RSI exceeds 70, the whole system will be canceled and we have to start from the beginning.)
5. The lower low <10881 only arrives at the red candle “2”.
- The low of this red candle to 2 is 10862 this is <LOW1 so we have a value for LOW2;
- The corresponding rsi value of this candle is 31.04 and this is> RSI1 so new variable RSI2 = 31.04 and
- the close of this candle is 10863 what <CLOSE1 so new variable CLOSE2 = 10863 and
- the number of candles is <30 (numerofbars)
All first conditions are met. Now the last one
6. The next candle MUST be a green candle where the close of this green candle> = 10865 (or CLOSE2 +2 points) and it must be a real hammercandle so (high-close) +2 <(open-low) The low of this candle may be <LOW2 but that’s not obligatory.
If all these criteria are met then the indicator should mention “1” AND all variabeles should be reset. Only if thereafter the RSI drops below 29, the system should restart from the beginning.
Hence nothing happens at 4 (1st green candle after 4 is not a hammer), but something should happen at the red 5 because here again there is a lower low (LOW3 <LOW2) and a lower close (CLOSE3 <CLOSE2) and rsi (RSI3> RSI1) and index has risen more than 20 points since LOW2and the green candle 5 is a hammer with close> = CLOSE3 + 2 points.
//Creating signals based on past divergences. Coding backwards. Check each new candle on the indicated setup.
//Building on the 5-min chart
//Max length of setup : 40 candles
//Version 22feb2019
RSIind = RSI[14](close)
//Find lowest low in RSI over the last NumberOfBars candles
RSILow1 = Lowest[NumberOfBars](RSIind)
IF RSILow1 < RSIBottom1 THEN
//reset all values
NoSignal = 0
NoSignalPart1 = 1
NoSignalPart2 = 1
NoSignalPart3 = 1
PriceLow1 = 0
PriceClose1 = 0
RSIBarindexLow1 = 0
PriceClose1NextBar = 0
GreenBarCondition = 0
BarindexDistanceToHigh = 0
MoveUpBarindex = 0
RSILow2 = 0
PriceLow2 = 0
GreenBarClose2Condition = 0
//Part 1
//find the barindex of the lowest RSI low, to also find the corresponding Price Low
//if RSI not below 29, stop calculating => No signal
FOR i=0 to NumberOfBars do
IF RSIind[i] = RSILow1 THEN
RSIBarindexLow1 = barindex[i]
PriceLow1 = low[i]
PriceClose1 = close[i]
IF i=0 then
//At this point cannot calc the close of next bar, so no signal yet
NoSignal = 1
ENDIF
IF NoSignal = 0 THEN
//Calc the Next bar close
PriceClose1NextBar = close[i-1]
//Addition : If low of this next bar is lower then PriceLow1 then update the low
IF low[i-1] < PriceLow1 THEN
PriceLow1 = low[i-1]
ENDIF
//Check if the candle following the 1st low is a green bar -> If not, no signal
GreenBarCondition = PriceClose1NextBar - PriceClose1
//If the next bar close is not 2 points higher then Close1 then no signal
if GreenBarCondition < MinGreenBar1 THEN
NoSignal = 1
endif
BREAK
ENDIF
ENDIF
//If condition is still valid, this section part is DONE
IF NoSignal = 0 THEN
NoSignalPart1 = 0
ENDIF
NEXT
//END Part 1
//Part 2 :Find the first Barindex after the RSILow where the distance is 20
BarindexDistanceTo1stLow = barindex - RSIBarindexLow1
if BarindexDistanceTo1stLow > 0 THEN
n = BarindexDistanceTo1stLow
Count = 0
Signal = 0
WHILE n <> 0 DO
IF High[n-1] - PriceLow1 > MaxUpAfterLow1 THEN
n = 0
Count = Count + 1
signal = 1
ELSE
n = n - 1
Count = Count +1
ENDIF
WEND
if signal = 1 THEN
MoveUpBarindex = RSIBarindexLow1 + Count
NoSignalPart2 = 0
ELSE
MoveUpBarindex = 0
NoSignalPart2 = 1
ENDIF
ENDIF
//END Part 2
//Part 3 : Find RSI2 low
IF NoSignal = 0 and MoveUpBarindex > 0 THEN
BarindexDistanceToHigh = barindex - MoveUpBarindex
IF BarindexDistanceToHigh > 0 THEN
RSILow2 = Lowest[BarindexDistanceToHigh](RSIind)
//Find barindex of the lowest 2nd RSI low
FOR l=0 to BarindexDistanceToHigh do
IF RSIind[l] = RSILow2 THEN
PriceLow2 = low[l]
IF l=0 then
//Cannot calc the close of next bar at this moment, so no signal yet
NoSignal = 1
ENDIF
IF NoSignal = 0 THEN
//Check if the candle following the low is a green one -> If not, no signal
GreenBarClose2Condition = close[l-1] - close[l]
if GreenBarClose2Condition < MinGreenBar2 THEN
NoSignal = 1
endif
ENDIF
BREAK
ENDIF
NEXT
//PriceLow2 must be 2 points lower then pricelow1
IF PriceLow1 - PriceLow2 < PriceLowerLow2 THEN
NoSignal = 1
ENDIF
//2nd RSI low must be at least 2 points higher then the first low, if not, no signal
IF RSILow2 - RSILow1 < RSIHigherLow2 THEN
NoSignal = 1
ENDIF
ELSE
NoSignal = 1
ENDIF
IF NoSignal = 0 THEN
NoSignalPart3 = 0
ENDIF
ENDIF
ELSE
NoSignal = 1
ENDIF
IF NoSignal = 0 and NoSignalPart1 = 0 and NoSignalPart2 = 0 and NoSignalPart3 = 0 THEN
Alarm = 1
ELSE
Alarm = 0
ENDIF
return Alarm as "Alarm"
Normally the indicator should also be usable in the 1 “, 10”, 30 “etc …