Putting up and down arrows on chart - ThinkOrSwim Programming | futures io social day trading
futures io futures trading


Putting up and down arrows on chart
Updated: Views / Replies:2,806 / 2
Created: by Cirrus Flyer Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Putting up and down arrows on chart

  #1 (permalink)
Trading Apprentice
Kaukauna, WI, USA
 
Futures Experience: Beginner
Platform: TOS
Favorite Futures: Stocks
 
Posts: 1 since Feb 2014
Thanks: 1 given, 0 received

Putting up and down arrows on chart

I'm trying to put up or down arrows on the chart if certain conditions are met. Here's the code that I'm having trouble with:


plot Arrow = if (ConnersRSI <= UnderSold) then Arrow = (Arrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP)) else if (ConnersRSI => OverBought) then Arrow = (Arrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN));

Think Script just gives me Invalid Statement. I took the form of the if statement right out of the TOS reference area.

Can anybody help get? Again, thanks in advance for the help.

Alan

Reply With Quote
 
  #2 (permalink)
Trading Apprentice
Portland, OR, USA
 
Futures Experience: Intermediate
Platform: thinkorswim
Favorite Futures: options
 
Posts: 3 since Aug 2015
Thanks: 4 given, 1 received

Use AddOrder() with a custom Strategy

Hi Alan,

AFAIK, you'll want to use addOrder() to add up/down arrows. But first a bit on your question about the invalid statement. When using plot Data = x, the x needs to resolve to a numeric value otherwise we couldn't plot it. For a very simplistic possibly even silly illustration, if we wanted to plot a 1 every time the close exceeded the open price and 0 if it didn't, we could write:

 
Code
plot Data = if close > open then 1 else 0;
Note how the value assigned to Data is numeric (1 or 0);

Now for for putting arrows on the chart, the AddOrder() function offers that. The ConnorsRSI isn't built into TOS so I found an implementation online and modified it for use as a strategy and not a plot. We use the appropriate AddOrders with conditions for overbought buy and sell. I created this as a strategy (not a study) and then ran a strategy report on FB for the last year (daily) and it made 115 orders with total Profit/Loss of $2075. I also used the standard convention from other strategies where up arrows indicate a long entry (aka buy) and down arrows a short entry (aka sell). Hope that helps

 
Code
input Over_Bought = 70;
input Over_Sold = 30;

# ConnorsRSI taken from 
# https://groups.yahoo.com/neo/groups/TOS_thinkscript/conversations/topics/14212
input Price_RSI_Period = 3;
input Streak_RSI_Period = 2;
input Rank_Lookback = 100;

# Component 1: the RSI of closing price
def priceRSI = reference RSI("price" = close, "length" = Price_RSI_Period);

# Component 2: the RSI of the streak 
def upDay = if close > close[1] then 1 else 0;
def downDay = if close < close[1] then -1 else 0;
def upStreak = if upDay != 0 then upStreak[1] + upDay else 0;
def downStreak = if downDay != 0 then downStreak[1] + downDay else 0;
def streak = upStreak + downStreak;
def streakRSI = reference RSI("price" = streak, "length" = Streak_RSI_Period); 

# Componenet 3: The percent rank of the current return
def ROC1 = close / close[1] - 1;

def rank = fold i = 1 to Rank_Lookback + 1 with r = 0 do 
r + (GetValue(ROC1, i, Rank_Lookback) < ROC1) ;

def pctRank = (rank / Rank_Lookback) * 100 ; 

# The final ConnorsRSI calculation, combining the three components
def ConnorsRSI = (priceRSI + streakRSI + pctRank) / 3;

#Add up arrows
AddOrder(OrderType.BUY_AUTO, ConnorsRSI <= Over_Sold, tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "ConnorsRSIStratLE");
#Add down arrows
AddOrder(OrderType.SELL_AUTO, ConnorsRSI >= Over_Bought, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "ConnorsRSIStratSE");

Reply With Quote
The following user says Thank You to jeremyis for this post:
 
  #3 (permalink)
Trading Apprentice
albuquerque nm/usa
 
Futures Experience: Intermediate
Platform: thinkorswim
Favorite Futures: forex
 
Posts: 29 since Aug 2015
Thanks: 3 given, 8 received



Cirrus Flyer View Post
I'm trying to put up or down arrows on the chart if certain conditions are met. Here's the code that I'm having trouble with:


plot Arrow = if (ConnersRSI <= UnderSold) then Arrow = (Arrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP)) else if (ConnersRSI => OverBought) then Arrow = (Arrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN));

Think Script just gives me Invalid Statement. I took the form of the if statement right out of the TOS reference area.

Can anybody help get? Again, thanks in advance for the help.

Alan

jeremyis already gave you a great reply, way above my pay grade. But for those browsing who are more TS newbie than I am, the thread title suggests something simpler might be on offer. So here are some simplistic answers to your question.
--------------------------------------
 
Code
#For arrows, you want some definite value produced by a calculation in your code.
#Let's say you want an UP arrow whenever the close moves up at least 1% from the
#previous close FOR THE FIRST TIME. And you want a DOWN arrow whenever the close
#moves down at least 1% from the previous close FOR THE FIRST TIME. So the initial
#part of your code could look like this:

def runup = close >= 1.01 * close[1];
def rundown = close <= 0.99 * close[1];

#Now plot the arrows:

plot Above = runup;
Above.SetDefaultColor(Color.BLUE);
Above.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
plot Below = rundown;
Below.SetDefaultColor(Color.RED);
Below.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

#Next, IF YOU HAD DECLARED THIS AS A LOWER STUDY, then to make those arrows run in nice
#horizontal lines, add a zeroline (or you'll get annoyingly ragged rows of arrows. DO NOT
#add the zeroline to an upper study (price overlay) because it'll flatten everything on your chart,
#remedied only by right-clicking the study and USE LEFT AXIS:

plot zeroline = 0;
--------------------------------------
#Now, suppose you find that the above code seems to profit you Long only when the
#current high is higher than the previous high, and it profits you Short only when the
#current low is lower than the previous low. Time to tweak it. Before I began to better
#understand how to write if-then-else conditionals, I simply used def workarounds like
#this, to avoid if-then-else stuff:

def runup = close >= 1.01 * close[1] AND high > high[1];
def rundown = close <= 0.99 * close[1] AND low < low[1];

#The above two lines of code are the only change from the original, using the Boolean
#operator "AND" to say you want BOTH conditions met before plotting an arrow.

plot Above = runup;
Above.SetDefaultColor(Color.BLUE);
Above.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
plot Below = rundown;
Below.SetDefaultColor(Color.RED);
Below.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);


Last edited by tangerine; August 24th, 2015 at 06:59 PM.
Reply With Quote

Reply



futures io > > > > > Putting up and down arrows on chart

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Webinar: FuturesTrader71 (FT71) - Putting all the pieces together Big Mike Traders Hideout 15 March 16th, 2014 10:27 AM
Putting things into perspective rickey Traders Hideout 9 February 5th, 2012 11:54 PM
How to trade SPY by putting orders on ES? (MultiInstrument trading) zokirb The Elite Circle 10 January 29th, 2012 11:09 AM
Week Ahead: Oil Prices to Keep Putting Pressure on Stocks Quick Summary News and Current Events 0 March 5th, 2011 04:20 AM
Student Loan Reforms Putting Taxpayers on Hook for Billions Quick Summary News and Current Events 0 December 21st, 2010 10:50 AM


All times are GMT -4. The time now is 02:12 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-11 in 0.12 seconds with 19 queries on phoenix via your IP 54.226.34.209