ThinkScript - MM-PS Code/Logic Question... - ThinkOrSwim | futures io social day trading
futures io futures trading

ThinkScript - MM-PS Code/Logic Question...
Updated: Views / Replies:572 / 1
Created: by netarchitech 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

Thread Tools Search this Thread

ThinkScript - MM-PS Code/Logic Question...

  #1 (permalink)
Trading for Fun
Futures Experience: Intermediate
Platform: TOS
Favorite Futures: Stocks, ETFs
Posts: 50 since Dec 2011
Thanks: 20 given, 9 received

ThinkScript - MM-PS Code/Logic Question...

Despite working with thinkorswim for over 10 years now, I am obviously still a novice thinkScripter when it comes to crafting custom solutions. With that said, I've been trying to write my own "study", really it's more of a "dashboard" of sorts, to address my need to keep Money Management and Position Sizing front and center when considering a trade...
declare lower;

input priceLo = low;
input priceHi = high;
input price = close;
input length = 10;
input averageType = AverageType.WILDERS;
input multiplier = 2.0;
input accountSize = 100000;
input accountRiskTolerance = 0.015;

def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
def ATRmultiple = multiplier * ATR;
#def avgPercentMove = (ATR / price) * 100;
def longStopLoss = priceLo - ATRmultiple;
def shortBuyCover = priceHi + ATRmultiple;
def tradeRisk = accountSize * accountRiskTolerance;
def sharesBuyBorrow = tradeRisk / ATRmultiple;
def tradeSizer = (tradeRisk / ATRmultiple) * price; 

AddLabel(yes, "Current Volatility: " + Round(ATR, 2), CreateColor (255, 255, 255));
#AddLabel(yes, "Average Move: " + Round(avgPercentMove, 2) + "%", CreateColor (255, 255, 255));
AddLabel(yes, "Total Per Trade Risk Limit : " + "$ " + Round(tradeRisk, 2), CreateColor (255, 255, 255));
AddLabel(yes, "Shares to Buy or Borrow: " + Round(sharesBuyBorrow, 0), CreateColor (255, 255, 255));
AddLabel(yes, "Trade Size: " + "$ " + Round(tradeSizer, 2), CreateColor (255, 255, 255));
AddLabel(yes, "If Going LONG -> Place Stop at " + Round(longStopLoss, 2), CreateColor (255, 255, 255));
AddLabel(yes, "If Going SHORT -> Place Cover at " + Round(shortBuyCover, 2), CreateColor (255, 255, 255));

While the code basically does provide some helpful information, there are a few inconsistencies:
1. Admittedly, this code employs both the Fixed Fraction and ATR Volatility position sizing strategies...I would prefer to follow the ATR strategy only if possible...
2. Somehow the calculation for "tradeSizer" on occasion exceeds "accountSize"...

Any feedback, thoughts or suggestions to improve this code would be greatly appreciated...

Thanks in advance...

Reply With Quote
  #2 (permalink)
Trading for Fun
Futures Experience: Intermediate
Platform: TOS
Favorite Futures: Stocks, ETFs
Posts: 50 since Dec 2011
Thanks: 20 given, 9 received

While I am still trying to sort out the code in terms of Fixed Fraction vs. ATR Volatility, I thought I would post the solution I came up with to resolve the "tradeSizer" exceeding "accountSize" issue in the hopes it might prove useful/helpful to someone else somewhere along the way...

AddLabel(yes, if tradeSizer < accountSize then "Trade Size: " + "$ " + Round(tradeSizer, 2) else "Trade Size: Exceeds available funds", CreateColor (255, 255, 255));

Reply With Quote


futures io > > > > ThinkScript - MM-PS Code/Logic Question...

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Wyckoff Hunting for Great Risk/Reward Ratio w/Gary Fullett

Elite only

Digging into the Details of iSystems w/Stage 5 & iSystems

Jun 5

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with thinkscript code vonso ThinkOrSwim Programming 1 October 16th, 2015 06:59 PM
Thinkscript - Code/Logic Question... netarchitech ThinkOrSwim 4 August 31st, 2015 05:13 PM
Looking to hire someone to write thinkscript code aehartle ThinkOrSwim Programming 2 August 26th, 2015 05:31 PM
Thinkscript logic question strategynode ThinkOrSwim Programming 0 January 5th, 2015 12:28 PM
My MM / PositionSize Code sagetrade EasyLanguage Programming 10 August 11th, 2013 03:53 PM

All times are GMT -4. The time now is 04:57 PM.

Copyright © 2018 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
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 2018-05-21 in 0.06 seconds with 19 queries on phoenix via your IP