NexusFi: Find Your Edge


Home Menu

 





Trade Calculator


Discussion in ThinkOrSwim

Updated
    1. trending_up 1,597 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
netarchitech
NY, NY
 
Posts: 68 since Dec 2011
Thanks Given: 27
Thanks Received: 19

Given my rather limited skills in terms of scripting/programming, I've been trying to construct a trade calculator. As a result, please find below what I have put together so far:

 
Code
input ATRlength = 10; # default length = 14 - can range anywhere from 6 to 21
def priceC = close;
input averageType = AverageType.WILDERS;
input ATRmultiplier = 1.50; # default multiplier = 2.0 - can range anywhere from 1.0 to 5.0
def ATR = MovingAverage(averageType, TrueRange(high, close, low), ATRlength);
def avgDailyMovement = (ATR / priceC) * 100;
input profitMultiplier = 3.00;

input AccountEquity = 100000.00;
input PercentRiskPerTrade = 0.005;
def EquityRiskPerTrade = AccountEquity * PercentRiskPerTrade;

def SharesToBuy = (EquityRiskPerTrade / (avgDailyMovement * ATRmultiplier));
def currentPositionSize = SharesToBuy * priceC;

def stopAmount = avgDailyMovement * ATRmultiplier;
def longSellStop = priceC - stopAmount;
def shortBuyStop = priceC + stopAmount;

def profitTarget = avgDailyMovement * profitMultiplier;
def longSellLimit = priceC + profitTarget;
def shortBuyLimit = priceC - profitTarget;

AddLabel(yes, "Shares to Buy: " + Round(SharesToBuy, 0), CreateColor (255, 255, 255));
AddLabel(yes, "Position Size: " + Round(currentPositionSize, 2), CreateColor (255, 255, 255));

AddLabel(yes, "Long SELL Stop: " + Round(longSellStop, 2), CreateColor (255, 255, 255));
AddLabel(yes, "Long SELL Limit: " + Round(longSellLimit, 2), CreateColor (255, 255, 255));

AddLabel(yes, "Short BUY Stop: " + Round(shortBuyStop, 2), CreateColor (255, 255, 255));
AddLabel(yes, "Short BUY Limit: " + Round(shortBuyLimit, 2), CreateColor (255, 255, 255));

I'm happy to say it works, just not necessarily as intended to some degree.

Depending on what timeframe I'm on, I get a wide degree of suggested trade numbers to "plug" in to a current trade, as shown below:

Here's the current quote:


5 min Calculator:


Hourly Calculator:


Daily Calculator:


Weekly Calculator:


Monthly Calculator:



The "farther out" you go, the less it suggests to buy and further suggests very wide stops. Whereas, the "closer in" you go, the more it suggests to buy and further suggests very tight stops. Also, depending on the Stock/ETF selected, it will sometimes recommend very large purchases that far exceed the size of the account (AccountEquity)...

Thanks in advance for any help/insights/feedback...

Reply With Quote
Thanked by:




Last Updated on October 18, 2018


© 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 - Sitemap - Downloads - Top
no new posts