Need simple algo coded in thinkscript - ThinkOrSwim | futures io social day trading
futures io futures trading


Need simple algo coded in thinkscript
Updated: Views / Replies:2,844 / 6
Created: by 1zach4 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 100,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
 

Need simple algo coded in thinkscript

  #1 (permalink)
Tampa, FL
 
 
Posts: 50 since Feb 2013
Thanks: 3 given, 15 received

Need simple algo coded in thinkscript

I have some pretty basic thinkscript code that is highly effective for /ES trading, but I cannot get it to work because I have minimal knowledge of thinkscript.

If anyone has the ability, I would gladly share the code with you if you can get it to work.

Reply With Quote
 
  #2 (permalink)
Dallas, Texas
 
 
Posts: 43 since Jun 2015
Thanks: 2 given, 26 received


1zach4 View Post
I have some pretty basic thinkscript code that is highly effective for /ES trading, but I cannot get it to work because I have minimal knowledge of thinkscript.

If anyone has the ability, I would gladly share the code with you if you can get it to work.

Shoot... I might be able to help.

Reply With Quote
 
  #3 (permalink)
Tampa, FL
 
 
Posts: 50 since Feb 2013
Thanks: 3 given, 15 received



devildriver6 View Post
Shoot... I might be able to help.

Won't let me DM for another 60min

Is there a way to have the period for the profile adjustable? Like can we set it up to switch back and forth between last n bars or 1 day, etc?

Reply With Quote
 
  #4 (permalink)
Dallas, Texas
 
 
Posts: 43 since Jun 2015
Thanks: 2 given, 26 received


1zach4 View Post
Won't let me DM for another 60min

Is there a way to have the period for the profile adjustable? Like can we set it up to switch back and forth between last n bars or 1 day, etc?

Sure.
Here you go.

VA set to default HOUR. Label shows when above or below VA.
Arrows are your logic.


input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {CHART, MINUTE, default HOUR, DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1; #### Hint: Set for time
input onExpansion = no;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 68;
input opacity = 0;
input displace = 0;
input ShowValueLabel = yes;


def period;
def yyyymmdd = getYyyyMmDd();
def seconds = secondsFromTime(0);
def month = getYear() * 12 + getMonth();
def day_number = daysFromDate(first(yyyymmdd)) + getDayOfWeek(first(yyyymmdd));
def dom = getDayOfMonth(yyyymmdd);
def dow = getDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
switch (timePerProfile) {
case CHART:
period = 0;
case MINUTE:
period = floor(seconds / 60 + day_number * 24 * 60);
case HOUR:
period = floor(seconds / 3600 + day_number * 24);
case DAY:
period = countTradingDays(Min(first(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
period = floor(day_number / 7);
case MONTH:
period = floor(month - first(month));
case "OPT EXP":
period = exp_opt - first(exp_opt);
case BAR:
period = barNumber() - 1;
}



def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1], 0);
def cond = count < count[1] + period - period[1];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
height = PricePerRow.AUTOMATIC;
case TICKSIZE:
height = PricePerRow.TICKSIZE;
case CUSTOM:
height = customRowHeight;
}

profile tpo = timeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = compoundValue(1, onExpansion, no);
def pc = if IsNaN(tpo.getPointOfControl()) and con then pc[1] else tpo.getPointOfControl();
def hVA = if IsNaN(tpo.getHighestValueArea()) and con then hVA[1] else tpo.getHighestValueArea();
def lVA = if IsNaN(tpo.getLowestValueArea()) and con then lVA[1] else tpo.getLowestValueArea();

def hProfile = if IsNaN(tpo.getHighest()) and con then hProfile[1] else tpo.getHighest();
def lProfile = if IsNaN(tpo.getLowest()) and con then lProfile[1] else tpo.getLowest();
def plotsDomain = IsNaN(close) == onExpansion;


plot POC = if plotsDomain then pc[displace] else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile[displace] else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile[displace] else Double.NaN;
plot VAH = if plotsDomain then hVA[displace] else Double.NaN;
plot VAL = if plotsDomain then lVA[displace] else Double.NaN;

DefineGlobalColor("Profile", color.blue);
DefineGlobalColor("Value Area", color.gray);
DefineGlobalColor("Point Of Control", color.yellow);

tpo.show(globalColor("Profile"), if showPointOfControl then globalColor("Point Of Control") else color.current, if showValueArea then globalColor("Value Area") else color.current, opacity);
POC.SetDefaultColor(color.yellow);
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAH.SetDefaultColor(color.green);
VAL.SetDefaultColor(color.red);
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.hide();
ProfileLow.hide();
VAH.setlineweight(3);
VAL.setlineweight(3);
Poc.setlineweight(3);


def VA = VAH - VAL;

addlabel(ShowValueLabel,
if close <= VAH && close >= VAL && close >= POC
then "Inside VA, > POC: " +" (" +VAH +" / " +VAL +") "
else if close <= VAH && close >= VAL && close < POC
then "Inside VA, < POC: " +" (" +VAH +" / " +VAL +") "
else if close < VAL
then "< VA: " +" (" +VAL +") "
else if close > VAH
then "> VA: " +" (" +VAH +") "
else "",
if close <= VAH && close >= VAL && close >= POC
then color.yellow
else if close <= VAH && close >= VAL && close < POC
then color.dark_orange
else if close < VAL
then color.red
else if close > VAH
then color.green
else color.gray);


def lr = 6 * ( WMA(OHLC4, 10) - Average(OHLC4, 10) ) / 9;
def upBar = close > open;
def dnBar = close < open;
def short = lr > 0 && upBar && close > VAH;
def long = lr < 0 && dnBar && close < VAL;
plot longSignal = if long && !long[1] and !long[2] then low else Double.NaN;
plot shortSignal = if short && !short[1] and !short[2] then high else Double.NaN;
longSignal.setpaintingStrategy(paintingStrategy.ARROW_UP);
shortSignal.setpaintingStrategy(paintingStrategy.ARROW_DOWN);
longSignal.setdefaultColor(color.cyan);
shortSignal.setdefaultColor(color.magenta);
longSignal.setlineweight(5);
shortSignal.setlineweight(5);
longSignal.hidebubble();
shortSignal.hidebubble();
longSignal.hidetitle();
shortSignal.hidetitle();

Reply With Quote
The following user says Thank You to devildriver6 for this post:
 
  #5 (permalink)
Tampa, FL
 
 
Posts: 50 since Feb 2013
Thanks: 3 given, 15 received

Wow, thank you so much!


devildriver6 View Post
Sure.
Here you go.

VA set to default HOUR. Label shows when above or below VA.
Arrows are your logic.


input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {CHART, MINUTE, default HOUR, DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1; #### Hint: Set for time
input onExpansion = no;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 68;
input opacity = 0;
input displace = 0;
input ShowValueLabel = yes;


def period;
def yyyymmdd = getYyyyMmDd();
def seconds = secondsFromTime(0);
def month = getYear() * 12 + getMonth();
def day_number = daysFromDate(first(yyyymmdd)) + getDayOfWeek(first(yyyymmdd));
def dom = getDayOfMonth(yyyymmdd);
def dow = getDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
switch (timePerProfile) {
case CHART:
period = 0;
case MINUTE:
period = floor(seconds / 60 + day_number * 24 * 60);
case HOUR:
period = floor(seconds / 3600 + day_number * 24);
case DAY:
period = countTradingDays(Min(first(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
period = floor(day_number / 7);
case MONTH:
period = floor(month - first(month));
case "OPT EXP":
period = exp_opt - first(exp_opt);
case BAR:
period = barNumber() - 1;
}



def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1], 0);
def cond = count < count[1] + period - period[1];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
height = PricePerRow.AUTOMATIC;
case TICKSIZE:
height = PricePerRow.TICKSIZE;
case CUSTOM:
height = customRowHeight;
}

profile tpo = timeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = compoundValue(1, onExpansion, no);
def pc = if IsNaN(tpo.getPointOfControl()) and con then pc[1] else tpo.getPointOfControl();
def hVA = if IsNaN(tpo.getHighestValueArea()) and con then hVA[1] else tpo.getHighestValueArea();
def lVA = if IsNaN(tpo.getLowestValueArea()) and con then lVA[1] else tpo.getLowestValueArea();

def hProfile = if IsNaN(tpo.getHighest()) and con then hProfile[1] else tpo.getHighest();
def lProfile = if IsNaN(tpo.getLowest()) and con then lProfile[1] else tpo.getLowest();
def plotsDomain = IsNaN(close) == onExpansion;


plot POC = if plotsDomain then pc[displace] else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile[displace] else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile[displace] else Double.NaN;
plot VAH = if plotsDomain then hVA[displace] else Double.NaN;
plot VAL = if plotsDomain then lVA[displace] else Double.NaN;

DefineGlobalColor("Profile", color.blue);
DefineGlobalColor("Value Area", color.gray);
DefineGlobalColor("Point Of Control", color.yellow);

tpo.show(globalColor("Profile"), if showPointOfControl then globalColor("Point Of Control") else color.current, if showValueArea then globalColor("Value Area") else color.current, opacity);
POC.SetDefaultColor(color.yellow);
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAH.SetDefaultColor(color.green);
VAL.SetDefaultColor(color.red);
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.hide();
ProfileLow.hide();
VAH.setlineweight(3);
VAL.setlineweight(3);
Poc.setlineweight(3);


def VA = VAH - VAL;

addlabel(ShowValueLabel,
if close <= VAH && close >= VAL && close >= POC
then "Inside VA, > POC: " +" (" +VAH +" / " +VAL +") "
else if close <= VAH && close >= VAL && close < POC
then "Inside VA, < POC: " +" (" +VAH +" / " +VAL +") "
else if close < VAL
then "< VA: " +" (" +VAL +") "
else if close > VAH
then "> VA: " +" (" +VAH +") "
else "",
if close <= VAH && close >= VAL && close >= POC
then color.yellow
else if close <= VAH && close >= VAL && close < POC
then color.dark_orange
else if close < VAL
then color.red
else if close > VAH
then color.green
else color.gray);


def lr = 6 * ( WMA(OHLC4, 10) - Average(OHLC4, 10) ) / 9;
def upBar = close > open;
def dnBar = close < open;
def short = lr > 0 && upBar && close > VAH;
def long = lr < 0 && dnBar && close < VAL;
plot longSignal = if long && !long[1] and !long[2] then low else Double.NaN;
plot shortSignal = if short && !short[1] and !short[2] then high else Double.NaN;
longSignal.setpaintingStrategy(paintingStrategy.ARROW_UP);
shortSignal.setpaintingStrategy(paintingStrategy.ARROW_DOWN);
longSignal.setdefaultColor(color.cyan);
shortSignal.setdefaultColor(color.magenta);
longSignal.setlineweight(5);
shortSignal.setlineweight(5);
longSignal.hidebubble();
shortSignal.hidebubble();
longSignal.hidetitle();
shortSignal.hidetitle();


Reply With Quote
 
  #6 (permalink)
Dallas, Texas
 
 
Posts: 43 since Jun 2015
Thanks: 2 given, 26 received


1zach4 View Post
Wow, thank you so much!

You bet.
Granted, I already had most of the logic, and yours was sound.
Just needed some minor things added to it.

Hope it helps.

Reply With Quote
 
  #7 (permalink)
Concord NH
 
 
Posts: 1 since Sep 2017
Thanks: 0 given, 0 received

Hi, any way you can help explain what this script is plotting, it looks interesting but not fully understanding the usage.


THanks,
DOnald

Reply With Quote

Reply



futures io > > > > Need simple algo coded in thinkscript




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

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now
 

Webinar: CME Micro-Indices & Important Lessons Learned w/FuturesTrader71

Elite only
 

Show us your trading desks and win $1,400 in prizes w/Earn2Trade

November
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
ThinkScript Help needed with a simple strategy Pongor ThinkOrSwim Programming 7 June 28th, 2015 12:53 PM
Strategies coded in R donedge Matlab, R project and Python 24 January 4th, 2015 02:07 PM
Has anyone coded these indicators? solom113 NinjaTrader 10 July 21st, 2012 05:33 PM
Can a floating window be coded with Ninjascript ? trendisyourfriend NinjaTrader Programming 29 December 21st, 2010 04:02 AM
need paintbar study coded-PLEASE bobbyacim The Elite Circle 3 July 28th, 2010 02:35 PM


All times are GMT -4. The time now is 08:43 PM. (this page content is cached, log in for real-time version)

Copyright © 2019 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