PRT bands strategy
Forums › ProRealTime English forum › ProOrder support › PRT bands strategy
- This topic has 5 replies, 2 voices, and was last updated 1 year ago by robertogozzi.
-
-
02/28/2023 at 8:56 PM #210675
Hi everyone,
It’s a week that I’m trying to understand Probuilder language, so it’s very difficult for me. I’m trying a strategy, very simple, that work with PRT bands when trend change from red to green.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positions
EXP1 = ExponentialAverage[1](close)
up = PRTBANDSUP
indicator8 = ExponentialAverage[50](close)
c1 = (EXP1 CROSSES OVER up )
EXP50 = ExponentialAverage[50](close)
EXP100 = ExponentialAverage[100](close)
c2 = (EXP50 >= EXP100)
if close crosses over up and trend<=0 then //le prix casse la bande supérieure
trend=1
elsif close crosses under dn and trend>=0 then //le prix casse la bande inférieure
trend=-1
ENDIF
c4 = trend<>trend[1]
IF c1 and c2 and c4 then
BUY 10 SHARES AT MARKET
ENDIF// Conditions to exit long positions
EXP1 = ExponentialAverage[1](close)
dn = PRTBANDSDOWN
c5 = (EXP1 CROSSES UNDER dn )IF c5 and c4 THEN
SELL AT MARKET
ENDIF// Stops and targets
SET STOP pLOSS 4probably there are many mistakes, but I’m just trying to understand the method. I’d like to use the strategy for medium-large stocks. I’d need a help to improve the strategy this way:
instead of Exp moving average as filter, I’d like an indcator, similar to Zig zag or Zig Zag itself, that make a condition to enter long only if there is a higher low or at least a low higher than one of the two previous lows (better if I can set the percentage of variation to determine highs and lows, in order to avoid small fluctuation).
in alternative it’d be great if I could use as condition something similar to ” stopping volume”, so for example looking at the previous 20 candles, determine the most bearish climax candles and to set a condition only if the last climax bearish candle have a ratio volume/body greater than the previous climax bearish candle.
more difficult is to determine exit strategy. actually it’s not good, it’s would be great if it could set a take profit when the price cross over (not at close) the upper band but Icannot make it work. I’d like to add also a trailing stop loss in a defined percentage under the last higher low.
I know I ask a lot but if someone can help me it would be great
thank’s
Alessio B.
03/01/2023 at 11:53 AM #210710Built-in ZigZag is a repainting indicator which cannot be used in autotrading. This one can be used, instead https://www.prorealcode.com/prorealtime-indicators/fractals-zigzag/.
I will try to help you asap.
03/01/2023 at 7:32 PM #21073503/02/2023 at 7:28 PM #210792Hi Roberto,
with my poor knownledge of program, I added short entry but It doesn’t work as I want; First of all for some reason it opens positions even if close of price is under EXP100, and it doesn’t open short position at all. I don’t know what I’m doing wrong. I summarize what I’d like to obtain:
Long if close of price up EXP100 or Short close under EXP100,in alternative a condition to enter long only if there is a higher low or at least a low higher than one of the two previous lows (better if I can set the percentage of variation to determine highs and lows, in order to avoid small fluctuation).
An additional condition something similar to ” stopping volume”, so for example looking at the previous 20 candles, determine the most bearish climax candles and to set a condition only if the last climax bearish candle have a ratio volume/body greater than the previous climax bearish candle.
more difficult is to determine exit strategy. actually it’s not good, it’s would be great if it could set a partial 50% take profit when the price cross over (not at close) the upper band and the rest when it closes under the band, the opposite for short. I’d like to add also a moving stop loss in a defined percentage under the last higher low.
Thank you very much for everything
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivatedEXP1 = ExponentialAverage[1](close)
up = PRTBANDSUP
dn = PRTBANDSDOWNif close crosses over up and trend<=0 then
trend=1
elsif close crosses under dn and trend>=0 then
trend=-1
ENDIFc1 = (EXP1 CROSSES OVER up )
EXP50 = ExponentialAverage[50](close)
EXP100 = ExponentialAverage[100](close)
c2 = close >= exp100
c3 = trend<>trend[1]// Conditions to enter long positions
IF NOT SHORTONMARKET AND c1 and c2 and c3 then
BUY 10 SHARES AT MARKET
ENDIF// Conditions to exit long positions
c4 = (EXP1 CROSSES UNDER dn )
IF c3 and c4 THEN
SELL AT MARKET
ENDIF// Conditions to enter short positions
c4 = (EXP1 CROSSES UNDER dn )
c5 = close <= exp100
IF NOT LONGONMARKET AND c4 and c5 then
SELL 10 SHARES AT MARKET
ENDIF// Conditions to exit short positions
IF c1 and c3 THEN
BUY AT MARKET
ENDIF// Stops and targets
SET STOP pLOSS 403/02/2023 at 7:30 PM #21079305/01/2023 at 4:29 PM #213938Sorry for the long delay!
Firstly, to enter/exit a trade you must use:
- BUY to enter a Long trade
- SELL to exit a Long trade
- SELLSHORT to enter a Short trade
- EXITSHORT to exit a Short trade.
Secondly, I can’t understant the use of EXP1, as it is the same as CLOSE (the closing price).
Thirdly, 4 pips is a very tiny SL and it may be less than the minimum requirements by your broker. You’d better check with them what that valus is for the instruments/assets you want to trade.
Fourthly, I can’t understand “it’s would be great if it could set a partial 50% take profit when the price cross over (not at close) the upper band and the rest when it closes under the band“, as it enters Long when the price crosses over the upper band, how can it take some profits when it CROSSES OVER it?
Anyway, this is the code I have modified:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedBullCond = 0BearCond = 0IF high = highest[20](high) THENBullishCandle = highBullishBody = abs(close - open)BullishRatio = volume / BullishBodyBullCond = BullishRatio > BullishRatio[1]ENDIFIF low = lowest[20](low) THENBearishCandle = highBearishBody = abs(close - open)BearishRatio = volume / BearishBodyBearCond = BearishRatio > BearishRatio[1]ENDIFEXP1 = ExponentialAverage[1](close)up = PRTBANDSUPdn = PRTBANDSDOWNif close crosses over up and trend<=0 thentrend=1elsif close crosses under dn and trend>=0 thentrend=-1ENDIFc1 = (EXP1 CROSSES OVER up )EXP50 = ExponentialAverage[50](close)EXP100 = ExponentialAverage[100](close)c2 = close >= exp100c3 = trend<>trend[1]// Conditions to enter long positionsIF NOT SHORTONMARKET AND c1 and c2 and c3 and BullCond thenBUY 10 SHARES AT MARKETENDIF// Conditions to exit long positionsc4 = (EXP1 CROSSES UNDER dn )IF c3 and c4 THENSELL AT MARKETENDIF// Conditions to enter short positionsc4 = (EXP1 CROSSES UNDER dn )c5 = close <= exp100IF NOT LONGONMARKET AND c4 and c5 and BearCond thenSELLSHORT 10 SHARES AT MARKETENDIF// Conditions to exit short positionsIF c1 and c3 THENEXITSHORT AT MARKETENDIF// Stops and targetsSET STOP pLOSS 4//graph Trend coloured("Black")graph BullCond coloured("Green")graph BearCond coloured("Red") -
AuthorPosts
Find exclusive trading pro-tools on