Evaluation of a new Strategy

Thanks for the add! I am new to most of this, except for coding and mathematics. I recently got interested in trading and wrote a Strategy. I would like help evaluating this strategy as I streamline and perfect it. Pretty much looking for information that will tell me if what I have written is decent, average, or cutting edge. I'm sure it's not the latter... lol
  1. What is an average or above average profitable/successful trade ratio based on the better strategies shared on this site?
  2. What are some of the highest percent gains obtained with a backtesting strategy in TOS to date? (Interested in averages over multiple stocks over longer periods of time) Obviously if shorted NFLX last week could have an impressive two day gain....
  3. The native strategies that are installed on TOS, are they considered average?
 
Last edited:

TrueDepth

Member
VIP
Slope of a tangent line
I have been trying to find an indicator that gives me the Angle in degrees of a moving average or price for a long time. Like when you use the drawing line tool, it will show the angle. I think whether a stock is moving up at 20° vs at 75° is useful information. I don't know if this is relevant to this thread or not.
 

YungTraderFromMontana

Well-known member
I have been trying to find an indicator that gives me the Angle in degrees of a moving average or price for a long time. Like when you use the drawing line tool, it will show the angle. I think whether a stock is moving up at 20° vs at 75° is useful information. I don't know if this is relevant to this thread or not.
I passed by it looking through this but I can't remember where, you can either dig through it or ask around more.
https://onedrive.live.com/redir?res...09.25.|30461c4b-420e-4b83-b56f-55faf5d1461b/)
 

markos

Well-known member
VIP
Interesting, thanks for telling me.
Just for kicks, put "ATan & Thinkscript" into the search above, if nothing, then try this:
Code:
def Regression = Inertia(close, length);

#Determine the angle of the lower end of the line and plot it in an oscillator

plot Data = ATan((Regression - Regression[length]) / length) * 180 / Double.Pi;
 

TrueDepth

Member
VIP
See what I put in the post above. It will give you something to work with.
Otherwise, look here: http://tlc.thinkorswim.com/center/howToTos/tutorials.html

Atan doesn't help at all. It probably just isn't possible on ThinkorSwim as an indicator, even though it should be something simple. I can just use the Draw tool and get the angle. manually. Also posting ThinkOrSwim's tutorial doesn't help whatsoever.
 

horserider

Well-known member
VIP
See if any of this helps find your slope.

Code:
AssignBackgroundColor(CreateColor(8, 0, 15));
input length = 9;
input price = HL2;
input PriceColorOn = Yes;
input ArrowsOn = Yes;
input PredictionLineOn = Yes;
input FirstRegressionChannelOn = Yes;
input SecondRegressionChannelOn = Yes;
input ThirdRegressionChannelOn = Yes;
input BubblesOn = No;
input ShowTodayOnly = no;
input ShowExtraDays = 0;
input slopebars = 1;

def Today = if !ShowTodayOnly then 1 else if GetDay() + ShowExtraDays >= GetLastDay() then 1 else 0;

def AvgPrice = Average(price, length);
def SumTime = fold i = 1 to length + 1 with x = 0 do x + i;
def AvgTime = SumTime / length;
    #sx is the sum of all the deviations from time for the last x bars
def sx = fold j = 1 to length + 1 with y = 0 do y + ((j - AvgTime) * (GetValue(price, length - j, length + 1) - AvgPrice));
        #sy is the sum of all the deviations from price for the last x bars
def sy = fold k = 1 to length + 1 with z = 0 do z + (Power(k - AvgTime, 2));
        #m is the slope of the line, b is the slope intercept of the line in the equation y = mx + b
def m = sx / sy;
def b = AvgPrice - m * AvgTime;
def Prediction = (m * (length + 1)) + b;
plot FuturePrediction = if !PredictionLineOn then Double.NaN else Prediction;

def height = (FuturePrediction - FuturePrediction[slopebars])*10000;
def hypotenuse = sqrt( sqr(slopebars) + sqr(height) );
rec slope = Tan(height/hypotenuse) * 180 / Double.Pi;

addlabel(yes, "Angle=" + slope, color.cyan);
#plot StrongestSlope = 50;
#plot StrongestSlope1 = -50;
#plot zeroline = 0;
 
Last edited by a moderator:
@FL_Mech_Engineer I see a linearregressionslope study in ToS maybe you just missed it.
You are right I did miss this, but I was referring to the strategies included with TOS. What I have been trading, successfully I might add so far, is slope of a tangent line to that linearregressionslope indicator which basically just buys at the bottom and sells at the top. However, by using slope <= 0.025 it actually gives the signal just before the bottom that way by the time you get the signal it executes truly AT the bottom, or top.
Happy trading.
 

adii800

Member
Here is a DMA slope in degrees. Also @horserider aren't you supposed to use ATan instead of Tan, because using tangent would find the Opps/Adj value for the angle "height/hypotenuse" in radians.
Code:
declare lower;
input price = close;
input length = 28;
input displace = -14;

def dPrice = price[displace];
def isNaNdPrice = IsNaN(dPrice);
def varLength = sum(!isNaNdPrice, length);
def varSum = sum(if isNaNdPrice then 0 else dPrice, length);

def DMA = if IsNaN(price) or varLength == 0 then Double.NaN else varSum / varLength;
def avg = DMA;
def height = avg - avg[1];

plot “Angle, deg” = (ATan(height))*(180/Double.Pi);
“Angle, deg”.AssignValueColor (if “Angle, deg” >= 0 then Color.ORANGE else Color.BLUE);

plot ZeroLine = 0;
ZeroLine.AssignValueColor(if “Angle, deg” < 0 then Color.RED else Color.GREEN);
ZeroLine.SetLineWeight(1);

I color-coded the slope so if its < 0 its blue and >0 its orange. Also, the zero line changes color.

Hey @FL_Mech_Engineer, can you provide more details on the rules in your strategy, also we need to find a way to reduce the drawdown for some of its trades, one of the shorts on NQ you posted had an insane drawdown.
 

halcyonguy

Active member
VIP
look at post #50
https://usethinkscript.com/threads/evaluation-of-a-new-strategy.694/page-3

to find an angle of a line, between 2 consecutive bars.
if the line endpoints are several bars apart, then you will need to include the count of bars, in the formula.

1. calc the price difference between 2 bars, which is height in the example.
2. use atan() to calc an angle

# def height = avg - avg[1];
# plot “Angle, deg” = (ATan(height))*(180/Double.Pi);
 

nately

New member
I color-coded the slope so if its < 0 its blue and >0 its orange. Also, the zero line changes color.

Hey @FL_Mech_Engineer, can you provide more details on the rules in your strategy, also we need to find a way to reduce the drawdown for some of its trades, one of the shorts on NQ you posted had an insane drawdown.

@adii800,

Does this strategy repaint? If not, it's one of the best indicators I've seen.
 

nately

New member
I tested adii800's strategy and have gotten amazing results. Too good to be true.

I suspect it's repainting and I suspect the OP's strategy might be a repainter as well.

For instance, here are the results for NQ:

nq.jpg
 

horserider

Well-known member
VIP
@adii800 Thanks for the information.
You are most likely correct as I am math deficient. Practically for ToS I do not think it matters to the plots. I think you can even use sin or asin and get the same plot.
 

nately

New member
did the code for the OP's strategy/indicator set ever get posted? I looked up the LP study and found this https://usethinkscript.com/threads/...ing-strategy-for-thinkorswim.3022/#post-28926 previously posted so im guessing it was just a repeat hence why this died off?

My guess is that he was using a repainting strategy, like the one @adii800 posted. I backtested that strategy and got similar "too good to be true" results. The OP was new to indicators and didn't understand the idea of repainting.
 

rj3137

New member
@nately which code are you using for the strategy? Is it this one by adii800?

declare lower;
input price = close;
input length = 28;
input displace = -14;

def dPrice = price[displace];
def isNaNdPrice = IsNaN(dPrice);
def varLength = sum(!isNaNdPrice, length);
def varSum = sum(if isNaNdPrice then 0 else dPrice, length);

def DMA = if IsNaN(price) or varLength == 0 then Double.NaN else varSum / varLength;
def avg = DMA;
def height = avg - avg[1];

plot “Angle, deg” = (ATan(height))*(180/Double.Pi);
“Angle, deg”.AssignValueColor (if “Angle, deg” >= 0 then Color.ORANGE else Color.BLUE);

plot ZeroLine = 0;
ZeroLine.AssignValueColor(if “Angle, deg” < 0 then Color.RED else Color.GREEN);
ZeroLine.SetLineWeight(1);
 

nately

New member
@nately which code are you using for the strategy? Is it this one by adii800?

declare lower;
input price = close;
input length = 28;
input displace = -14;

def dPrice = price[displace];
def isNaNdPrice = IsNaN(dPrice);
def varLength = sum(!isNaNdPrice, length);
def varSum = sum(if isNaNdPrice then 0 else dPrice, length);

def DMA = if IsNaN(price) or varLength == 0 then Double.NaN else varSum / varLength;
def avg = DMA;
def height = avg - avg[1];

plot “Angle, deg” = (ATan(height))*(180/Double.Pi);
“Angle, deg”.AssignValueColor (if “Angle, deg” >= 0 then Color.ORANGE else Color.BLUE);

plot ZeroLine = 0;
ZeroLine.AssignValueColor(if “Angle, deg” < 0 then Color.RED else Color.GREEN);
ZeroLine.SetLineWeight(1);

Yes, that's it. I've been observing it over the past few weeks. It does repaint but only subtetly. The repainting might become more dramatic during a big move.
 

Similar threads

Top