Hi Nicolas,
I would ask for a help in my simple strategy using PRt Bands (I’ve used different interesting pieces of indicators found in the forum)
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
EXP1 = ExponentialAverage[1](close)
up = PRTBANDSUP
dn = PRTBANDSDOWN
a = PRTBandsmediumterm
if close crosses over up and trend<=0 then //prezzo supera banda superiore
trend=1
elsif close crosses under dn and trend>=0 then //prezzo ribassa banda inferiore
trend=-1
ENDIF
c4 = trend<>trend[1]
ONCE Periods = 60
ONCE hi1 = 0
ONCE hi2 = 0
ONCE hi3 = 0
ONCE lo1 = 0
ONCE lo2 = 0
ONCE lo3 = 0
Bullish = close > open
Bearish = close < open
NewHigh = (high = highest[Periods](high))
NewLow = (low = lowest[Periods](low))
HIswing = Bullish[1] AND Bearish AND NewHigh[1]
LOswing = Bearish[1] AND Bullish AND NewLow[1]
IF HIswing THEN
hi3 = hi2
hi2 = hi1
hi1 = high[1]
ENDIF
IF LOswing THEN
lo3 = lo2
lo2 = lo1
lo1 = low[1]
ENDIF
c5 = a > lo1 and hi1 >hi2
//condizione per entrare Long
IF NOT longonmarket and Trend=1 and c4 and c5 then
BUY 10 SHARES AT MARKET
ENDIF
// Conditions to exit long positions
//IF longonmarket and TREND=-1 and c4 THEN
IF longonmarket and close<lo1 THEN
SELL AT MARKET
ENDIF
//condizione per entrare Short
//IF NOT shortonmarket and Trend=-1 and c4 then
//SELL 10 SHARES AT MARKET
//ENDIF
// Conditions to exit short positions
//IF shortonmarket and TREND=1 and c4 THEN
//BUY AT MARKET
//ENDIF
I’d like to add the use of this amazing indicator Wick pressure https://www.prorealcode.com/prorealtime-indicators/wick-pressure/
How can I add the conditon that when trend changes from red to green, there have been wick pressure in the last red trend ? that could helpful to filter many enters long. last question, in the strategy I have deactiveted enter shorts because for some reason it doesn’t work. I know that PRT bands has not be designed to work short but it should work the same, right ? I’ve thought the strategy for large cap stocks, when sstocks are in pre market or after market, is it correct to use buy at market? I know that in pre market and after market Proreal time work only with order limit, my doubt is that in backtest it work but in live it does not work. How could I change the strategy, if it’s this the case?
thank’s for any help you could give me
AleX
First you need to modify the indicator so that it returns a value indicating the type of rectangle, I put 1=green and -1=red:
//PRC_Wick Pressure | indicator
//23.05.2022
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//converted from pinescript
// --- settings
//atrmult = 0.7 //ATR Multiplier (The Wick area is filtered on the basis of atr and this is multiplier to that ATR. The more the multiplier value, the less the signals and vice versa)
//boxlength = 16 //Length of Wick Pressure Box
//rsiob = 60 //RSI based on which signnals are filtered
//rsios = 40 //RSI based on which signnals are filtered
// --- end of settings
meersi = rsi[14](close)
signal = 0
//bullish wick pressure
rsibullishcond = meersi < rsios or meersi[1] < rsios or meersi[2] < rsios
ll3 = lowest[3](low)
lc3 = min(lowest[3](close),lowest[3](open))
if low<=lc3 and low[1]<=lc3 and low[2]<=lc3 and open>=lc3 and open[1]>=lc3 and open[2]>=lc3 and lc3-ll3>(atrmult*AverageTrueRange[14](close)) and rsibullishcond and close>open then
drawrectangle(barindex,lc3,barindex+boxlength, ll3) coloured("green",50) bordercolor("green")
signal = 1
endif
//bearish wick pressure
rsibearishcond = meersi > rsiob or meersi[1] > rsiob or meersi[2] > rsiob
hh3 = highest[3](high)
hc3 = max(highest[3](close), highest[3](open))
if high>=hc3 and high[1]>=hc3 and high[2]>=hc3 and open<=hc3 and open[1]<=hc3 and open[2]<=hc3 and hh3-hc3>(atrmult*AverageTrueRange[14](close)) and rsibearishcond and close<open then
drawrectangle(barindex,hh3,barindex+boxlength, hc3) coloured("red",50) bordercolor("red")
Signal = -1
endif
return Signal AS "Signal"
after which it enters when C4 is true (change of Trend), provided that in the previous change there was at least one signal (it doesn’t matter which one because I’m not sure which one should be taken into consideration, if the Red one or the Green one):
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
ONCE Segnale = 0
// Conditions to enter long positions
EXP1 = ExponentialAverage[1](close)
up = PRTBANDSUP
dn = PRTBANDSDOWN
a = PRTBandsmediumterm
if close crosses over up and trend<=0 then //prezzo supera banda superiore
trend=1
elsif close crosses under dn and trend>=0 then //prezzo ribassa banda inferiore
trend=-1
ENDIF
c4 = trend<>trend[1]
Segnale = CALL "PRC_Wick Pressure v2"[0.7, 16, 60, 40]
IF Segnale <> Segnale[1] THEN
Entrata = Segnale[1]
ENDIF
ONCE Periods = 60
ONCE hi1 = 0
ONCE hi2 = 0
ONCE hi3 = 0
ONCE lo1 = 0
ONCE lo2 = 0
ONCE lo3 = 0
Bullish = close > open
Bearish = close < open
NewHigh = (high = highest[Periods](high))
NewLow = (low = lowest[Periods](low))
HIswing = Bullish[1] AND Bearish AND NewHigh[1]
LOswing = Bearish[1] AND Bullish AND NewLow[1]
IF HIswing THEN
hi3 = hi2
hi2 = hi1
hi1 = high[1]
ENDIF
IF LOswing THEN
lo3 = lo2
lo2 = lo1
lo1 = low[1]
ENDIF
c5 = a > lo1 and hi1 >hi2
//condizione per entrare Long
IF NOT longonmarket and Trend=1 and Entrata[1] and c4 and c5 then
BUY 10 SHARES AT MARKET
ENDIF
// Conditions to exit long positions
//IF longonmarket and TREND=-1 and c4 THEN
IF longonmarket and close<lo1 THEN
SELL AT MARKET
ENDIF
//condizione per entrare Short
//IF NOT shortonmarket and Trend=-1 and c4 then
//SELL 10 SHARES AT MARKET
//ENDIF
// Conditions to exit short positions
//IF shortonmarket and TREND=1 and c4 THEN
//BUY AT MARKET
//ENDIF
//graph c4
//graph Segnale
//graph Entrata
if you want to specify the type of rectangle that should have been diaplayed before the trend change, just tell me.
Hi Roberto,
thank you for your amazing work.
since PRT bands work only for long, I need to enter long only when the green bullish rectangle is in the red trend before the change of trend (for PRT bands). if possible.
thank’s in advance
is it possible to define both the conditions, bullish pressure and bearish pressure? green bullish rectangle when trend is red (so before the change of trend to green on PRT bands) and viceversa for bearsh red rectangle. Then it will be on me to define a condition for short instead of long. For bearish I was thinking to use Supertrend
Hi Roberto,
I know you’re very busy, but I’d like to ask a suggestion for the code in a simpler way in order not to use mcuh of your time, I’ve tried to do it but there ‘s something that I don’t get. How can I do a buy order when the wick bullish pressure gives the signal and viceversa a sell order when a wick bearish pressure signal gives the signal? also if possible a stop limit order above the rectangle (for green) or below the rectangle (for red) ?
thank you very much in advance
Alex
Sorry for the delay.
I coded this update:
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
ONCE Segnale = 0
// Conditions to enter long positions
EXP1 = ExponentialAverage[1](close)
up = PRTBANDSUP
dn = PRTBANDSDOWN
a = PRTBandsmediumterm
if close crosses over up and trend<=0 then //prezzo supera banda superiore
trend=1
elsif close crosses under dn and trend>=0 then //prezzo ribassa banda inferiore
trend=-1
ENDIF
c4 = trend<>trend[1]
Segnale = CALL "PRC_Wick Pressure v2"[0.7, 16, 60, 40]
IF Segnale <> Segnale[1] THEN
Entrata = Segnale[1]
ENDIF
ONCE Periods = 60
ONCE hi1 = 0
ONCE hi2 = 0
ONCE hi3 = 0
ONCE lo1 = 0
ONCE lo2 = 0
ONCE lo3 = 0
Bullish = close > open
Bearish = close < open
NewHigh = (high = highest[Periods](high))
NewLow = (low = lowest[Periods](low))
HIswing = Bullish[1] AND Bearish AND NewHigh[1]
LOswing = Bearish[1] AND Bullish AND NewLow[1]
IF HIswing THEN
hi3 = hi2
hi2 = hi1
hi1 = high[1]
ENDIF
IF LOswing THEN
lo3 = lo2
lo2 = lo1
lo1 = low[1]
ENDIF
c5 = a > lo1 and hi1 >hi2
//condizione per entrare Long
IF NOT longonmarket and Trend=1 and Entrata[1] = -1 and c4 and c5 then
BUY 10 SHARES AT MARKET
ENDIF
// Conditions to exit long positions
//IF longonmarket and TREND=-1 and c4 THEN
IF longonmarket and close<lo1 THEN
SELL AT MARKET
ENDIF
//condizione per entrare Short
IF NOT shortonmarket and Entrata = 1 and c4 then
SELLSHORT 10 SHARES AT MARKET
ENDIF
// Conditions to exit short positions
IF shortonmarket and TREND=1 and c4 THEN
EXITSHORT AT MARKET
ENDIF
//graph c4
//graph Segnale
//graph Entrata
Hi Roberto,
thank’s for your update and time. Strategy does not work, sometimes goes long outside green rectangle and sometimes it goes short in green rectangle and viceversa, it works random. Can I ask you please if it’s possible to forget the strategy and focus only on wick pressure.
A strategy that goes long when there is bullish condition and goes short on red rectangle with bearish condition. Condition for exit long Position when there is short bearish condition, and viceversa for short. Hope to be clear. Then I’ll take care of adding other indicators or conditions.
Thank’s in advance
Alessio
Hi Roberto. could be something like this? the strange thing is that doing the backtest I see the positions opened in the chart but the detailed report shows Zero positions opened. I don’t understand why
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
ONCE Segnale = 0
// Conditions to enter long positions
//PRC_Wick Pressure | indicator
//23.05.2022
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//converted from pinescript
// --- settings
atrmult = 0.7 //ATR Multiplier (The Wick area is filtered on the basis of atr and this is multiplier to that ATR. The more the multiplier value, the less the signals and vice versa)
//boxlength = 16 //Length of Wick Pressure Box
rsiob = 60 //RSI based on which signnals are filtered
rsios = 40 //RSI based on which signnals are filtered
// --- end of settings
meersi = rsi[14](close)
signal = 0
//bullish wick pressure
rsibullishcond = meersi < rsios or meersi[1] < rsios or meersi[2] < rsios
ll3 = lowest[3](low)
lc3 = min(lowest[3](close),lowest[3](open))
if low<=lc3 and low[1]<=lc3 and low[2]<=lc3 and open>=lc3 and open[1]>=lc3 and open[2]>=lc3 and lc3-ll3>(atrmult*AverageTrueRange[14](close)) and rsibullishcond and close>open then
//drawrectangle(barindex,lc3,barindex+boxlength, ll3) coloured("green",50) bordercolor("green")
signal = 1
BarLongsignal=Barindex
endif
If Barindex=BarLongsignal+2 then
Signal=0
endif
//bearish wick pressure
rsibearishcond = meersi > rsiob or meersi[1] > rsiob or meersi[2] > rsiob
hh3 = highest[3](high)
hc3 = max(highest[3](close), highest[3](open))
if high>=hc3 and high[1]>=hc3 and high[2]>=hc3 and open<=hc3 and open[1]<=hc3 and open[2]<=hc3 and hh3-hc3>(atrmult*AverageTrueRange[14](close)) and rsibearishcond and close<open then
//drawrectangle(barindex,hh3,barindex+boxlength, hc3) coloured("red",50) bordercolor("red")
Signal = -1
BarShortsignal=Barindex
If Barindex=Barshortsignal+2 then
Signal=0
endif
endif
//condizione per entrare Long
IF NOT longonmarket and Signal = 1 then
BUY 1 SHARES AT MARKET
ENDIF
// Conditions to exit long positions
//condizione per entrare Short
IF NOT shortonmarket and signal = -1 then
SELLSHORT 1 SHARES AT MARKET
ENDIF
// Conditions to exit short positions
//graph c4
//graph Segnale
//graph Entrata
set stop %loss 2
set stop %profit 4
can you help me ,please? thank’s in advance
Alessio
Signals are returned by the indicator.
Do you need to change it?
Can you explain me when it has to enter Long and Short, when a rectangle starts or ends, when it’s Red or Green?
Hi roberto, when a bullish signal appear on a candle , I would like to set a stop limit some pipes above the high of that candle, viceversa for short, when a bearish signal appears, a short stop limit some pipes below that candle.
thank’s in advance
Alessio