Trend Magic Indicator For ThinkOrSwim

tenacity11

Active member
2019 Donor
Can anyone convert this to TOS for me. I included 2 screen shots. thanks so much.

Code:
//Tradestation Version

Var:

Up(0),

Dn(0);

//do not change the inputs for CCI and ATR

UP = (LOW - AvgTrueRange(5));//plots below the bars

if CCI(50) >= 0 then begin

Plot1( UP, "TrendMagic" ,Blue) ;

Condition1 = True;

end else begin

DN = (HIGH + AvgTrueRange(5));//plots above the bars

If CCI(50) < 0 then begin

Plot1( DN, "TrendMagic" ,Red) ;

Condition2 = True;

end;end;

//Alert Conditions

Condition1 = FALSE ;

Condition2 = False;

if Condition1 then

Alert( "TrendMagicUp" ) ;

if Condition2 then

Alert( "TrendMagicDn" ) ;

secret of earning huge profit magic-trend-indicator


Juzk8v9.jpg


This was another code I found. fyi.

Code:
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_width1 2
#property indicator_color2 Red
#property indicator_width2 2
//+------------------------------------------------------------------+
extern int CCI = 50;
extern int ATR = 5;
//+------------------------------------------------------------------+
double bufferUp[];
double bufferDn[];
//+------------------------------------------------------------------+
int init()
{
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(0, bufferUp);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(1, bufferDn);
   return (0);
}
//+------------------------------------------------------------------+
int deinit()
{
   return (0);
}
//+------------------------------------------------------------------+
int start()
{
   double thisCCI;
   double lastCCI;
   int counted_bars = IndicatorCounted();
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;
   int limit = Bars - counted_bars;
   for (int shift = limit; shift >= 0; shift--)
   {
      thisCCI = iCCI(NULL, 0, CCI, PRICE_TYPICAL, shift);
      lastCCI = iCCI(NULL, 0, CCI, PRICE_TYPICAL, shift + 1);
      if (thisCCI >= 0 && lastCCI < 0) bufferUp[shift + 1] = bufferDn[shift + 1];
      if (thisCCI <= 0 && lastCCI > 0) bufferDn[shift + 1] = bufferUp[shift + 1];
      if (thisCCI >= 0)
      {
         bufferUp[shift] = Low[shift] - iATR(NULL, 0, ATR, shift);
         if (bufferUp[shift] < bufferUp[shift + 1])
            bufferUp[shift] = bufferUp[shift + 1];
      }
      else
      {
         if (thisCCI <= 0)
         {
            bufferDn[shift] = High[shift] + iATR(NULL, 0, ATR, shift);
            if (bufferDn[shift] > bufferDn[shift + 1])
               bufferDn[shift] = bufferDn[shift + 1];
         }
      }
   }
   return (0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
 

Attachments

  • Juzk8v9.jpg
    Juzk8v9.jpg
    38 KB · Views: 172
Indicator was shared with the chart. So it was there.

Here is the code:

Code:
input agg = AggregationPeriod.FIFTEEN_MIN;
def c = close(period = agg);
def h = high(period = agg);
def l = low(period = agg);
def pricedata = hl2(period = agg);

DefineGlobalColor("TrendUp", CreateColor(0, 254, 30));
DefineGlobalColor("TrendDown", CreateColor(255, 3, 2));


input lengthCCI = 50;
input lengthATR = 5;
input AtrFactor = 0.7;

def ATRcci = Average(TrueRange(h, c, l), lengthATR) * AtrFactor;
def price = c + l + h;
def linDev = LinDev(price, lengthCCI);
def CCI = if linDev == 0
          then 0
          else (price - Average(price, lengthCCI)) / linDev / 0.015;
def MT1 = if CCI > 0
          then Max(MT1[1], pricedata - ATRcci)
          else Min(MT1[1], pricedata + ATRcci);
plot data = MT1;
data.AssignValueColor(if c < MT1 then Color.RED else Color.GREEN);
 
Once again thanks so much. Looks good and I made one for the daily chart. I greatly appreciate the time you've taken to help me.
 
Welcome Tenacity and San. Hope it helps with your trading. If you develop a great strategy will appreciate your sharing it back.
 
@tenacity11 and BenTen team, Just i want to share my thought... I am very comfort using all these indicator in Offline i mean After the market time end , but during the market hours 9.30EST- 4PM EST, I am really scared, even if i stick with the strategy/ Instruction/Rule I experience lot of fail trade.. I don't know how to come out these situation.. BUT still i am trying to finding which strategy may fit for me during market hours.

I would like to say one thing.. This forum its give me a hope that i will definitely find a good strategy in one day.... !!!! Because in this forum i see lot of open heart people and helping tendency people... ...
 
@San You're definitely not alone. It's good that you're going through these indicators and backtesting them. But that does not mean you can't paper trade them during trading hours. I would suggest using the ThinkorSwim paper trade account and practice so you get confident with the strategy that you picked (you can even paper trade by jogging down the share price or contract price as if you're actually buying them). If it doesn't turn out like you expected, then you know to move on then and not lose a single dime.

And also be patient when paper trading. Nothing will yield you 100% winning rate. Just because the first trade didn't work out doesn't the mean indicator or strategy isn't working. Give it some time. The good thing about paper trading is that you're flexible with what you test (have fun with all the strategies and indicators that you think may fit your needs). I hope that helps.
 
Code:
#Trend Magic Indicator

#Revised with Auto Aggregation and Global Colors

#Originally posted by horserider



def agg = getAggregationPeriod();

def c = close(period = agg);

def h = high(period = agg);

def l = low(period = agg);

def pricedata = hl2(period = agg);

DefineGlobalColor("TrendUp", CreateColor(0, 254, 30));

DefineGlobalColor("TrendDown", CreateColor(255, 3, 2));

input lengthCCI = 50;

input lengthATR = 5;

input AtrFactor = 0.7;

def ATRcci = Average(TrueRange(h, c, l), lengthATR) * AtrFactor;

def price = c + l + h;

def linDev = LinDev(price, lengthCCI);

def CCI = if linDev == 0

then 0

else (price - Average(price, lengthCCI)) / linDev / 0.015;

def MT1 = if CCI > 0

then Max(MT1[1], pricedata - ATRcci)

else Min(MT1[1], pricedata + ATRcci);

plot data = MT1;

data.AssignValueColor(if c < MT1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
 
@Lukhy11 Thanks. Makes it simple for those that do not wish to worry about changing aggregation if they change chart time.
The advantage of being able to change aggregation is you can see the study at 10 min aggregation on a 5 minute chart. Or whatever combination that will still allow it to chart. I am now testing using a 5 minute chart with two of the studies, one at 5 minute agg and one at 15 min agg. Take a look and see if it shows you anything.
 
Hi All @tenacity11 just wondering is the magic trend indicator working and can you share the code like the indicator in the picture you posted. I would appreciate it Thanks!
 
Here's the code. I'm still following but so far it looks good.

Code:
#Trend Magic Indicator
#Revised with Auto Aggregation and Global Colors
#Originally posted by horserider

def agg = getAggregationPeriod();
def c = close(period = agg);
def h = high(period = agg);
def l = low(period = agg);
def pricedata = hl2(period = agg);
DefineGlobalColor("TrendUp", CreateColor(0, 254, 30));
DefineGlobalColor("TrendDown", CreateColor(255, 3, 2));
input lengthCCI = 50;
input lengthATR = 5;
input AtrFactor = 0.7;
def ATRcci = Average(TrueRange(h, c, l), lengthATR) * AtrFactor;
def price = c + l + h;
def linDev = LinDev(price, lengthCCI);
def CCI = if linDev == 0
then 0
else (price - Average(price, lengthCCI)) / linDev / 0.015;
def MT1 = if CCI > 0
then Max(MT1[1], pricedata - ATRcci)
else Min(MT1[1], pricedata + ATRcci);
plot data = MT1;
data.AssignValueColor(if c < MT1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
 
Shouldn't this script be able to function on Tick charts as well with the "getAggregationPeriod" function? I can't get this bad boy to plot on the desktop platform. It plots perfectly on the Mobile App tick charts.
 
Last edited:
I have been trying this is on daily chart. The lines are too close to the price where it creates many false signals. Is default settings work or any change in ATR or CCI or ATR Factor more reliable ?
 
I have been trying this is on daily chart. The lines are too close to the price where it creates many false signals. Is default settings work or any change in ATR or CCI or ATR Factor more reliable ?

Just use one instance of the Trend Magic on the DAILY chart...Use these settings 20 4 0.7
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
411 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top