Alpha Trend

barbaros

Administrator
Staff member
@barbaros - Any news or developments figuring out a scan for Alpha Trend indicator or the coding for the QQQ RelaxedTrader strategy? Just curious.
Untested, but here is the simplest for scanner. QQQ is still on the list.

Code:
# AlphaTrend Scanner
# Converted for https://b4indicators.com/threads/alpha-trend.174/
# v1.0 - barbaros

input coeff = 1.0;
input AP = 14;
input src = close;
input noVolumeData = no;
input paintBars = no;

def _ATR = ATR(AP);
def upT = low - _ATR * coeff;
def downT = high + _ATR * coeff;

def AlphaTrend = if BarNumber() == 1 then 0
                 else if (if novolumedata then RSI(price=src, length=14) >= 50 else MoneyFlowIndex(length=14) >= 50) then
                    if upT < AlphaTrend[1] then AlphaTrend[1] else upT
                 else
                    if downT > AlphaTrend[1] then AlphaTrend[1] else downT;


def k1 = AlphaTrend;
def k2 = AlphaTrend[2];

def direction = if BarNumber() == 1 then 0
                else if direction[1] != 1 and crosses(AlphaTrend, AlphaTrend[2], CrossingDirection.ABOVE) then 1
                else if direction[1] != -1 and crosses(AlphaTrend, AlphaTrend[2], CrossingDirection.BELOW) then -1
                else direction[1];

plot buySignal = direction == 1 and direction[1] != 1;
plot sellSignal = direction == -1 and direction[1] != -1;
 
@barbaros thanks for the update. I caught the part at the bottom of the script where I needed to "#" either the buy or the sell option. It looks like it compiled right, but when I run either the buy or the sell version on Daily aggregate it times out with the "Error:Script execution timeout" message. I don't think it is coded quite right, or I did something wrong which is the more likely. Let me know what you find on your end, and thanks for the efforts so far. Very generous of you.
 

barbaros

Administrator
Staff member
Interesting results with the scanner. When saved as a study, it doesn't work as expected, but if you paste code directly into the custom script section of the scanner, it works.

Bullish:
Code:
# AlphaTrend Scanner
# Converted for https://b4indicators.com/threads/alpha-trend.174/
# v1.0 - barbaros

input coeff = 1.0;
input AP = 14;
input src = close;
input noVolumeData = no;
input paintBars = no;

def _ATR = ATR(AP);
def upT = low - _ATR * coeff;
def downT = high + _ATR * coeff;

def AlphaTrend = if BarNumber() == 1 then 0
                 else if (if novolumedata then RSI(price=src, length=14) >= 50 else MoneyFlowIndex(length=14) >= 50) then
                    if upT < AlphaTrend[1] then AlphaTrend[1] else upT
                 else
                    if downT > AlphaTrend[1] then AlphaTrend[1] else downT;


def k1 = AlphaTrend;
def k2 = AlphaTrend[2];

def direction = if BarNumber() == 1 then 0
                else if direction[1] != 1 and crosses(AlphaTrend, AlphaTrend[2], CrossingDirection.ABOVE) then 1
                else if direction[1] != -1 and crosses(AlphaTrend, AlphaTrend[2], CrossingDirection.BELOW) then -1
                else direction[1];

plot buySignal = direction == 1 and direction[1] != 1;

Bearish:
Code:
# AlphaTrend Scanner
# Converted for https://b4indicators.com/threads/alpha-trend.174/
# v1.0 - barbaros

input coeff = 1.0;
input AP = 14;
input src = close;
input noVolumeData = no;
input paintBars = no;

def _ATR = ATR(AP);
def upT = low - _ATR * coeff;
def downT = high + _ATR * coeff;

def AlphaTrend = if BarNumber() == 1 then 0
                 else if (if novolumedata then RSI(price=src, length=14) >= 50 else MoneyFlowIndex(length=14) >= 50) then
                    if upT < AlphaTrend[1] then AlphaTrend[1] else upT
                 else
                    if downT > AlphaTrend[1] then AlphaTrend[1] else downT;


def k1 = AlphaTrend;
def k2 = AlphaTrend[2];

def direction = if BarNumber() == 1 then 0
                else if direction[1] != 1 and crosses(AlphaTrend, AlphaTrend[2], CrossingDirection.ABOVE) then 1
                else if direction[1] != -1 and crosses(AlphaTrend, AlphaTrend[2], CrossingDirection.BELOW) then -1
                else direction[1];

plot sellSignal = direction == -1 and direction[1] != -1;
 

TennVol79

New member
Hi, Barbaros, I set up those two ToS scans exactly like you said to do but they don't return anything, even after I remove my usual stock price and volume filters. Would you please publish shared links so I can give them a try?
 

barbaros

Administrator
Staff member
Hi, Barbaros, I set up those two ToS scans exactly like you said to do but they don't return anything, even after I remove my usual stock price and volume filters. Would you please publish shared links so I can give them a try?
What did you pick as the timeframe?
 
Top