X number of consecutive candles above MA (Tradingview Strategy)

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #95505 quote
    djohnson87
    Participant
    New

    Hi all

    Are you able to please assist with converting the attached TradingView script strategy to ProBuilder please?

    System essentially does the following:

    Long entries:

    • Looks back at x number of consecutive candles’ closing price and if it forms x number of higher closes above the simple moving average enter long
    • Uses take profit and stop loss

    Short entries

    • Looks back at x number of consecutive candles’ closing price and it it forms x number of lower lows below the simple moving average enter short
    • uses take profit and stop loss

    Attached system has a lookback of 10 candles but that way too much. Maximum lookback of 5 candles is required.

     

    Thanks heaps, please advise any further questions. Cheers

    Cons-candles-v6.txt
    #95675 quote
    Nicolas
    Keymaster
    Master

    Wow the code is huge and not well formatted, I think that we can reduce it a lot.
    You are talking about “lower lows” while short conditions are testing lower close, is that ok?

    #95676 quote
    djohnson87
    Participant
    New

    Yeah cheers any efficiencies you can add would be appreciated.

    Yeah correct, should read lower closes. Thank you

    #95790 quote
    Nicolas
    Keymaster
    Master

    Below is the code compatible with ProBacktest / ProOrder: (consecutive candles are set to 5 and moving average period to 50, but you can change these settings at the beginning of the code).

    defparam cumulateorders=false
    
    MAperiod = 50
    bblong = 3 //"# Bars Back for Long"
    bbshort= 3 //"# Bars Back for Short"
    slPoints    = 50 //"Stop Loss in Pips (zero to disable)"
    tpPoints    = 50 //"Target Profit in Pips (zero to disable)"
    
    ma = average[MAperiod]
    buyc = summation[bblong](close>close[1] and close>ma)=bblong 
    sellc = summation[bbshort](close<close[1] and close<ma)=bbshort
    
    if not longonmarket and buyc then
    buy 1 contract at market 
    endif
    
    if not shortonmarket and sellc then 
    sellshort 1 contract at market 
    endif 
    
    set target pprofit tpPoints
    set stop ploss slPoints
    #95836 quote
    djohnson87
    Participant
    New

    Thank you

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

X number of consecutive candles above MA (Tradingview Strategy)


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
djohnson87 @djohnson87 Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by djohnson87
6 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/05/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...