Conversion of TradingView strategy to PRT Indicator and screener
Forums › ProRealTime English forum › ProBuilder support › Conversion of TradingView strategy to PRT Indicator and screener
- This topic has 8 replies, 3 voices, and was last updated 1 year ago by iamboston.
-
-
12/16/2022 at 1:33 AM #205852
Hey there PRT team,
I’m hoping for some assistance with converting the daily High/Low strategy in Tradingview, to an indicator (with buy/sell signals) + screener for Pro Real Time. I’ve made a few attempts and failed miserably, so any assistance would be amazing!
Daily High/Low Strategy123456789101112131415161718192021222324252627282930313233343536// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © exlux99//@version=5strategy(title='Daily HIGH/LOW strategy', overlay=true, initial_capital=10000, calc_on_every_tick=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1)////////////////////////////GENERAL INPUTS//////////////////////////////////////len = input.int(24, minval=1, title='Length MA', group='Optimization paramters')src = input.source(close, title='Source MA', group='Optimization paramters')out = ta.ema(src, len)length = input.int(20, minval=1, title='CMF Length', group='Optimization paramters')ad = close == high and close == low or high == low ? 0 : (2 * close - low - high) / (high - low) * volumemf = math.sum(ad, length) / math.sum(volume, length)f_secureSecurity(_symbol, _res, _src) =>request.security(_symbol, _res, _src[1], lookahead=barmerge.lookahead_on)pricehigh = f_secureSecurity(syminfo.tickerid, 'D', high)pricelow = f_secureSecurity(syminfo.tickerid, 'D', low)plot(pricehigh, title='Previous Daily High', style=plot.style_linebr, linewidth=2, color=color.new(color.white, 0))plot(pricelow, title='Previous Daily Low', style=plot.style_linebr, linewidth=2, color=color.new(color.white, 0))short = ta.crossunder(low, pricelow) and close < out and mf < 0long = ta.crossover(high, pricehigh) and close > out and mf > 0if short and barstate.isconfirmedstrategy.entry('short', strategy.short, when=barstate.isconfirmed, stop=pricelow[1])strategy.close('short', when=close > out)if long and barstate.isconfirmedstrategy.entry('long', strategy.long, when=barstate.isconfirmed, stop=pricehigh[1])strategy.close('long', when=close < out)12/16/2022 at 2:52 PM #205910Hi @iamboston
The basis of the system is:
High > DHigh(1)
Low < DLow(1) Furthermore, it is examined whether: Close > EMA[24](Close) for LONG
Close < EMA[24](Close) for SHORT An additional indicator is used to confirm: Chaikin Money Flow (CMF) CMF > 0 for LONG
CMF < 0 for SHORT The exit of the trades is done with: Close Crosses Under EMA[24](Close) (Sell) Close Crosses About EMA[24](Close) (ExitShort)
Daily High/Low Strategy123456789101112131415161718192021222324252627DefParam CumulateOrders=FalseEMAPeriod=24 //Period of EMAS1=ExponentialAverage[EMAPeriod](Close) //EMA signalCMFPeriod=20 //Period of Chaikin Money FlowMFM = ((Close-Low)-(High-Close)) / (High-Low) //Money Flow MultiplierMFV = MFM * Volume //Money Flow VolumeCMF = Summation[CMFPeriod](MFV) / Summation[CMFPeriod-1](Volume) //Chaikin Money Flow//LONGIf High Crosses Over DHigh(1) and Close > S1 and CMF > 0 thenBuy 1 contract at MarketEndIf//Exit LONGIf Close Crosses Under S1 thenSell at MarketEndIf//SHORTIf Low Crosses Under DLow(1) and Close < S1 and CMF < 0 thenSellShort 1 contract at MarketEndIf//Exit SHORTIf Close Crosses Over S1 thenExitShort at MarketEndIf2 users thanked author for this post.
12/17/2022 at 6:03 AM #20593812/18/2022 at 12:39 PM #205994I’m surprised. For a breakout system it works quite well. At least long, also on Nasdaq or SP500. But then with EMA45. Short would also work, but then with a different exit strategy. The long candles, which should cause the exit in short mode, are usually simply too long in the time unit. Short would need another exit.
12/18/2022 at 11:24 PM #20600612/18/2022 at 11:25 PM #20600912/19/2022 at 12:40 AM #206014Hi @iamboston
It is a simple indicator, for the CMF you can use the standard indicator from PRT…
Daily High/Low Indicator1234567EMAPeriod=24 //Period of EMAS1=ExponentialAverage[EMAPeriod](Close) //EMA signalDH=DHigh(1)//Previous Daily HighDL=DLow(1)//Previous Daily LowReturn DH as "Daily High" Coloured(255,0,0), DL as "Daily Low" Coloured(0,255,0), S1 as "EMA24" Coloured(255,255,0) Style(DottedLine)1 user thanked author for this post.
12/20/2022 at 11:20 PM #206110Hi @iamboston
To complete the trio 😉 hereby the screener…
Hope you have fun with it.
Regards Jaap
Daily High/Low Screener1234567891011121314151617181920EMAPeriod=24 //Period of EMAS1=ExponentialAverage[EMAPeriod](Close) //EMA signalCMFPeriod=20 //Period of Chaikin Money FlowMFM=((Close-Low)-(High-Close)) / (High-Low) //Money Flow MultiplierMFV=MFM * Volume //Money Flow VolumeCMF=Summation[CMFPeriod](MFV) / Summation[CMFPeriod](Volume)C1 = High Crosses Over DHigh(1) and Close > S1 and CMF > 0C2 = Low Crosses Under DLow(1) and Close < S1 and CMF < 0If C1 thenResult=1EndIfIf C2 thenResult=2EndIfScreener[Result](Result as "1=LONG 2=SHORT")1 user thanked author for this post.
12/21/2022 at 12:17 AM #206111 -
AuthorPosts
Find exclusive trading pro-tools on