NexusFi: Find Your Edge


Home Menu

 





ThinkScript help with SchaffTrendCycle


Discussion in Traders Hideout

Updated
    1. trending_up 1,309 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?
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Request for MACD with option to use different MAs for fa …
NinjaTrader
Looking for an MQL4 MetaTrader programmer/coder
The Elite Circle
ZombieSqueeze
Platforms and Indicators
Ninja Trader 8 Drawing Tools Wanted
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
52 thanks
NexusFi site changelog and issues/problem reporting
46 thanks
Battlestations: Show us your trading desks!
34 thanks
GFIs1 1 DAX trade per day journal
32 thanks
What percentage per day is possible? [Poll]
20 thanks

  #2 (permalink)
 
justtrader's Avatar
 justtrader 
San Francisco, CA
 
Experience: Intermediate
Platform: Ninja Trader, TOS
Trading: es, rty, cl, gc, nq, ym
Posts: 182 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