NexusFi: Find Your Edge


Home Menu

 





ThinkScript help with SchaffTrendCycle


Discussion in Traders Hideout

Updated
    1. trending_up 1,324 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

ThinkScript help with SchaffTrendCycle

  #1 (permalink)
zentrader618
ny, ny/us
 
Posts: 3 since Aug 2019
Thanks Given: 1
Thanks Received: 0

Hello Forum,
I need help in doing the following:
- Plot a buy/sell arrow below/above the candle that triggers the following condition:
#1- cross above/below the oversold/overbought line on the SchaffTrendCycle

-Add a buy/sell alert when #1 is met

Code:
input fastLength = 23;
input slowLength = 50;
input KPeriod = 10;
input DPeriod = 3;
input over_bought = 80;
input over_sold = 20;
input neutral_zone = 50;
input averageType = AverageType.EXPONENTIAL;

def macd = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def fastK1 = FastKCustom(macd, KPeriod);
def fastD1 = MovingAverage(averageType, fastK1, DPeriod);
def fastK2 = FastKCustom(fastD1, KPeriod);
plot STC = MovingAverage(averageType, fastK2, DPeriod);
plot OverBought = over_bought;
plot OverSold = over_sold;
plot Neutral = neutral_zone;
STC.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(7));
OverSold.SetDefaultColor(GetColor(7));
Neutral.SetDefaultColor(GetColor(7));

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Cheap historycal L1 data for stocks
Stocks and ETFs
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
What is Markets Chat (markets.chat) real-time trading ro …
77 thanks
Spoo-nalysis ES e-mini futures S&P 500
55 thanks
Just another trading journal: PA, Wyckoff & Trends
38 thanks
Bigger Wins or Fewer Losses?
24 thanks
The Program
17 thanks
  #2 (permalink)
 
justtrader's Avatar
 justtrader 
San Francisco, CA
 
Experience: Intermediate
Platform: Ninja Trader, TOS
Trading: es, rty, cl, gc, nq, ym
Posts: 184 since May 2011
Thanks Given: 104
Thanks Received: 173


zentrader618 View Post
Hello Forum,
I need help in doing the following:
- Plot a buy/sell arrow below/above the candle that triggers the following condition:
#1- cross above/below the oversold/overbought line on the SchaffTrendCycle

-Add a buy/sell alert when #1 is met



Try this code:
NOTE: you will not be able to see the original "cycle" plot; just the arrows and the alerts.



input fastLength = 23;
input slowLength = 50;
input KPeriod = 10;
input DPeriod = 3;
input over_bought = 80;
input over_sold = 20;
input neutral_zone = 50;
input averageType = AverageType.EXPONENTIAL;

input alerttextOB = "OverBought Exit!";
input alerttextOS = "OverSold Exit!";
input UseAlerts = {false, default true};
input AlertType = {default "BAR", "ONCE", "TICK"};
input AlertSound = {"Bell", "Chimes", default "Ding", "NoSound", "Ring"};


def macd = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def fastK1 = FastKCustom(macd, KPeriod);
def fastD1 = MovingAverage(averageType, fastK1, DPeriod);
def fastK2 = FastKCustom(fastD1, KPeriod);
plot STC = MovingAverage(averageType, fastK2, DPeriod);
plot OverBought = over_bought;
plot OverSold = over_sold;
plot Neutral = neutral_zone;
STC.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(7));
OverSold.SetDefaultColor(GetColor(7));
Neutral.SetDefaultColor(GetColor(7));

plot entryS = if STC crosses below over_bought then High else Double.NaN;
plot entryL = if STC crosses above over_sold then Low else Double.NaN;

entryL.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
entryS.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);


Alert(entryL and UseAlerts, alerttextOS, if AlertType == AlertType.ONCE then Alert.ONCE else if AlertType == AlertType.TICK then Alert.TICK else Alert.BAR, AlertSound);
Alert(entryS and UseAlerts, alerttextOB, if AlertType == AlertType.ONCE then Alert.ONCE else if AlertType == AlertType.TICK then Alert.TICK else Alert.BAR, AlertSound);

Reply With Quote




Last Updated on October 19, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts