Pine Script to PRT code conversion for Multi Time Frame strategy on EURUSD
Forums › ProRealTime English forum › ProBuilder support › Pine Script to PRT code conversion for Multi Time Frame strategy on EURUSD
- This topic has 3 replies, 3 voices, and was last updated 1 year ago by Aragorna.
-
-
05/24/2023 at 9:21 PM #215141
Hi,
I am new to the forum but have dabbled with PRT for a number of years.
Please could you provide a code conversion for the strategy below for trading EUR/USD
It is a multi time frame strategy using the 1 hour and 1 minute candlestick charts
The code is written in Pine Script
Thanks and happy trading.
Tony
//@version=5
strategy(“EUR/USD Trading Strategy”, overlay=true)// Define indicators and time frames
supertrendLength = 10
supertrendMultiplier = 3
confirmIndicatorLength = 14// Calculate Supertrend on 1-hour chart
[stLine, stTrend] = ta.supertrend(security(syminfo.tickerid, “60”, close), supertrendLength, supertrendMultiplier)// Calculate Confirmation Indicator (RSI) on 1-minute chart
confirmIndicator = ta.rsi(close, confirmIndicatorLength)// Define entry conditions
enterLong = crossover(confirmIndicator, 50) and stTrend == 1
enterShort = crossunder(confirmIndicator, 50) and stTrend == -1// Define exit conditions
exitLong = crossunder(confirmIndicator, 50) and stTrend == -1
exitShort = crossover(confirmIndicator, 50) and stTrend == 1// Execute trades
if (enterLong)
strategy.entry(“Long”, strategy.long)
if (enterShort)
strategy.entry(“Short”, strategy.short)if (exitLong)
strategy.close(“Long”)
if (exitShort)
strategy.close(“Short”)// Set stop loss and take profit
stopLoss = 0.0025 // Set your desired stop loss value
takeProfit = 0.005 // Set your desired take profit valuestrategy.exit(“Exit Long”, “Long”, stop=low – stopLoss, limit=high + takeProfit)
strategy.exit(“Exit Short”, “Short”, stop=high + stopLoss, limit=low – takeProfit)05/27/2023 at 3:59 PM #215285Hereby a start of conversion, SL and TP have yet to be determined…
EUR/USD Trading Strategy123456789101112131415161718192021222324252627282930313233343536373839404142434445supertrendLength = 10supertrendMultiplier = 3confirmIndicatorLength = 14// Calculate Supertrend on 1-hour chartTimeFrame(1 hour)stTrend = Supertrend[supertrendLength, supertrendMultiplier]// Calculate Confirmation Indicator (RSI) on 1-minute chartTimeFrame(1 minute)confirmIndicator = RSI[confirmIndicatorLength](close)If Close Crosses Over stTrend thenstTrend=1EndIfIf Close Crosses Under stTrend thenstTrend=-1EndIf// Define entry conditionsenterLong = confirmIndicator Crosses Over 50 and stTrend = 1enterShort = confirmIndicator Crosses Under 50 and stTrend = -1// Define exit conditionsexitLong = confirmIndicator Crosses Under 50 and stTrend = -1xexitShort = confirmIndicator Crosses Over 50 and stTrend = 1// Execute tradesif enterLong thenBuy 1 contract at marketEndIfif enterShort thenSellShort 1 contract at marketEndIfif exitLong thenSell at marketEndIfif xexitShort thenExitShort at marketEndIf// Set stop loss and take profit//stopLoss = 0.0025 // Set your desired stop loss value//takeProfit = 0.005 // Set your desired take profit value05/27/2023 at 6:03 PM #215289Correct version:
12345678910111213141516171819202122232425262728293031323334353637383940414243// Calculate Supertrend on 1-hour chartTimeFrame(1 hour, UPDATEONCLOSE )supertrendLength = 10supertrendMultiplier = 3confirmIndicatorLength = 14stTrend = Supertrend[supertrendLength, supertrendMultiplier]If Close Crosses Over stTrend thenstTrend=1EndIfIf Close Crosses Under stTrend thenstTrend=-1EndIfTimeFrame(1 minute,default)// Calculate Confirmation Indicator (RSI) on 1-minute chartconfirmIndicator = RSI[confirmIndicatorLength](close)// Define entry conditionsenterLong = confirmIndicator Crosses Over 50 and stTrend = 1enterShort = confirmIndicator Crosses Under 50 and stTrend = -1// Define exit conditionsexitLong = confirmIndicator Crosses Under 50 and stTrend = -1xexitShort = confirmIndicator Crosses Over 50 and stTrend = 1// Execute tradesif enterLong thenBuy 1 contract at marketEndIfif enterShort thenSellShort 1 contract at marketEndIfif exitLong thenSell at marketEndIfif xexitShort thenExitShort at marketEndIf// Set stop loss and take profit//stopLoss = 0.0025 // Set your desired stop loss value//takeProfit = 0.005 // Set your desired take profit value05/27/2023 at 7:17 PM #215291sorry this one is correct, I guess:
12345678910111213141516171819202122232425262728293031323334353637383940414243// Calculate Supertrend on 1-hour chartTimeFrame(1 hour, UPDATEONCLOSE )supertrendLength = 10supertrendMultiplier = 3stTrend = Supertrend[supertrendLength, supertrendMultiplier]c1= Close Crosses Over stTrendc2= Close Crosses Under stTrendTimeFrame(1 minute,default)confirmIndicatorLength = 14// Calculate Confirmation Indicator (RSI) on 1-minute chartconfirmIndicator = RSI[confirmIndicatorLength](close)// Define entry conditionsenterLong = confirmIndicator Crosses Over 50 and c1enterShort = confirmIndicator Crosses Under 50 and c2// Define exit conditionsexitLong = confirmIndicator Crosses Under 50 and c2xexitShort = confirmIndicator Crosses Over 50 and c1// Execute tradesif enterLong thenBuy 1 contract at marketEndIfif enterShort thenSellShort 1 contract at marketEndIfif exitLong thenSell at marketEndIfif xexitShort thenExitShort at marketEndIf// Set stop loss and take profitSET STOP PLOSS 100SET TARGET PPROFIT 200 -
AuthorPosts
Find exclusive trading pro-tools on