Unanswered Question Graveyard

MerryDay

Administrative
Staff member
Staff
VIP
No solutions have been found for these questions so far. They will reside here in hopes that someone will be able to provide some direction.
 
Last edited:

Trader_Rich

Member
@BenTen @younglove06 I am currently using the Renko strategy shared below to scalp Indicies and Futures. Is it possible to set an alert if the following conditions are met when using Renko Bars:

Longs:
Renko bars >= Ichimoku Cloud and EMA
Lagging Span has exited Ichimoku Cloud and EMA
WAE is >= Dead Zone
Awesome Oscillator >= Dead Zone
LBR 3/10 >= Dead Zone

Conversely for shorts
Renko bars <= Ichimoku Cloud and EMA
Lagging Span has exited Ichimoku Cloud and EMA
WAE is M<= Dead Zone
Awesome Oscillator <= Dead Zone
LBR 3/10 <= Dead Zone

My chart is shared below for reference

https://tos.mx/pyG6xP6

I am also using this study SPX Trading Strategy for ThinkorSwim shared by @Hypoluxa but have somewhat adapted it for Indicies and Futures. I am trying to determine if you can set an alert if the following conditions are met

Longs:
Renko bars >=89 EMA
MACD_BB >= Zero Line and Green
Ergodic Oscillator >= Dead Zone

Shorts:
Renko bars <=89 EMA
MACD_BB<= Zero Line and Red
Ergodic Oscillator <= Dead Zone

https://tos.mx/MVyI2t2
 

joshua74133

Member
VIP
ok so lets try this again. the code is below. all im wanting is that thumbs up if the price is greater then the prev resistance line. ive been trying to steal parts of the script from auto piv to try and figure out the code. the Auto piv has a box that says the price is above trend... i want the same type of thing for the script below. is this even possible? ive spent hours trying to figure it out.

NXBewnB.png



Code:
input magnitude = 2;
input showValues = yes;
def top = high >= Highest(high[1], magnitude) and high >= Highest(high[-magnitude], magnitude);
def topvalue = if BarNumber() < magnitude then Double.NaN else if top    then high else topvalue[1];
plot topline = topvalue;
def countp = if IsNaN(top) and !IsNaN(top[1]) then 1 else countp[1] + 1;
plot peaktop = if IsNaN(top) then GetValue(topline, countp) else Double.NaN;
def bottom = low <= Lowest(low[1], magnitude) and low <= Lowest(low[-magnitude], magnitude);
def bottomValue = if BarNumber() < magnitude then Double.NaN else if bottom then low else bottomValue[1];
plot bottomline = bottomValue;


topline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
topline.SetDefaultColor(Color.RED);
peaktop.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
peaktop.SetDefaultColor(Color.RED);
bottomline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
bottomline.SetDefaultColor(Color.GREEN);

input show_bubble_labels = yes;

AddLabel(yes, if close>high then "👍" else "NA", if close>high is true then color.green else color.black);
 
Last edited:

bustrama

New member
Hello everyone,

I've noticed most of the posts here are regarding the familiar exchanges
I was wondering if someone here uses thinkScript for the OTC? where the prices are between 0.0001 to 0.01

Thank you
 

BLL

New member
Hi Guys,

Would it be possible to have this indicator but for stocks?

So it would just be three basic boxes in the volume bar section. One box showing the total volume for the previous candle, one box showing the current volume on the current candle, and then one box showing the predicted total volume for the current candle at the end of the 60 seconds. This would help me so much. It could be as basic as possible.

Thank you,
 

magnatron

New member
VIP
Hey Gurus, need help creating a scanner which scans for the following:
1. Price has higher close for the last 3 (configurable) consecutive days
2. On 4th day, the first 30min bar (time configurable) is a solid RED bar (%change is configurable)
3. Icing on the cake, the 30min bar forms on a high volume.

Basically idea is to scan for a big drop in price after a bull run but I want to take the position after the first 30min rather than end of the day. Please share if anything else achieves the same effect.
 

Yourmomhello

New member
So I’m trying to create a very specific order. I called TOS and they told me this isn’t possible.
Here’s the order for credit spreads specifically:
I mainly do 40+ DTE trades.

I want to specially create an automated way of exiting.

1st order: take full trade down at 50% profit at any point until 21 DTE.

2nd order: once 21 DTE is hit, create a 1st triggers all. 1st order: Take half of all orders at 50%. Triggers all: set a stop limit at purchase price. Or let the orders expire worth less for total profit of 75%
****

Example:

Purchase BAC quantity 40 contracts expiring 11/19/21. (59 DTE) put credit spread sold at .23

1st order

GTC order 40 contracts until 10/29/21 at 50% profit for 0.115

2nd order

1st triggers all:

1st trigger: 20 contracts at 0.115 starting from 10/29/21 to expiration (11/19/21).
Rest of order (trigger all): 20 contracts stop limit at .23.

(The rest of orders expire worthless for 75% profit)

I don’t know anything about coding but I’m willing to learn. If someone can provide advice on how to even tackle this I would appreciate it. Thank you team
 

Yourmomhello

New member
The order would be structured as a combination of a sequence and a 1st triggers all trade. 1st order would be a sequence order leading to order 2 if it goes past 21DTE. This automatically turns into a 1st triggers all where the first order is 50% profit taking half the trade down. Consequently triggering the stop limit for the rest of the orders. I called TOS and they said this was not possible. So I figured thinkscript is a way to do this
 

AlexeyMironenko

New member
VIP
ok so lets try this again. the code is below. all im wanting is that thumbs up if the price is greater then the prev resistance line. ive been trying to steal parts of the script from auto piv to try and figure out the code. the Auto piv has a box that says the price is above trend... i want the same type of thing for the script below. is this even possible? ive spent hours trying to figure it out.

NXBewnB.png



Code:
input magnitude = 2;
input showValues = yes;
def top = high >= Highest(high[1], magnitude) and high >= Highest(high[-magnitude], magnitude);
def topvalue = if BarNumber() < magnitude then Double.NaN else if top    then high else topvalue[1];
plot topline = topvalue;
def countp = if IsNaN(top) and !IsNaN(top[1]) then 1 else countp[1] + 1;
plot peaktop = if IsNaN(top) then GetValue(topline, countp) else Double.NaN;
def bottom = low <= Lowest(low[1], magnitude) and low <= Lowest(low[-magnitude], magnitude);
def bottomValue = if BarNumber() < magnitude then Double.NaN else if bottom then low else bottomValue[1];
plot bottomline = bottomValue;


topline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
topline.SetDefaultColor(Color.RED);
peaktop.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
peaktop.SetDefaultColor(Color.RED);
bottomline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
bottomline.SetDefaultColor(Color.GREEN);

input show_bubble_labels = yes;

AddLabel(yes, if close>high then "👍" else "NA", if close>high is true then color.green else color.black);
Hi Joshua, have you solved the problem?
 

8Nick8

Active member
2019 Donor
VIP
Compare ROC of stock vs SPX for momentum ranking
I can across the Relative Price Indicator from stockcharts.com, link below.
https://school.stockcharts.com/doku.php?id=technical_indicators:price_relative

Definition
"The Price Relative indicator compares the performance of one security to another with a ratio chart. This indicator is also known as the Relative Strength indicator or Relative Strength Comparative. Often, the Price Relative indicator is used to compare the performance of a stock against a benchmark index, such as the S&P 500. Chartists can also use the Price Relative to compare the performance of a stock to its sector or industry group. This makes it possible to determine if a stock is leading or lagging its peers. The Price Relative indicator can also be used to find stocks that are holding up better during a broad market decline or showing weakness during a broad market advance."

And I wanted to use the concept and construct a watchlist column to calculate the rate of change of the stock over x period and compare it with SPX as described above. Aim is to find which stock has the strongest momentum when it is compared with SPX. Thereafter, I can sort them by ranking them from the strongest to the weakest, to find which stock has outperformed the market and its peers over the selected period. The 3 time frame are as follows

I have found this similar script but I am unsure if the formula for BaseStrength is getting the right value of SPX we needed, should I include another lookback period of 252 for calculating the base strength of SPX over 1yr??

declare lower;
def length1 = 5;
def length2 = 21;
def length3 = 63;

input price = FundamentalType.CLOSE;
input RelativeToSecurity = "SPX";
input Lookback = 5;

def price1 = CLOSE(period = AggregationPeriod.day);
def price2 = Fundamental(price, RelativeToSecurity, AggregationPeriod.Day);

def UnderlyingStrength = (price1 - price1[Lookback]) / price1[Lookback];#
def BaseStrength = (price2 - price2[Lookback]) / price2[Lookback];
plot PriceRelativeIndicator5 = Round((1 + UnderlyingStrength) / (1 + BaseStrength), 3);

While i did not get any error msg, i like to request some help to verify if this script is correct to find the results I desired ?

Thanks
 
Last edited by a moderator:

SirSeff

New member
Hi everybody :)

I am looking for a solution on how to scale up, buy more, average up, when my "buy2" order triggers.
For example, when "Buy2" triggers, I want to buy more when the condition is still good in the next couple of days. (See blue rectangles)
The strategy is Ribbon EMAs with ATRs. (see code below)
I tried fast emas and slow emas combination but it doesn't respect the "Buy2" trigger first before buying more
avKgr06.png


PLEASE ADVICE :unsure::unsure:

Code:
#MARKET DIRECTION
input averageLength = 21;
input marketIndex = "NDX";
def Cond1 = expAverage(close(marketIndex), averageLength);

#SUPPORT
input price = close;
input startingMA = 21;
input endingMA = 90;

def inc = (endingMA - startingMA) / 7;
plot RS1 = ExpAverage(price, startingMA + 0 * inc);
plot RS2 = ExpAverage(price, startingMA + 1 * inc);
plot RS3 = ExpAverage(price, startingMA + 2 * inc);
plot RS4 = ExpAverage(price, startingMA + 3 * inc);
plot RS5 = ExpAverage(price, startingMA + 4 * inc);
plot RS6 = ExpAverage(price, startingMA + 5 * inc);
plot RS7 = ExpAverage(price, startingMA + 6 * inc);
plot RS8 = ExpAverage(price, startingMA + 7 * inc);
def rs9 = SimpleMovingAvg(close, 200);

RS1.SetDefaultColor(CreateColor(255, 65, 0));
RS2.SetDefaultColor(CreateColor(255, 90, 0));
RS3.SetDefaultColor(CreateColor(255, 115, 0));
RS4.SetDefaultColor(CreateColor(255, 140, 0));
RS5.SetDefaultColor(CreateColor(255, 165, 0));
RS6.SetDefaultColor(CreateColor(255, 190, 0));
RS7.SetDefaultColor(CreateColor(255, 215, 0));
RS8.SetDefaultColor(CreateColor(255, 240, 0));

def Cond2 = low > rs1 and RS1 > RS2 and RS2 > RS3 and RS3 > RS4 and RS4 > RS5 and RS5 > RS6 and RS6 > RS7 and RS7 > RS8 and low > rs9;

#EXIT
input AtrMult = 7;
input ATRlength = 10;
input lookbackLength = 21;
input highestHigh = high;
input lowestLow = low;
input AvgType = averageType.EXPONENTIAL;
input PaintBars = no;

def ATR = MovingAverage(AvgType, TrueRange(high, close, low), ATRlength);
def longstop = Highest(highestHigh, lookbackLength) - AtrMult * ATR;
def shortstop = Lowest(lowestLow, lookbackLength) + AtrMult * ATR;

def shortvs = if IsNaN(shortvs[1]) then shortstop else if close > shortvs[1] then shortstop else Min(shortstop, shortvs[1]);
def longvs = if IsNaN(longvs[1]) then longstop else if close < longvs[1] then longstop else Max(longstop, longvs[1]);

def longswitch = if close >= shortvs[1] and close[1] < shortvs[1] then 1 else 0;
def shortswitch = if close <= longvs[1] and close[1] > longvs[1] then 1 else 0;

def direction = if IsNaN(direction[1]) then 0 else if direction[1] <= 0 and longswitch then 1 else if direction[1] >= 0 and shortswitch then -1 else direction[1];

def pc = if direction > 0 then longvs else shortvs;

plot VolatilityStop = pc;
VolatilityStop.AssignValueColor(if direction < 0 then Color.RED else Color.GREEN);
AssignPriceColor(if PaintBars and direction < 0
                 then Color.RED
                 else if PaintBars and direction > 0
                      then Color.GREEN
                      else Color.CURRENT);
def cond3 =  direction>0;

#ENTRY
def Entry = cond1 and cond2 and cond3;

plot signal = if entry then 1 else 0;
signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
AddOrder(OrderType.BUY_TO_OPEN, signal, open [-1], tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "Buy2");
 

windowshopr

New member
Anyone tried this yet? The IntradayFlagFormationStrat makes use of the IntradayFlagFormation indicator. Looking for some guidance on how to convert these two scripts to work for the short side as well, but there's a fair amount of logic in here that I find hard to follow, but if I saw the final version, I could compare and note the differences. I'm hoping it would be fairly easy for someone in here to do as I'd like to see if the flag formations also hold weight for the short side as well?

Here is the indicator:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2014-2021
#


script VariableMinOffset {
    input price = close;
    input length = 0;


    plot VMin;
    if !IsNaN(price) and !IsNaN(length) {
        VMin = fold i = 0 to length with o do if GetValue(price, i) < GetValue(price, o) then i else o;
    } else {
        VMin = Double.NaN;
    }
}


script VariableLRS {
    input price = close;
    input length = 0;


    plot VLRS;
    if !IsNaN(price) and length != 1 {
        VLRS = 6 * ( ( fold i1 = 0 to length with s1 do s1 + (length - i1) * GetValue(price, i1) ) / ( (1 + length) / 2 * length ) - ( fold i2 = 0 to length with s2 do s2 + GetValue(price, i2) ) / length ) / (length - 1);
    } else if length == 1 {
        VLRS = 0;
    } else {
        VLRS = Double.NaN;
    }
}


input maxFlagLength = 15;
input maxFlagHeight = 2.5;
input maxPoleLength = 23;
input minPoleHeight = 5.5;
input upTrendLength = 70;
input minAtrPercentChange = 5.0;


Assert(maxPoleLength > 0, "'maxPoleLength' must be positive: " + maxPoleLength);


def x1 = GetMaxValueOffset(close, maxFlagLength)[2] + 2;
def x2 = x1 + 1;
def lfOffset = VariableMinOffset(close, x2);
def lf = GetValue(close, lfOffset);
def top = Max(GetValue(close, x1), GetValue(close, x1 + 1));
def atr = Average(TrueRange(high,  close,  low),  40);
def LRSX = VariableLRS(close[1], x1);
def LRSX1 = VariableLRS(close, x1);
def LRSX2;
if x1 == 2 {
    LRSX2 = LRSX2[1];
} else if x1 > 2 {
    LRSX2 = VariableLRS(close[2], x1 - 1);
} else {
    LRSX2 = Double.NaN;
}


def condition1 = top - lf < maxFlagHeight * atr and x2 > 2 and x2 <= maxFlagLength;
def condition2 =  if IsNaN(LRSX) or IsNaN(LRSX1) or IsNaN(LRSX2) then no else LRSX < 0 and (LRSX1 < 0 or LRSX2 < 0);
def y23 = VariableMinOffset(close, maxPoleLength + x2);
def bottom = GetValue(close, y23);
def pole = top - bottom;
def condition3 = pole > minPoleHeight * atr and y23 > x2;
def condition4 = bottom - Lowest(low, upTrendLength) > 0;
def condition5 = (atr / GetValue(atr, y23) - 1) * 100 > minAtrPercentChange;


plot Flag = condition1 and condition2 and condition3 and condition4 and condition5;
Flag.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Flag.SetLineWeight(3);


And here is the Strategy:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2014-2021
#


input maxFlagLength = 15;
input maxFlagHeight = 2.5;
input maxPoleLength = 23;
input minPoleHeight = 5.5;
input upTrendLength = 70;
input minLengthBetweenFlags = 50;
input minAtrPercentChange = 5.0;
input strictBreakout = yes;
input profitTargetConstant = 1.2;
input stopLossDelayLength = 5;
input stopAtr = 3.0;
input trailStopLength = 5;
input trailStopAtr = 3.0;
input inactivityExitLength = 70;
input inactivityAtr = 4.0;
input timeExitLength = 100;


Assert(maxFlagLength > 0, "'maxFlagLength' must be positive: " + maxFlagLength);
Assert(maxPoleLength > 0, "'maxPoleLength' must be positive: " + maxPoleLength);
Assert(stopLossDelayLength > 0, "'stopLossDelayLength' must be positive: " + stopLossDelayLength);
Assert(inactivityExitLength > 0, "'inactivityExitLength' must be positive: " + inactivityExitLength);
Assert(timeExitLength > 0, "'timeExitLength' must be positive: " + timeExitLength);


def atr = Average(TrueRange(high,  close,  low),  40);


def isFlag = reference IntradayFlagFormation(maxFlagLength = maxFlagLength, maxFlagHeight = maxFlagHeight, maxPoleLength = maxPoleLength, minPoleHeight = minPoleHeight, upTrendLength = upTrendLength, minAtrPercentChange = minAtrPercentChange).Flag;
def pole = reference IntradayFlagFormation(maxFlagLength = maxFlagLength, maxFlagHeight = maxFlagHeight, maxPoleLength = maxPoleLength, minPoleHeight = minPoleHeight, upTrendLength = upTrendLength, minAtrPercentChange = minAtrPercentChange).pole;
def lf = reference IntradayFlagFormation(maxFlagLength = maxFlagLength, maxFlagHeight = maxFlagHeight, maxPoleLength = maxPoleLength, minPoleHeight = minPoleHeight, upTrendLength = upTrendLength, minAtrPercentChange = minAtrPercentChange).lf;


def flagSum = Sum(isFlag, minLengthBetweenFlags) == 1;


def poleSave;
def lfSave;
if isFlag and flagSum {
    poleSave = pole;
    lfSave = lf;
} else {
    poleSave = poleSave[1];
    lfSave = lfSave[1];
}


AddOrder(OrderType.BUY_TO_OPEN, isFlag and flagSum, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "FlagLE");


def entryPrice = EntryPrice();
def afterEntryCount = if IsNaN(entryPrice[1]) and !IsNaN(entryPrice) then 1 else if !IsNaN(entryPrice) then afterEntryCount[1] + 1 else Double.NaN;


AddOrder(OrderType.SELL_TO_CLOSE, close >= entryPrice + profitTargetConstant * poleSave, tickcolor = GetColor(2), arrowcolor = GetColor(2), name = "FlagProfitTargetLX");
AddOrder(OrderType.SELL_TO_CLOSE, afterEntryCount > stopLossDelayLength and close < lfSave - stopAtr * atr, tickcolor = GetColor(3), arrowcolor = GetColor(3), name = "FlagStopLX");
AddOrder(OrderType.SELL_TO_CLOSE, close < Highest(close, trailStopLength) - trailStopAtr * atr, tickcolor = GetColor(4), arrowcolor = GetColor(4), name = "FlagTrailStopLX");
AddOrder(OrderType.SELL_TO_CLOSE, afterEntryCount > inactivityExitLength and close < entryPrice + inactivityAtr * atr, tickcolor = GetColor(5), arrowcolor = GetColor(5), name = "FlagInactivityLX");
AddOrder(OrderType.SELL_TO_CLOSE, afterEntryCount > timeExitLength, tickcolor = GetColor(6), arrowcolor = GetColor(6), name = "FlagTimeLX");
 

TCB

Member
Hi, I was wondering if there was a way to get the market maker candles to display on TOS during the premarket. It seems that TOS takes them out but they are displayed on TC2000. Any help or suggestions would be appreciated.
 

Dousei987

New member
VIP
RSI-Aroon Index Trading Strategy
Been working on this study but it still has a few kinks I'm hoping to clear out.

If you have trouble reading the code, I'll try to explain it as best I can.

The indicators to focus on are RSI and Aroon the study uses US index's. The main point is to focus on when condition is met it will generate a peak or value=1. For RSI its when an overbought or oversold appears, and for Aroon its when a cross occurs but it also reaches a value of 100. When the Aroon reaches the condition, labeled AroonCross, it will generate a peak or Value=1. ScanUp is when an RSI overbought and Aroon Up reaches 100 are met at the same time, the inverse is for ScanDown which involves an oversold and Aroon Down=100.

As for the scanPeriod, I have a tendency to observe markets 1 hour before and after open. The script generates a value=1 when the designated time is active. My preferred period is 5 min, but I've noticed the 1st 5 min after open tend to be very volatile so I try to avoid and skip, hence endOfscan has so many secondstilltime, it's so that if you were to observe on a 1 or 5 min chart that time frame won't generate a peak or value=1 during this period.

So the areas that i need a little refinement or focus on would be:
I'm trying to incorporate another time frame but whenever i add another secondsfromtime or secondstilltime to the def startOfscan or endOfscan the plot won't generate anything. Is there something I'm doing wrong or is there another way to write the script? Basically I want to add a 3rd peak to the scan period for at least a night frame after market closes. Also if there is a way to condense the endOfscan script then please let me know otherwise I think it's a little long. I tried creating two time plots but that led to overlapping and also made things slightly harder to read.

Secondly, for the alerts is there a way to write so that they will only generate during the time periods I want? I've tried messing around but while I can get them to alert when an AroonCross or scanup/scandown is generated they still generate at anytime as long as conditions are met. I tried "Alert(arooncross and scanPeriod== 1, "Main Cross", Alert.BAR, Sound.Chimes);" but it doesn't seem to react to every signal that is generated. So for now I just want to make sure that when the Aroon condition is met within the designated time frame I'll be alerted and that no other time can generate an alert cause it would just be too distracting and pointless.

In the image you'll see two plum color peaks representing the scanperiod plot(1st hour before and after open), the 1st 3 white lines each mark an arooncross(grey), scanup(red), and scandown (cyan) plot so at least you'll know what they look like. The 4th white line is roughly where I hope to add another plum color peak to the scanperiod just like the 2 in the image.

Hopefully this will give you an idea what roughly what things will look like or make it easier to follow the script for your reference.

Here's the script i've put together so far:
Ruby:
input aroonlength = 14;
Assert(aroonlength > 0, "'length' must be positive: " + aroonlength);

input rsilength = 8;
input price = close;
input averageType = AverageType.WILDERS;

def Up = (aroonlength - 1 - GetMaxValueOffset(high, aroonlength)) * 100.0 / (aroonlength - 1);
def Down = (aroonlength - 1 - GetMinValueOffset(low, aroonlength)) * 100.0 / (aroonlength - 1);

def rsi = RSI(rsilength, 70, 30, price, averageType).RSI;

def startOfScan = SecondsFromTime(0830) > 0 and secondsfromTime(0935);
def endOfScan = SecondsTillTime(1600) > 0 and secondstillTime(0930) and secondstillTime(0931) and secondstillTime(0932) and secondstillTime(0933) and secondstillTime(0934);

plot scanPeriod = startOfScan and endOfScan; scanPeriod.setDefaultColor(color.plum);
plot arooncross = Up[1] < Down[1] and Up equals 100 or down[1] < up [1] and down equals 100; arooncross.setDefaultColor(getcolor(3));

# scan for up line crossing above down line
plot scanup = Up equals 100 and rsi is greater than 70;
scanup.SetDefaultColor(GetColor(1));
# scan for down line crossing above up line
plot scanDown = Down equals 100 and rsi is less than 30;
scandown.SetDefaultColor(GetColor(2));

Alert(arooncross, "Main Cross", Alert.BAR, Sound.Chimes);
 
Last edited by a moderator:

Matz371

New member
So, I discovered there's a function for the HistoricalEPS (https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Stock-Fundamentals), I've been playing around but have found no examples and so far have been unable to get any code to work because I don't know how the constant fiscalperiod.QUARTER is to be defined (e.g. =1? =Q1?).

Google search showed that basically no one uses these functions, but if I can figure out how to define the fiscalperiod I think we could swap that in instead of the corporate actions getearnings pull.
Hi, I am new to here and TOS.
I tried and found that it maybe work as below.

Code:
def EPS1 = GetValue(GetActualEarnings(), GetEventOffset(Events.EARNINGS, -1));
def EPS2 = GetValue(GetActualEarnings(), GetEventOffset(Events.EARNINGS, -2));

"-1" and "-2" at the last refer to "Number of Events to Skip".
 

Matz371

New member
Hello, I am using this one for EPS and growth.

Unfortunately I'm not good in English and don't have enough knowledge and experience in writing thinkScripts, therefore it's not a good one.

Would you please help to amend the Script, or please advise some others like this? Thank you very much.:):)🥰



In the Script I use "X" as the number of event "hasEarnings" in the period.
I'd like to Sub "X" into the Script "GetEventOffset(Events.EARNINGS, X-1));" below.

Although it also count the number of times as "EPScount", it is not able to put it into the mentioned Script, since a warning "Only constants expected here: EPScount CL constant function parameter 'numberOfEventsToSkip' " is triggered.

Therefore it have to input the number of times by myself.



Another question is, it can only obtain the informations shown on the Chart period.
Meanwhile, it can't work in the Column, but only the nearest year of time.


I am also confused by the problem of "Split", which happened in AAPL, TSLA or ISRG and so on.
The way I can only think about is to "Red" the label as a remark.


Beside, would you please advise how to add the "Plus sign" (+) in front of the growth percentage?


The last thing is, sometimes it can't obtain all Earnings in the Chart.
I have no idea about that, for example which happened in TSM.
I found the same situation when using another EPS Script.


Thank you very much for all of you!!🥰🥰😊



$LMT Lockheed Martin Corp Com (620 Days / 1D)
DgSps27.jpg


Code:
input EarningsTimes = 10;
def X = EarningsTimes;

def EPSYes = IF hasEarnings() then GetActualEarnings() else Double.NaN;
def EPScount = if !IsNan(EPSYes) THEN IF IsNan(EPScount[1]) THEN 1 ELSE EPScount[1] + 1 ElSE EPScount[1];

def Split1 = IF GetSplitDenominator() or GetSplitNumerator() then GetSplitDenominator() else Double.NaN;
def Splitcount1 = if !IsNan(Split1) THEN IF IsNan(Splitcount1[1]) THEN 1 ELSE Splitcount1[1] + 1 ElSE Splitcount1[1];

AddLabel(Yes, "EPS Reports: " + EPScount + " ("+X+") ", if Splitcount1>0 then color.red else color.light_GRAY);


def EPS1 = GetValue(GetActualEarnings(), GetEventOffset(Events.EARNINGS, X-1));
def EPS2 = GetValue(GetActualEarnings(), GetEventOffset(Events.EARNINGS, X-2));
def EPS3 = GetValue(GetActualEarnings(), GetEventOffset(Events.EARNINGS, X-3));
def EPS4 = GetValue(GetActualEarnings(), GetEventOffset(Events.EARNINGS, X-4));
def EPS5 = GetValue(GetActualEarnings(), GetEventOffset(Events.EARNINGS, X-5));
def EPS6 = GetValue(GetActualEarnings(), GetEventOffset(Events.EARNINGS, X-6));
def EPS7 = GetValue(GetActualEarnings(), GetEventOffset(Events.EARNINGS, X-7));
def EPS8 = GetValue(GetActualEarnings(), GetEventOffset(Events.EARNINGS, X-8));
def EPS9 = GetValue(GetActualEarnings(), GetEventOffset(Events.EARNINGS, X-9));
def EPS10 = GetValue(GetActualEarnings(), GetEventOffset(Events.EARNINGS, X-10));


def EPS5a = if EPS5<0 then EPS5*-1 else EPS5;
def EPS6a = if EPS6<0 then EPS6*-1 else EPS6;
def EPS7a = if EPS7<0 then EPS7*-1 else EPS7;
def EPS8a = if EPS8<0 then EPS8*-1 else EPS8;
def EPS9a = if EPS9<0 then EPS9*-1 else EPS9;
def EPS10a = if EPS10<0 then EPS10*-1 else EPS10;


def C1 = (EPS1 - EPS5) / EPS5a * 100;
def C2 = (EPS2 - EPS6) / EPS6a * 100;
def C3 = (EPS3 - EPS7) / EPS7a * 100;
def C4 = (EPS4 - EPS8) / EPS8a * 100;
def C5 = (EPS5 - EPS9) / EPS9a * 100;
def C6 = (EPS6 - EPS10) / EPS10a * 100;


def isBar = BarNumber() == 1;

AddChartBubble(isBar, 100,

"[CQ] " + EPS1 + "  ("  + Round(C1,2) + "%)\n" +
"[Q3] " +EPS2 + "  (" + Round(C2,2) + "%)\n" +
"[Q2] " +EPS3 + "  (" + Round(C3,2) + "%)\n" +
"[Q1] " +EPS4 + "  (" + Round(C4,2) + "%)\n" +
"[L 4] " +EPS5 + "  (" + Round(C5,2) + "%)\n" +
"[L 3] " +EPS6 + "  (" + Round(C6,2) + "%)\n"

,  Color.WHITE, no);
 
Last edited:

Similar threads

Top