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
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?
Yeah cheers any efficiencies you can add would be appreciated.
Yeah correct, should read lower closes. Thank you
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