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

    • Date: 26th November 2024. Trump’s tariff threats boosted Dollar; Peso, Loonie, Gold & Oil Lower. The Trump trade picked up steam as investors cheered his pick for Treasury Secretary, Scott Bessent. Beliefs he will be a steadying voice in the administration’s fiscal measures, while still following President-elect Trump’s tariff and tax commitments, underpinned. Asia & European Sessions:   Trump threatened on Monday to impose sweeping new tariffs on China, Canada and Mexico on his first day as US President to crack down on illegal immigration and drugs. He would impose a 25% tax on all products entering the country from Canada and Mexico, and an additional 10% tariff on goods from China as one of his first acts as president of the US. Bessent’s 3-3-3 plan aims to cut the deficit to 3% of GDP, boost growth to 3%, and increase oil production to 3 mln barrels. Treasury yields dove in a curve flattener, extending their drops through the session, on expectations inflation will decelerate. A strong 2-year auction also supported. The Dow led the charge, climbing 0.99% to 44,736, a new record peak as the rally broadens. The S&P500 climbed to 6020, a session peak, but finished with a 0.3% gain to 5987. The NASDAQ closed 0.27% higher. Today, stock markets in Europe are posting broad losses, with the DAX down -0.6%, the FTSE 100 0.4%, after a largely weaker close across Asia. ECB: Lane suggests ECB must be open-minded on speed of rate cuts. The ECB’s Chief Economist said in a speech on Monday evening that “remaining open-minded about the speed and scale of adjustments is in fact a valuable strategy across various environments, as different situations may necessitate distinct approaches.” This careful, step-by-step strategy enables us to observe the responses of the economy to our decisions and continuously refine our understanding of their impacts.” The comments leave the door open to a 50 bp move in December, but also tie in with our expectation that the central bank will deliver a 25 bp while tweaking the forward guidance and commit to additional moves. Financial Markets Performance: The USDIndex hit a session high of 107.50 and is currently lower at 106.85. Mexican peso and Canadian dollar slumped as the dollar is being viewed as a haven after the comments of President-elect Donald Trump on tariffs on Canada, Mexico and China. USDCAD spiked to 1.4177 and USDMXN rallied to 20.74. Oil and Gold lost ground, in part on cooling geopolitical risks, and on Trump trades. Oil dropped -3.03% to $69.09 per barrel, in part on the Trump trade and on talk of a potential cease fire between Israel and Hezbollah. Similarly, gold fell -3.26% to $2605 per ounce. Always trade with strict risk management. Your capital is the single most important aspect of your trading business. Please note that times displayed based on local time zone and are from time of writing this report. Click HERE to access the full HFM Economic calendar. Want to learn to trade and analyse the markets? Join our webinars and get analysis and trading ideas combined with better understanding of how markets work. Click HERE to register for FREE! Click HERE to READ more Market news. Andria Pichidi HFMarkets Disclaimer: This material is provided as a general marketing communication for information purposes only and does not constitute an independent investment research. Nothing in this communication contains, or should be considered as containing, an investment advice or an investment recommendation or a solicitation for the purpose of buying or selling of any financial instrument. All information provided is gathered from reputable sources and any information containing an indication of past performance is not a guarantee or reliable indicator of future performance. Users acknowledge that any investment in FX and CFDs products is characterized by a certain degree of uncertainty and that any investment of this nature involves a high level of risk for which the users are solely responsible and liable. We assume no liability for any loss arising from any investment made based on the information provided in this communication. This communication must not be reproduced or further distributed without our prior written permission.
    • RYAM Rayonier Advanced Materials stock, nice trend with a pull back to 8.79 support area, bullish indicators at https://stockconsultant.com/?RYAM
    • LICY Li-Cycle stock watch, attempting to move higher off the 2.15 triple+ support area at https://stockconsultant.com/?LICY
    • SGMO Sangamo Therapeutics stock watch, pull back to 2 support area with high trade quality at https://stockconsultant.com/?SGMO
    • YUMC Yum China stock watch, pull back to 47.4 support area with bullish indicators at https://stockconsultant.com/?YUMC
×
×
  • Create New...

Important Information

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