Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

MC

Think or Swim Code/indicators

Recommended Posts

I don't see a relative strength index (RSI) as an indicator in the TOS platform. Does anyone have code for this?

 

Thanks,

StockJock

 

Is there any way to make the RSIWILDER multi-time-frame? Any place or person you can direct me to that would be able to code it???

 

Thanks in advance

Share this post


Link to post
Share on other sites

hello informed trades, I have this indicator on my Metatrader 4 and i would like to transfer it to Think or Swim but i keep getting common errors.

Can some one please have a look and correct it or at least tell me what i am doing wrong.

Below is the language code.

 

 

 

#property indicator_separate_window

#property indicator_buffers 4

#property indicator_color1 Blue

#property indicator_width1 4

#property indicator_color2 Red

#property indicator_width2 4

#property indicator_color3 Blue

#property indicator_width3 2

#property indicator_color4 Red

#property indicator_width4 2

 

//---- input parameters

extern int Mode = 0; // 0-RSI method; 1-Stoch method

extern int Length = 9; // Period

extern int Smooth = 1; // Period of smoothing

extern int Signal = 4; // Period of Signal Line

extern int Price = 0; // Price mode : 0-Close,1-Open,2-High,3-Low,4-Median,5-Typical,6-Weighted

extern int ModeMA = 3; // Mode of Moving Average

extern int Mode_Histo = 3;

//---- buffers

double Bulls[];

double Bears[];

double AvgBulls[];

double AvgBears[];

double SmthBulls[];

double SmthBears[];

double SigBulls[];

double SigBears[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

IndicatorBuffers(8);

SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,4);

SetIndexBuffer(0,SmthBulls);

SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,4);

SetIndexBuffer(1,SmthBears);

 

SetIndexStyle(2,DRAW_LINE,EMPTY,2);

SetIndexBuffer(2,SigBulls);

SetIndexStyle(3,DRAW_LINE,EMPTY,2);

SetIndexBuffer(3,SigBears);

 

SetIndexBuffer(4,Bulls);

SetIndexBuffer(5,Bears);

SetIndexBuffer(6,AvgBulls);

SetIndexBuffer(7,AvgBears);

//---- name for DataWindow and indicator subwindow label

string short_name="AbsoluteStrengthHistogram("+Mode+","+L ength+","+Smooth+","+Signal+",,"+ModeMA+")";

IndicatorShortName(short_name);

SetIndexLabel(0,"Bulls");

SetIndexLabel(1,"Bears");

SetIndexLabel(2,"Bulls");

SetIndexLabel(3,"Bears");

 

//----

SetIndexDrawBegin(0,Length+Smooth+Signal);

SetIndexDrawBegin(1,Length+Smooth+Signal);

SetIndexDrawBegin(2,Length+Smooth+Signal);

SetIndexDrawBegin(3,Length+Smooth+Signal);

 

SetIndexEmptyValue(0,0.0);

SetIndexEmptyValue(1,0.0);

SetIndexEmptyValue(2,0.0);

SetIndexEmptyValue(3,0.0);

SetIndexEmptyValue(4,0.0);

SetIndexEmptyValue(5,0.0);

SetIndexEmptyValue(6,0.0);

SetIndexEmptyValue(7,0.0);

 

 

 

return(0);

}

 

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

int shift, limit, counted_bars=IndicatorCounted();

double Price1, Price2, smax, smin;

//----

if ( counted_bars < 0 ) return(-1);

if ( counted_bars ==0 ) limit=Bars-Length+Smooth+Signal-1;

if ( counted_bars < 1 )

for(int i=1;i<Length+Smooth+Signal;i++)

{

Bulls[bars-i]=0;

Bears[bars-i]=0;

AvgBulls[bars-i]=0;

AvgBears[bars-i]=0;

SmthBulls[bars-i]=0;

SmthBears[bars-i]=0;

SigBulls[bars-i]=0;

SigBears[bars-i]=0;

}

 

 

 

if(counted_bars>0) limit=Bars-counted_bars;

limit--;

 

for( shift=limit; shift>=0; shift--)

{

Price1 = iMA(NULL,0,1,0,0,Price,shift);

Price2 = iMA(NULL,0,1,0,0,Price,shift+1);

 

if (Mode==0)

{

Bulls[shift] = 0.5*(MathAbs(Price1-Price2)+(Price1-Price2));

Bears[shift] = 0.5*(MathAbs(Price1-Price2)-(Price1-Price2));

}

 

if (Mode==1)

{

smax=High[Highest(NULL,0,MODE_HIGH,Length,shift)];

smin=Low[Lowest(NULL,0,MODE_LOW,Length,shift)];

 

Bulls[shift] = Price1 - smin;

Bears[shift] = smax - Price1;

}

}

 

for( shift=limit; shift>=0; shift--)

{

AvgBulls[shift]=iMAOnArray(Bulls,0,Length,0,ModeMA,shift);

AvgBears[shift]=iMAOnArray(Bears,0,Length,0,ModeMA,shift);

}

 

for( shift=limit; shift>=0; shift--)

{

SmthBulls[shift]=iMAOnArray(AvgBulls,0,Smooth,0,ModeMA,shift);

SmthBears[shift]=iMAOnArray(AvgBears,0,Smooth,0,ModeMA,shift);

}

 

if(Mode_Histo == 1)

{

for( shift=limit; shift>=0; shift--)

{

if(SmthBulls[shift]-SmthBears[shift]>0)

{

SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,5);

SetIndexStyle(1,DRAW_LINE,EMPTY,2);

SmthBears[shift]= SmthBears[shift]/Point;

SmthBulls[shift]= SmthBulls[shift]/Point;

}

else

{

SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,5);

SetIndexStyle(0,DRAW_LINE,EMPTY,2);

SmthBears[shift]= SmthBears[shift]/Point;

SmthBulls[shift]= SmthBulls[shift]/Point;

}

} //end for( shift=limit; shift>=0; shift--)

} // end if(Mode_Histo == 1)

else

if(Mode_Histo == 2)

{

for( shift=limit; shift>=0; shift--)

{

if(SmthBulls[shift]-SmthBears[shift]>0)

{

SmthBears[shift]=-SmthBears[shift]/Point;

SmthBulls[shift]= SmthBulls[shift]/Point;

}

else

{

SmthBulls[shift]=-SmthBulls[shift]/Point;

SmthBears[shift]= SmthBears[shift]/Point;

}

} //end for( shift=limit; shift>=0; shift--)

} //end if(Mode_Histo == 2)

else

if(Mode_Histo == 3)

{

for( shift=limit; shift>=0; shift--)

{

SigBulls[shift]= SmthBulls[shift];

SigBears[shift]= SmthBears[shift];

if(SmthBulls[shift]-SmthBears[shift]>0)

SmthBears[shift]=0;

else

SmthBulls[shift]=0;

} //end for( shift=limit; shift>=0; shift--)

} //end if(Mode_Histo == 3)

else

if(Mode_Histo == 4)

{

for( shift=limit; shift>=0; shift--)

{

if(SmthBulls[shift]-SmthBears[shift]>0)

{

SigBears[shift]= SmthBears[shift];

SmthBears[shift]=0;

}

else

{

SigBulls[shift]= SmthBulls[shift];

SmthBulls[shift]=0;

}

} //end for( shift=limit; shift>=0; shift--)

} //end if(Mode_Histo == 4)

 

return(0);

}

//+------------------------------------------------------------------+

Share this post


Link to post
Share on other sites

I've been looking for a good trend indicator; so I'm trying the ADX. According to Investopedia the ADX is The Trend Strength Indicator and I've made some code to post chart labels on trend conditions. This is an upper chart indicator and you'll see labels only (no lines).

================================================

#

# SJ_ADX_DMI_TrendLabels

#

# Directional Movement System measures the ability of bulls and

# bears to move price outside the previous day's trading range.

declare upper;

input length = 14;

def hiDiff = high - high[1];

def loDiff = low[1] - low;

def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;

def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;

def ATR = WildersAverage(TrueRange(high, close, low), length);

def "DI+" = 100 * WildersAverage(plusDM, length) / ATR;

def "DI-" = 100 * WildersAverage(minusDM, length) / ATR;

def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;

def ADX = WildersAverage(DX, length);

# Starting A Bullish Trend

def Condition1 = "DI+" > ADX && ADX > "DI-" && "DI+" > "DI-";

# Ending A Bullish Trend

def Condition2 = ADX > "DI+" && ADX > "DI-" && "DI+" > "DI-";

# Starting Into A Range

def Condition3 = ADX > "DI+" && ADX > "DI-" && "DI-" > "DI+";

# Ending Out Of A Range

def Condition4 = "DI+" > ADX && "DI-" > ADX && "DI+" > "DI-";

# Starting A Bearish Trend

def Condition5 = "DI+" > ADX && "DI-" > ADX && "DI-" > "DI+";

# Ending A Bearish Trend

def Condition6 = ADX > "DI+" && ADX > "DI-" && "DI-" > "DI+";

 

# addChartLabel(visible, value, textLabel, color)

addchartlabel(yes, concat( 0, concat(" ",

If Condition1 then "Starting A Bullish Trend" else

If Condition2 then "Ending A Bullish Trend" else

If Condition3 then "Starting Into A Range" else

If Condition4 then "Ending Out Of A Range" else

If Condition5 then "Starting A Bearish Trend" else

If Condition6 then "Ending A Bearish Trend" else

"Wait")),

If Condition1 then color.green else

If Condition2 then color.gray else

If Condition3 then color.yellow else

If Condition4 then color.orange else

If Condition5 then color.red else

If Condition6 then color.pink else

color.white);

plot null = double.nan;

================================================

Share this post


Link to post
Share on other sites

Here's an updated version of the ADX, DMI Indicator that I recently posted.

#

# SJ_ADX_DMI_TrendStrengthLabels

#

# Directional Movement System measures the ability of bulls and

# bears to move price outside the previous day's trading range.

declare upper;

input length = 14;

def hiDiff = high - high[1];

def loDiff = low[1] - low;

def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;

def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;

def ATR = WildersAverage(TrueRange(high, close, low), length);

def "DI+" = 100 * WildersAverage(plusDM, length) / ATR;

def "DI-" = 100 * WildersAverage(minusDM, length) / ATR;

def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;

def ADX = WildersAverage(DX, length);

#

# ============================================================

# ============================================================

# Bullish Trend

def BullishCondition = "DI+" > "DI-";

# Bearish Trend

def BearishCondition = "DI-" > "DI+";

# ============================================================

# ============================================================

# Range Bound & No Trend

def ConditionA = ADX > 0 && ADX < 20;

# Absent or Weak Trend

def ConditionB = ADX > 20 && ADX < 25;

# Strong Trend

def ConditionC = ADX > 25 && ADX < 50;

# Very Strong Trend

def ConditionD = ADX > 50 && ADX < 75;

# Extremely Strong Trend

def ConditionE = ADX > 75 && ADX < 100;

# ============================================================

# ************************************************************

# addChartLabel(visible, value, textLabel, color)

AddChartLabel(yes, concat( ADX, concat(If ConditionA then " Range Bound " else If ConditionB then " Weak " else If ConditionC then " Strong " else If ConditionD then " Very Strong " else If ConditionE then " Extremely Strong " else " No Strength ", If BullishCondition then "Bullish Trend" else If BearishCondition then "Bearish Trend" else "& No Trend")), if BullishCondition then color.green else color.red);

plot null = double.nan

Share this post


Link to post
Share on other sites
They also have a great deal on Snake Oil apparently as well. :spam:

 

That I don't know. I do know, however, that the guy who does the videos for TSI helped start them (I doubt highly he is involved with any "snake oil"), and the site is less 2 weeks old (TSI announced it in their emails).

 

Did you have a bad experience with them within the last 2 weeks?

Share this post


Link to post
Share on other sites
Did you have a bad experience with them within the last 2 weeks?

 

A casual glance at your post history reveals that:

 

1) You are probably affiliated with the folks selling that garbage (I suspect they are in fact your web sites).

 

2) You are spamming this board with links back to your sites.

 

Please stop.

Share this post


Link to post
Share on other sites

Actually, although I am not directly affiliated with the compnay I do personally know the web designer.

 

However, I have been trading with the Thinkorswim platform since 2002, when it was just Investools. And have been trading for a living since 1997.

 

The facts are, and It is obvious that:

 

1.) You are an idiot, and quite possible a very unhappy and unsuccessful trader.

 

2.) They are not my sites.

 

3.) I have only mentioned these sites in response to direct questions and becuase I am convinced of their superiority as regards the TOS platform.

 

4.) I make over $10 K a week and have successfully for over 10 years now. And am qualified to make whatever statements I so choose. :haha:

 

5.) You did not answer the question and obviously need someone to blame for your lack of prowess in the markets.

 

6.) I have made 25 posts--6 times more than you--on a great many subjects, and have only mentioned TSI indicators a few measily times.

 

7.) And a casual galnce at YOUR post history shows that your negative remarks to me were the very first post you have ever made since joining in February. Excellent timing.

 

I personally have no vested interest and do not care if you use or like TSI indicators...or any other indicators for that matter. However, attacks against me were unsubstantiated, woefully uninformed, dear chap, and unwarranted.

 

Each individual can decide for him/herself if they want to follow up on any statement I make in life. After I make that statement, I really wouldn't care. I don't even KNOW you: I spend more time on the blue seas than I do in these forums, mate.

 

If you are that acrimonious and bitter at the world I suggest you blame yourself for leveraging your house against the markets--or whatever dumb thing you must have done to go spewing nonsense in these forums.

 

Ask your old boss for your job back...if he'll have you. Trading is obviously not your forte.

Edited by HI_THERE
misspell

Share this post


Link to post
Share on other sites

Me thinks he doth protest too much. The magnitude of your over reaction speaks volumes...

 

Bottom Line: There are more than enough free Think or Swim indicators available that you should steer as clear as possible from the crooks at TSI.

Share this post


Link to post
Share on other sites

I have no interest in conversing with you RandomTask. In fact, I have turned off my email alerts to hedge against having to hear from the likes of blokes like you.

 

So you now have this thread to yourself.

 

:haha: You can dislike that company all you like: it doesn't affect me.

 

But your attack on me was unwarranted.

 

You should use this website as an educational base, instead of a personal platform to whine. If you are blaming an indicator for your inability to trade, then "methinks" you should re-formulate.

 

Goodday, mate. And good luck.

Edited by HI_THERE
misspell

Share this post


Link to post
Share on other sites

up volume

 

============================

 

 

declare lower;

 

input distrday_threshold = 9;

 

def upvol = close(“$UVOL”);

def dnvol = close(“$DVOL”);

 

plot ZeroLine = 0;

plot DistrDay = distrday_threshold;

 

plot volumedata = upvol;

 

volumedata.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

volumedata.DefineColor(“Positive”, Color.UPTICK);

volumedata.DefineColor(“Negative”, Color.DOWNTICK);

volumedata.AssignValueColor(if volumedata >= distrday_threshold then volumedata.color(“Positive”) else volumedata.color(“Negative”));

Share this post


Link to post
Share on other sites

down volume

======================

 

declare lower;

 

input distrday_threshold = 9;

 

def upvol = close(“$UVOL”);

def dnvol = close(“$DVOL”);

 

plot ZeroLine = 0;

plot DistrDay = distrday_threshold;

 

plot volumedata = dnvol;

 

volumedata.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

volumedata.DefineColor(“Positive”, Color.UPTICK);

volumedata.DefineColor(“Negative”, Color.DOWNTICK);

volumedata.AssignValueColor(if volumedata >= distrday_threshold then volumedata.color(“Positive”) else volumedata.color(“Negative”));

Share this post


Link to post
Share on other sites

Plotting Prices & Indexes On Price Bars

 

This code is to start the bar count from the first bar on the far left side of the chart and count down forward in time. I'm trying to use the fold statement to do a count down, but fold is so different from loops in other programming languages. I need help on this.

=================================================

declare upper;

# Clear Chart

AssignPriceColor(CreateColor(10, 0, 78));

AssignBackgroundColor(CreateColor(10, 0, 78));

# Graph Boundaries

plot HH = HighestAll(high);

plot LL = LowestAll(low);

plot ML = (HH + LL) / 2;

# Plot Bubbles

def TotalBarsOnChart=24*60*60*1000/getAggregationPeriod();

def Bar_Xaxis = barNumber();

def Bar_Yaxis = ML;

rec FBarIndex = if IsNaN(FBarIndex[1] ) then 0 else FBarIndex[1] + 1;

rec RBarIndex=fold index = 1 to TotalBarsOnChart with Bar = TotalBarsOnChart do Bar = Bar - 1);

 

AddChartBubble(Bar_Xaxis, Bar_Yaxis, concat("", FBarIndex), color.Gray, No);

AddChartBubble(Bar_Xaxis, Bar_Yaxis + 0.2, concat("", RBarIndex), color.Yellow, No);

=================================================

Edited by Stock.Jock

Share this post


Link to post
Share on other sites

input timeFrame = {default DAY};

input showOnlyToday = no;

 

def day = getDay();

def lastDay = getLastDay();

def isToday = if(day >= lastDay, 1, 0);

def shouldPlot = if(showOnlyToday and isToday, 1, if(!showOnlyToday, 1, 0));

 

 

declare lower;

 

input distrday_threshold = 9;

 

def upvol = close(“$UVOL”);

def dnvol = close(“$DVOL”);

 

plot ZeroLine = 0;

plot DistrDay = distrday_threshold;

 

# plot volumedata = absvalue ( dnvol / upvol );

 

plot volumedata = if (shouldPlot,

absvalue( dnvol/upvol) ,

double.nan);

 

volumedata.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

volumedata.DefineColor(“Positive”, Color.UPTICK);

volumedata.DefineColor(“Negative”, Color.DOWNTICK);

volumedata.AssignValueColor(if volumedata >= distrday_threshold then volumedata.color(“Positive”) else volumedata.color(“Negative”));

 

#volumedata.AssignValueColor(if volumedata > volumedata[1] then #color.red else color.green);

 

============================================

 

TOS is only good for end of day charting.... nothing more.

Share this post


Link to post
Share on other sites
there are a lot of TOS indicators out there now on the web.

 

however don't try to use TOS for live trading as you will lose your shirt

 

you should qualify that...

TOS is a very good options broker.

anything else is not their specialty.

Share this post


Link to post
Share on other sites

.... speaking about reliability issues.... not which products to trade

 

there are a lot of TOS indicators out there now on the web.

however don't try to use TOS for live trading as you will lose your shirt

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Topics

  • Posts

    • NFLX Netflix stock, with a solid top of range breakout, from Stocks to Watch at https://stockconsultant.com/?NFLX  
    • NFLX Netflix stock, with a solid top of range breakout, from Stocks to Watch at https://stockconsultant.com/?NFLX  
    • It depends. If you have lots of money that you can buy a house without a loan and if you don't have any parents to sponsor then it is a good idea. Otherwise it might be a bad idea depending where in Canada you are heading to. I earned a good middle income in my home country and I migrated to Vancouver 5 years ago at the age of 35. I had to start right from the bottom, lowest of the low.. Now i am finally earning a middle income in Canada but I still cannot afford to buy a one bedroom apartment. Having left behind friends, family and home, most of the times I think it is not worth it.   In short, do not migrate if you already have a good life in your home country and you are happy. Only migrate to Canada if you really have to leave your home country say there is a war or something really bad. Discrimination still exists here and its really tough for newcomers unless you are super rich. Good luck. David Chong, Quora  
    • This is bigger than the internet. Bigger than mobile. Bigger than social media.   While everyone was distracted by stock market fluctuations and political theater…   Most people have NO IDEA what just happened last week with ChatGPT.   Their new memory feature allows ChatGPT to remember EVERYTHING about you across all your conversations.   Think about that for a minute...   While most tech companies have been collecting mere breadcrumbs about you - your likes, your clicks, your browsing history - OpenAI is now collecting the most valuable dataset in human history: your complete psychological profile.   This is Zuckerberg x 5,000.   The more you use ChatGPT, the more it understands you, becoming a supercharged reflection of yourself that improves at an exponential rate.   Are you a regular ChatGPT user?   Consider whether it’s time to turn off the “you can train on my information” feature. To prevent your data from being used for training while still using the memory feature:   Disable Model Training: Navigate to Settings > Data Controls. Toggle off "Improve the model for everyone". Manage Memory Settings: Go to Settings > Personalization > Memory. Here, you can: Turn off memory entirely. Delete specific memories. Use Temporary Chat for sessions that won't be saved or used for training. Now the investment implications…   Why This is Bigger Than You Think Consider this: the relationship between humans and ChatGPT is evolving beyond a mere tool.   People are now treating these AI assistants as friends, confidants, and even romantic partners.   I'm not making this up - there are already documented cases of people ending real human relationships to pursue “connections” with their AI companions.   A viral Instagram meme shows a person going through life with a glowing, featureless humanoid figure - representing ChatGPT - as their companion.   The post has over 1.1 million likes and comments like "Bro ChatGPT is like my best friend. Ain't even ashamed to say it" with 25,000 likes.   But here's where things get really interesting for investors and entrepreneurs...   Three Things to Watch For starters, hardware is the next big thing for the big players.   The iPhone form factor is dead.   It hasn't meaningfully changed in nearly a decade. The next evolution in hardware will be designed specifically to interface with these AI companions.   OpenAI is already working on hardware with Johnny Ive, the legendary designer behind the iPhone and iPod. But you can’t ignore Elon Musk’s edge here.   So what does all of this mean for you?   The companies that control the personal AI relationships will be worth trillions. OpenAI and Elon Musk will have the coziest moats. We're witnessing the birth of a new internet - one built on agents that can communicate with each other across platforms. Google's new agent-to-agent protocol allows AI agents to work together without sharing internal memories or tools. The hardware companies that create the perfect interface for these AI companions will dominate the next decade of technology. And almost nobody is talking about what this means.   My prediction? Within five years, most people will have a personal AI that knows them better than anyone else. And they will interact with it in ways that seem foreign today.   (And, yes, it will almost certainly have dystopian elements.)   In the meantime, the biggest gains won’t come from household names. And, right now, James is seeing a prime opportunity to invest in the most under-the-radar plays in AI…   For dirt cheap. By Chris C. Source: https://altucherconfidential.com/posts/use-chatgpt-protect-yourself-now
    • KBH KB Home stock, nice day and rally off the 50.82 support area, from Stocks to Watch at https://stockconsultant.com/?KBH      
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.