Convert Trend Magic Indicator to ThinkorSwim?

tenacity11

tenacity11

Active member
VIP
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



trendmagicH1.jpg.dc00dc3e21033ba5fdd65aee8c99aee0.jpg
 
N

Nick

Member
VIP
Hi there, this looks like super trend indicator. There is a thread on Super Trend, do check it out and compare. Hope this helps
 
tenacity11

tenacity11

Active member
VIP
Hi there, this looks like super trend indicator. There is a thread on Super Trend, do check it out and compare. Hope this helps
I've got the super trend indicator on and they don't seem to be the same based on what I'm seeing but thanks
 
S

San

Member
VIP
@BenTen , I belive Ben and Team can help to create Script... ;)
 
tenacity11

tenacity11

Active member
VIP
@horserider I got the email with the indicator but when I tried to view it in the thread it was gone. I just want to thank you for taking the time to do this and I will follow to see how it works.
 
S

San

Member
VIP
@horserider , Not clear... You already have the indicator or You need the indicator. If you have it already please post.
 
tenacity11

tenacity11

Active member
VIP
@horserider , Not clear... You already have the indicator or You need the indicator. If you have it already please post.
I have it in the email but it was originally posted in this thread but disappeared. I will repost it.
 
tenacity11

tenacity11

Active member
VIP
Hi Tenacity. See if this will work for you. Based on Supertrend. Code from a larger study simplified with the lines you are looking for pulled out. You can adjust the agg and values to get the type line you want.

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 Factor = 1.3;

input Pd = 60;

input Lookback = 3;



def atr_st = Average(TrueRange(h, c, l), Pd);

def Up = pricedata[Lookback] - (Factor * atr_st);

def Dn = pricedata[Lookback] + (Factor * atr_st);

def TrendUp = if c > TrendUp[1] then Max(Up, TrendUp[1]) else Up;

def TrendDown = if c < TrendDown[1] then Min(Dn, TrendDown[1]) else Dn;

def Trend = if c > TrendDown[1] then 1 else if c < TrendUp[1] then -1 else (Trend[1]);

def Trendbn = if c > TrendDown[1] then BarNumber() else if c < TrendUp[1] then BarNumber() else (Trendbn[1]);

def Trendc = if c > TrendDown[1] then c else if c < TrendUp[1] then c else (Trendc[1]);



plot Tsl = if Trend == 1 then TrendUp else TrendDown;

Tsl.AssignValueColor(if Trend == 1 then GlobalColor("TrendUp") else GlobalColor("TrendDown"));

Tsl.SetLineWeight(1);
 
H

horserider

Well-known member
VIP
Warehouse
Sorry posted the wrong one. That one is not based on CCI like you requested. I was playing with some indicators and code and copied the wrong thing.
 
tenacity11

tenacity11

Active member
VIP
Sorry posted the wrong one. That one is not based on CCI like you requested. I was playing with some indicators and code and copied the wrong thing.
OOPS...Can you send the one you meant to.
 
H

horserider

Well-known member
VIP
Warehouse
Ok try this one based on CCI and ATR. Do not understand TradingView code so just kind of speculating if it is doing exactly the same thing.
Watch out for aggregation period, it must be higher than chart period or it will not plot. You can change other settings to your liking. Initially set to CCI length of 50. http://tos.mx/WzND7F
I do seem to be able to post an image of a chart to show you what it looks like.
 
tenacity11

tenacity11

Active member
VIP
Ok try this one based on CCI and ATR. Do not understand TradingView code so just kind of speculating if it is doing exactly the same thing.
Watch out for aggregation period, it must be higher than chart period or it will not plot. You can change other settings to your liking. Initially set to CCI length of 50. http://tos.mx/WzND7F
I do seem to be able to post an image of a chart to show you what it looks like.
Chart came up but no code with it. Looks good
 
tenacity11

tenacity11

Active member
VIP
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);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
this was another code I found. fyi.
 
H

horserider

Well-known member
VIP
Warehouse
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);
 
tenacity11

tenacity11

Active member
VIP
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.
 
H

horserider

Well-known member
VIP
Warehouse
Welcome Tenacity and San. Hope it helps with your trading. If you develop a great strategy will appreciate your sharing it back.
 
S

San

Member
VIP
@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... ...
 

Top