Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with Trend Trader Strategy #274

Open
botzill opened this issue Jun 29, 2022 · 1 comment
Open

Help with Trend Trader Strategy #274

botzill opened this issue Jun 29, 2022 · 1 comment
Labels
Enhancement New feature or request pinescript Indicators to be converted from pinescript

Comments

@botzill
Copy link

botzill commented Jun 29, 2022

Hi.

I was wondering if anyone has any experience with this indicator?

https://www.tradingview.com/script/j1etwXMQ-Trend-Trader-Strategy/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 21/01/2021
// This is plots the indicator developed by Andrew Abraham 
// in the Trading the Trend article of TASC September 1998  
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
study(title="Trend Trader Strategy", overlay = true)
Length = input(21, minval=1),
Multiplier = input(3, minval=0.000001)
avgTR      = wma(atr(1), Length)
highestC   = highest(Length)
lowestC    = lowest(Length)
hiLimit = highestC[1]-(avgTR[1] * Multiplier)
loLimit = lowestC[1]+(avgTR[1] * Multiplier)
ret = 0.0
pos = 0.0
ret:= iff(close > hiLimit and close > loLimit, hiLimit,
       iff(close < loLimit and close < hiLimit, loLimit, nz(ret[1], close)))
pos:= iff(close > ret, 1,
	   iff(close < ret, -1, nz(pos[1], 0))) 
barcolor(pos == -1 ? color.red: pos == 1 ? color.green : color.blue )
plot(ret, color= color.blue , title="Trend Trader Strategy")

I'm not sure how I can write this myself, if you have any suggestions please let me know.

Thanks.

@xmatthias xmatthias added the Enhancement New feature or request label Jul 3, 2022
@xmatthias
Copy link
Member

the code itself doesn't look too complicated - however it'll most likely be slow to calculate (at least for backtesting) - as you'll have to implement this as (partial) loop.

ret is assigned with ret[1] - which is the equivalent to row[i] = row[i-1] - so the calculation of the current row relies on the resut of the prior row - which means it cannot be vectorized.

It's then simply a question of finding the definition of each method - and implementing it in python.

@xmatthias xmatthias added the pinescript Indicators to be converted from pinescript label Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request pinescript Indicators to be converted from pinescript
Projects
None yet
Development

No branches or pull requests

2 participants