Pine Script to PRT code conversion for Multi Time Frame strategy on EURUSD

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #215141 quote
    Tony BR
    Participant
    New

    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 value

    strategy.exit(“Exit Long”, “Long”, stop=low – stopLoss, limit=high + takeProfit)
    strategy.exit(“Exit Short”, “Short”, stop=high + stopLoss, limit=low – takeProfit)

    #215285 quote
    JS
    Participant
    Senior

    Hereby a start of conversion, SL and TP have yet to be determined…  

    supertrendLength = 10
    supertrendMultiplier = 3
    confirmIndicatorLength = 14
    
    // Calculate Supertrend on 1-hour chart
    TimeFrame(1 hour)
    stTrend = Supertrend[supertrendLength, supertrendMultiplier]
    
    // Calculate Confirmation Indicator (RSI) on 1-minute chart
    TimeFrame(1 minute)
    confirmIndicator = RSI[confirmIndicatorLength](close)
    
    If Close Crosses Over stTrend then
    stTrend=1
    EndIf
    If Close Crosses Under stTrend then
    stTrend=-1
    EndIf
    
    // Define entry conditions
    enterLong = confirmIndicator Crosses Over 50 and stTrend = 1
    enterShort = confirmIndicator Crosses Under 50 and stTrend = -1
    
    // Define exit conditions
    exitLong = confirmIndicator Crosses Under 50 and stTrend = -1
    xexitShort = confirmIndicator Crosses Over 50 and stTrend = 1
    
    // Execute trades
    if enterLong then
    Buy 1 contract at market
    EndIf
    if enterShort then
    SellShort 1 contract at market
    EndIf
    
    if exitLong then
    Sell at market
    EndIf
    if xexitShort then
    ExitShort at market
    EndIf
    
    // Set stop loss and take profit
    //stopLoss = 0.0025 // Set your desired stop loss value
    //takeProfit = 0.005 // Set your desired take profit value
    

    #215289 quote
    Aragorna
    Participant
    Junior
    Correct version:  
    // Calculate Supertrend on 1-hour chart
    TimeFrame(1 hour, UPDATEONCLOSE )
    supertrendLength = 10
    supertrendMultiplier = 3
    confirmIndicatorLength = 14
    stTrend = Supertrend[supertrendLength, supertrendMultiplier]
     
    
    If Close Crosses Over stTrend then
    stTrend=1
    EndIf
    If Close Crosses Under stTrend then
    stTrend=-1
    EndIf
     TimeFrame(1 minute,default)
    // Calculate Confirmation Indicator (RSI) on 1-minute chart
    confirmIndicator = RSI[confirmIndicatorLength](close)
    // Define entry conditions
    enterLong = confirmIndicator Crosses Over 50 and stTrend = 1
    enterShort = confirmIndicator Crosses Under 50 and stTrend = -1
     
    // Define exit conditions
    exitLong = confirmIndicator Crosses Under 50 and stTrend = -1
    xexitShort = confirmIndicator Crosses Over 50 and stTrend = 1
     
    // Execute trades
    if enterLong then
    Buy 1 contract at market
    EndIf
    if enterShort then
    SellShort 1 contract at market
    EndIf
     
    if exitLong then
    Sell at market
    EndIf
    if xexitShort then
    ExitShort at market
    EndIf
     
    // Set stop loss and take profit
    //stopLoss = 0.0025 // Set your desired stop loss value
    //takeProfit = 0.005 // Set your desired take profit value
    #215291 quote
    Aragorna
    Participant
    Junior
    sorry this one is correct,  I guess:
    // Calculate Supertrend on 1-hour chart
    TimeFrame(1 hour, UPDATEONCLOSE )
    supertrendLength = 10
    supertrendMultiplier = 3
    
    stTrend = Supertrend[supertrendLength, supertrendMultiplier]
     
    
    c1= Close Crosses Over stTrend
    c2= Close Crosses Under stTrend 
    
    
     TimeFrame(1 minute,default)
    confirmIndicatorLength = 14
    // Calculate Confirmation Indicator (RSI) on 1-minute chart
    confirmIndicator = RSI[confirmIndicatorLength](close)
    // Define entry conditions
    enterLong = confirmIndicator Crosses Over 50 and c1
    enterShort = confirmIndicator Crosses Under 50 and c2
     
    // Define exit conditions
    exitLong = confirmIndicator Crosses Under 50 and c2
    xexitShort = confirmIndicator Crosses Over 50 and c1
     
    // Execute trades
    if enterLong then
    Buy 1 contract at market
    EndIf
    if enterShort then
    SellShort 1 contract at market
    EndIf
     
    if exitLong then
    Sell at market
    EndIf
    if xexitShort then
    ExitShort at market
    EndIf
     
    
    // Set stop loss and take profit
    SET STOP PLOSS 100 
    SET TARGET PPROFIT 200
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Pine Script to PRT code conversion for Multi Time Frame strategy on EURUSD


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Tony BR @tony-br Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by Aragorna
2 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/24/2023
Status: Active
Attachments: No files
Logo Logo
Loading...