5m UStech 100 strategy
Forums › ProRealTime English forum › ProBuilder support › 5m UStech 100 strategy
- This topic has 1 reply, 2 voices, and was last updated 1 year ago by ProRealAlgos.
Viewing 2 posts - 1 through 2 (of 2 total)
-
-
06/11/2023 at 8:37 PM #215978
This is a long only strategy for the 5m US tech 100 . Works well with c.2.5 profit factor.
I am not a coder so would appreciate if someone could put this in ProRealTime code for me .
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204//Disbale Signal RepaintingdisableRepainting = input.bool(defval = true, title = "Disable Signal Repainting", group = "Repainting Settings")////Session Settings InputsuseSession = input.bool(defval = true, title = "Use Session", group = "Session Settings")closeEverything = input.bool(defval = true, title = "Close all orders/positions if session ends", group = "Session Settings")customTimeZone = input.string(defval = "America/New_York", title = "Custom Time Zone", group = "Session Settings", inline = "a1")useCustomTimeZone = input.bool(defval = true, title = "On/Off", group = "Session Settings", inline = "a1")timeSession = input.session(defval = "0940-1605", title = "Session Time", group = "Session Settings", tooltip = "Use the checkboxes to select " +"on which days of the week this session is active. The session " +"has to be active on at least one day.")monSession = input.bool(true, title="Mon ", group = "Session Settings", inline="d1")tueSession = input.bool(true, title="Tue ", group = "Session Settings", inline="d1")wedSession = input.bool(true, title="Wed ", group = "Session Settings", inline="d1")thuSession = input.bool(true, title="Thu ", group = "Session Settings", inline="d1")friSession = input.bool(true, title="Fri   ", group = "Session Settings", inline="d2")satSession = input.bool(false, title="Sat  ", group = "Session Settings", inline="d2")sunSession = input.bool(false, title="Sun ", group = "Session Settings", inline="d2")// Custom Time Zone LogictimeZone = useCustomTimeZone ? customTimeZone : syminfo.timezone// Make a days of week string based on the value of the checkboxessessionDays = ""if sunSessionsessionDays += "1"if monSessionsessionDays += "2"if tueSessionsessionDays += "3"if wedSessionsessionDays += "4"if thuSessionsessionDays += "5"if friSessionsessionDays += "6"if satSessionsessionDays += "7"// Make the session string by joining the time with the daystradingSession = timeSession + ":" + sessionDays//Session Logict = time(timeframe.period, tradingSession, timeZone)inSession = not na(t) and useSessionoutSession = na(t) and useSessionbgcolor(inSession ? color.new(color.green, transp = 95) : na)////VWAP indicator//VWAP InputsvwapSource = input.source(defval = close, title = "VWAP Source", group = "VWAP Settings")//Calculate Indicatorvwap = ta.vwap(vwapSource)////EMA Indicator//EMA InputsemaLength = input.int(defval = 555, title = "EMA Lenght", group = "EMA Settings")emaSource = input.source(defval = close, title = "EMA Source", group = "EMA Settings")//Calculate Indicatorema = ta.ema(emaSource, emaLength)////BB Indicator//BB InputsbbSource = input.source(defval = close, title = "BBands Source", group = "Bollinger Bands Settings")bbLength1 = input.int(defval = 20, title = "BBands Lenght 1", minval = 1, group = "BBands 1")devUp1 = input.float(defval = 2, title = "BBands DevUp 1", minval = 1, step = 0.1, group = "BBands 1")devDn1 = input.float(defval = 2, title = "BBands DevDown 1", minval = 1, step = 0.1, group = "BBands 1")bbLength2 = input.int(defval = 10, title = "BBands Lenght 2", minval = 1, group = "BBands 2")devUp2 = input.float(defval = 1.2, title = "BBands DevUp 2", minval = 1, step = 0.1, group = "BBands 2")devDn2 = input.float(defval = 1.2, title = "BBands DevDown 2", minval = 1, step = 0.1, group = "BBands 2")/////////Additional MA// TEMAtema(src, length) =>v2 = ta.ema(src, length)v = 3 * (v2 - ta.ema(v2, length)) + ta.ema(ta.ema(v2, length), length) // Triple Exponentialv// KAMAkama(src, length) =>k = 0.0volatility = math.sum(math.abs(src-src[1]), length)change = math.abs(src-src[length-1])er = volatility != 0 ? change/volatility : 0sc = math.pow((er*(0.666666-0.064516))+0.064516, 2)k := nz(k[1])+(sc*(hl2-nz(k[1])))k// TRIMAtrima(src, length) =>trima = ta.sma(ta.sma(src, math.ceil(length / 2)), math.floor(length / 2) + 1)trima//DEMAdema(src, length) =>e1 = ta.ema(src, length)e2 = ta.ema(e1, length)dema = 2 * e1 - e2dema//MA SwitchermaType = input.string(defval = "SMA", title = "BBands MA Type", options = ["EMA", "SMA", "VWMA", "WMA", "TRIMA", "HMA", "KAMA", "TEMA", "DEMA"], group = "Bollinger Bands Settings")getMA(src, length) =>ma = float(na)if maType == "EMA"ma := ta.ema(src, length)if maType == "SMA"ma := ta.sma(src, length)if maType == "VWMA"ma := ta.vwma(src, length)if maType == "WMA"ma := ta.wma(src, length)if maType == "TRIMA"ma := trima(src, length)if maType == "HMA"ma := ta.hma(src, length)if maType == "KAMA"ma := kama(src, length)if maType == "T3"ma := tema(src, length)if maType == "DEMA"ma := dema(src, length)ma//Calculate BB IndicatormiddleLine1 = getMA(bbSource, bbLength1)upperBand1 = (middleLine1 + (devUp1 * (ta.stdev(bbSource, bbLength1))))lowerBand1 = (middleLine1 - (devDn1 * (ta.stdev(bbSource, bbLength1))))middleLine2 = getMA(bbSource, bbLength2)upperBand2 = (middleLine2 + (devUp2 * (ta.stdev(bbSource, bbLength2))))lowerBand2 = (middleLine2 - (devDn2 * (ta.stdev(bbSource, bbLength2))))upperBandDifference = upperBand1 - upperBand2maxDifference = 100ratio = 100 - (100 * (upperBandDifference / maxDifference))////Condition LogicVWAP_condition = vwapSource > vwapEMA_condition = emaSource > emaabove95 = ratio > 89closeAboveBothUpperBands = bbSource > upperBand1 and bbSource > upperBand2entryCondition = above95 and VWAP_condition and EMA_condition and closeAboveBothUpperBandsexitConditionRegular = (upperBand2 - bbSource) / bbSource > 0.006//Define position directionisLong = strategy.position_size > 0isShort = strategy.position_size < 0noPosition = strategy.position_size == 0//Strategy Entriesif entryCondition and (inSession or not useSession) and noPosition and (barstate.isconfirmed or not disableRepainting)strategy.entry("Long", strategy.long)if exitConditionRegular and (inSession or not useSession) and isLong and (barstate.isconfirmed or not disableRepainting)strategy.close("Long")if outSession and closeEverythingstrategy.cancel_all()strategy.close_all()07/12/2023 at 1:58 PM #217574This will not get you the whole way there, but I used ChatGPT with the prompt instructions from this ProRealCode thread here to convert it to ProRealTime code.
https://www.prorealcode.com/topic/create-strategies-codes-with-chatgpt-for-prorealtime/You will with 100% certainty have to make some additional adjustments to make it work. However, I hope it got you a couple of steps forward.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182//Disbale Signal RepaintingdisableRepainting = true////Session Settings InputsuseSession = truecloseEverything = truecustomTimeZone = "America/New_York"useCustomTimeZone = truetimeSession = "0940-1605"monSession = truetueSession = truewedSession = truethuSession = truefriSession = truesatSession = falsesunSession = false// Custom Time Zone LogictimeZone = useCustomTimeZone ? customTimeZone : syminfo.timezone// Make a days of week string based on the value of the checkboxessessionDays = ""if sunSession thensessionDays = sessionDays + "1"endifif monSession thensessionDays = sessionDays + "2"endifif tueSession thensessionDays = sessionDays + "3"endifif wedSession thensessionDays = sessionDays + "4"endifif thuSession thensessionDays = sessionDays + "5"endifif friSession thensessionDays = sessionDays + "6"endifif satSession thensessionDays = sessionDays + "7"endif// Make the session string by joining the time with the daystradingSession = timeSession + ":" + sessionDays//Session Logict = timeframes(1, tradingSession, timeZone)inSession = not na(t) and useSessionoutSession = na(t) and useSessionbgcolor(inSession, color.new(color.green, 95))////VWAP indicatorvwapSource = close//Calculate Indicatorvwap = VWAP[vwapSource]////EMA IndicatoremaLength = 555emaSource = close//Calculate Indicatorema = EMA[emaSource, emaLength]////BB IndicatorbbSource = closebbLength1 = 20devUp1 = 2devDn1 = 2bbLength2 = 10devUp2 = 1.2devDn2 = 1.2/////////Additional MA// TEMAtema(src, length) =v2 = EMA[src, length]v = 3 * (v2 - EMA[v2, length]) + EMA[EMA[v2, length], length] // Triple Exponentialv// KAMAkama(src, length) =k = 0.0volatility = sum(abs(src-src[1]), length)change = abs(src-src[length-1])er = volatility <> 0 ? change/volatility : 0sc = pow((er*(0.666666-0.064516))+0.064516, 2)k = nz(k[1])+(sc*(hl2-nz(k[1])))k// TRIMAtrima(src, length) =trima = SMA[SMA[src, ceil(length / 2)], floor(length / 2) + 1]trima//DEMAdema(src, length) =e1 = EMA[src, length]e2 = EMA[e1, length]dema = 2 * e1 - e2dema//MA SwitchermaType = "SMA"getMA(src, length) =ma = 0.0if maType = "EMA" thenma = EMA[src, length]if maType = "SMA" thenma = SMA[src, length]if maType = "VWMA" thenma = VWMA[src, length]if maType = "WMA" thenma = WMA[src, length]if maType = "TRIMA" thenma = trima(src, length)if maType = "HMA" thenma = HMA[src, length]if maType = "KAMA" thenma = kama(src, length)if maType = "T3" thenma = tema(src, length)if maType = "DEMA" thenma = dema(src, length)ma//Calculate BB IndicatormiddleLine1 = getMA(bbSource, bbLength1)upperBand1 = middleLine1 + (devUp1 * (STDEV[bbSource, bbLength1]))lowerBand1 = middleLine1 - (devDn1 * (STDEV[bbSource, bbLength1]))middleLine2 = getMA(bbSource, bbLength2)upperBand2 = middleLine2 + (devUp2 * (STDEV[bbSource, bbLength2]))lowerBand2 = middleLine2 - (devDn2 * (STDEV[bbSource, bbLength2]))upperBandDifference = upperBand1 - upperBand2maxDifference = 100ratio = 100 - (100 * (upperBandDifference / maxDifference))////Condition LogicVWAP_condition = vwapSource > vwapEMA_condition = emaSource > emaabove95 = ratio > 89closeAboveBothUpperBands = bbSource > upperBand1 and bbSource > upperBand2entryCondition = above95 and VWAP_condition and EMA_condition and closeAboveBothUpperBandsexitConditionRegular = (upperBand2 - bbSource) / bbSource > 0.006//Define position directionisLong = positionsize > 0isShort = positionsize < 0noPosition = positionsize = 0//Strategy Entriesif entryCondition and (inSession or not useSession) and noPosition and (barnumber[1] > 0 or not disableRepainting) thenbuy at marketendifif exitConditionRegular and (inSession or not useSession) and isLong and (barnumber[1] > 0 or not disableRepainting) thensell at marketendifif outSession and closeEverything thenset stop ploss 0sell at marketendif -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
Find exclusive trading pro-tools on
Similar topics: