NexusFi: Find Your Edge


Home Menu

 





Thinkscripts


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one RedK with 20 posts (15 thanks)
    2. looks_two pbenson68 with 15 posts (1 thanks)
    3. looks_3 RemoWilliams with 5 posts (1 thanks)
    4. looks_4 courier12 with 5 posts (0 thanks)
      Best Posters
    1. looks_one optntdr13 with 8.3 thanks per post
    2. looks_two Silvester17 with 8 thanks per post
    3. looks_3 Massive l with 3 thanks per post
    4. looks_4 RedK with 0.8 thanks per post
    1. trending_up 77,255 views
    2. thumb_up 73 thanks given
    3. group 52 followers
    1. forum 111 posts
    2. attach_file 32 attachments




 
Search this Thread

Thinkscripts

  #91 (permalink)
 
rmejia's Avatar
 rmejia 
Puerto Rico
 
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441


courier12 View Post
Has anyone coded the TWAP indicator in ThinkorSwim? TOS has a built in VWAP but not TWAP.

Found this one a while back:

 
Code
input price = FundamentalType.HLC3;
input timeFrame = {default Day, Week, Month, Chart};

script TimeWAP {

input price = hlc3;
input timeFrame = {default Day, Week, Month, Chart};

def yyyyMmDd = getYyyyMmDd();
def periodIndx;
switch (timeFrame) {
case DAY:
    periodIndx = yyyyMmDd;
case WEEK:
    periodIndx = Floor((daysFromDate(first(yyyyMmDd)) + getDayOfWeek(first(yyyyMmDd))) / 7);
case MONTH:
    periodIndx = roundDown(yyyyMmDd / 100, 0);
case Chart:
    periodIndx = 0;
}

def newday = compoundValue(1, periodIndx != periodIndx[1], yes);
rec cumeprice = if newday then price else price + cumeprice[1];
rec cumebarnumber = if newday then 1 else 1 + cumebarnumber[1];

plot TWAP = Round(cumeprice / cumebarnumber, 4);

}

plot TWAP = TimeWAP(fundamental(price));
TWAP.AssignValueColor(if TWAP > TWAP[1] then Color.Dark_Green else if TWAP is equal to TWAP[1] then color.gray else Color.Dark_Red);
TWAP.SetStyle(curve.SHORT_DASH);
TWAP.SetLineWeight(2);
TWAP.HideBubble();

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Exit Strategy
NinjaTrader
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
27 thanks
The Program
18 thanks
Battlestations: Show us your trading desks!
18 thanks
  #92 (permalink)
 courier12 
Mumbai India
 
Experience: None
Platform: TradeStation
Trading: Forex
Posts: 39 since Nov 2014
Thanks Given: 58
Thanks Received: 10

Thank you @rmejia .

This is not quite right since it resets after every candle. The TWAP is much smoother, similar to VWAP. Since this indicator calculates every bar, it is quite "jerky" and not smooth


rmejia View Post
Found this one a while back:

 
Code
input price = FundamentalType.HLC3;
input timeFrame = {default Day, Week, Month, Chart};

script TimeWAP {

input price = hlc3;
input timeFrame = {default Day, Week, Month, Chart};

def yyyyMmDd = getYyyyMmDd();
def periodIndx;
switch (timeFrame) {
case DAY:
    periodIndx = yyyyMmDd;
case WEEK:
    periodIndx = Floor((daysFromDate(first(yyyyMmDd)) + getDayOfWeek(first(yyyyMmDd))) / 7);
case MONTH:
    periodIndx = roundDown(yyyyMmDd / 100, 0);
case Chart:
    periodIndx = 0;
}

def newday = compoundValue(1, periodIndx != periodIndx[1], yes);
rec cumeprice = if newday then price else price + cumeprice[1];
rec cumebarnumber = if newday then 1 else 1 + cumebarnumber[1];

plot TWAP = Round(cumeprice / cumebarnumber, 4);

}

plot TWAP = TimeWAP(fundamental(price));
TWAP.AssignValueColor(if TWAP > TWAP[1] then Color.Dark_Green else if TWAP is equal to TWAP[1] then color.gray else Color.Dark_Red);
TWAP.SetStyle(curve.SHORT_DASH);
TWAP.SetLineWeight(2);
TWAP.HideBubble();


Reply With Quote
  #93 (permalink)
 
rmejia's Avatar
 rmejia 
Puerto Rico
 
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441



courier12 View Post
Thank you @rmejia .

This is not quite right since it resets after every candle. The TWAP is much smoother, similar to VWAP. Since this indicator calculates every bar, it is quite "jerky" and not smooth

Where do you see the jerkyness ? Looks very similar to the VWAP

Attached Thumbnails
Click image for larger version

Name:	twap.png
Views:	288
Size:	371.1 KB
ID:	171899   Click image for larger version

Name:	twap2.png
Views:	221
Size:	358.0 KB
ID:	171900   Click image for larger version

Name:	twap3.png
Views:	196
Size:	368.3 KB
ID:	171901  
Reply With Quote
Thanked by:
  #94 (permalink)
 Azrael 
Jurong Singapore
 
Experience: Beginner
Platform: NinjaTrader
Broker: Optimus Futures/Rithmic
Trading: TF
Posts: 72 since Jul 2012
Thanks Given: 39
Thanks Received: 9


optntdr13 View Post
I just wanted to let folks know that if you are looking for something specific, chances are I have it or wrote it and am more than happy to share with any and all. If you would like to have any T.....D......ARK stuff, I have coded almost every single one of them but won't share publically due to the maketstudies goons I will however send via PM or e-mail and am happy to do so.

Just curious, do you have Cory's Volume Stop V7 on thinkscript?

Reply With Quote
  #95 (permalink)
 courier12 
Mumbai India
 
Experience: None
Platform: TradeStation
Trading: Forex
Posts: 39 since Nov 2014
Thanks Given: 58
Thanks Received: 10


rmejia View Post
Where do you see the jerkyness ? Looks very similar to the VWAP

Thank you @rmejia and I apologize for the delay in getting back.

The other day I was looking at "data" (thin blue line) which is hugging price and is jerky.

The dotted white line is VWAP and the dotted red (and green) line is the TWAP which I did not see the other day.

Really appreciate your quick replies. Have a good weekend!

Attached Thumbnails
Click image for larger version

Name:	TWAP vs VWAP.png
Views:	262
Size:	74.2 KB
ID:	172155  
Reply With Quote
  #96 (permalink)
 courier12 
Mumbai India
 
Experience: None
Platform: TradeStation
Trading: Forex
Posts: 39 since Nov 2014
Thanks Given: 58
Thanks Received: 10

Hi:

Does anyone have an indicator which shows the Average Volume for the past "X" days by time of day?

E.g. On say a 30 min chart of the 6E, display the average volume traded from 8-8:30 am GMT for the past 20 days and overlay on today's volume bar.

Thank you,

Reply With Quote
  #97 (permalink)
 aron1234 
brooklyn ny usa
 
Experience: Intermediate
Platform: think or swim
Trading: es
Posts: 233 since Nov 2013
Thanks Given: 404
Thanks Received: 252

hi all
how do I add a moving avg below the chart ?

Reply With Quote
  #98 (permalink)
 shzhning 
Madison, NJ
 
Experience: Intermediate
Platform: CQG/TOS
Broker: Optimus/CQG
Trading: ZN/TN/ES/NQ
Posts: 134 since Jun 2010
Thanks Given: 65
Thanks Received: 112

use declare lower;

see here: https://www.thinkorswim.com

Reply With Quote
Thanked by:
  #99 (permalink)
 courier12 
Mumbai India
 
Experience: None
Platform: TradeStation
Trading: Forex
Posts: 39 since Nov 2014
Thanks Given: 58
Thanks Received: 10

Hi everyone:

Is there an indicator in TOS which will plot last week's high and low on this week's chart?

Thank you,

Reply With Quote
  #100 (permalink)
pilotchilly
Colorado Springs, CO
 
Posts: 1 since Feb 2015
Thanks Given: 0
Thanks Received: 1


I’ve recently developed some custom studies (via ThinkScript) that I want to use for conditional orders. They are derivatives of the standard MACD and the ForceIndex. I copied the script from those studies exactly as my starting point and scripted from there. The MACDPlus allows for a confirmatory buy or sell curve above or below “Avg” expressed as a percentage that a conditional order can be used when “Value” passes above or below those lines. The FACD is a derivative of both ForceIndex in the form of MACD using 2 ForceIndexes of varying lengths. Looking at the charts in ToS, these scripts plot and indicate correctly…showing the conditional buy and sell opportunities with a vertical line based on the 2 optional criteria for each (i.e. a set number OR an amount above/below the slower indicator)

However, the problem I’m having is not with the charts themselves, but rather using the studies I’ve modified to trigger conditional orders. I use the conditional order pop-up to trigger conditional orders based on the studies…and even though it appears through the script that the orders have been placed correctly utilizing the custom study, actual orders have failed to trigger. Can anyone please help me figure out what going so wrong?

BTW, I was going to include links...but since I'm new to the forum, I have to make at least 5 posts first. Any help is still appreciated.

Attached Files
Elite Membership required to download: MACDPlusSTUDY.ts
Reply With Quote
Thanked by:




Last Updated on March 25, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts