NexusFi: Find Your Edge


Home Menu

 





Calculating trades in R


Discussion in Trading Journals

Updated
      Top Posters
    1. looks_one Kennard with 4 posts (2 thanks)
    2. looks_two SMCJB with 2 posts (2 thanks)
    3. looks_3 matthew28 with 2 posts (6 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
      Best Posters
    1. looks_one matthew28 with 3 thanks per post
    2. looks_two lutzs with 2 thanks per post
    3. looks_3 SMCJB with 1 thanks per post
    4. looks_4 Kennard with 0.5 thanks per post
    1. trending_up 3,009 views
    2. thumb_up 13 thanks given
    3. group 4 followers
    1. forum 10 posts
    2. attach_file 0 attachments




 
Search this Thread

Calculating trades in R

  #1 (permalink)
Kennard
Sydney,NSW,Australia
 
Posts: 5 since Feb 2013
Thanks Given: 5
Thanks Received: 2

Hello,

I am recording my trades in google sheets and include usual data like open price, close price profit/loss in pips etc but would like to also start recording my profit/loss in R.

I am trying to find information how to calculate it automaticaly in Google sheets or Excel but so far no luck.

If anybody here is willing to help could you please point me to a website or information how to use calculation formula to calculate my trades in R?
Thanks a lot.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Quant vue
Trading Reviews and Vendors
What broker to use for trading palladium futures
Commodities
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
 
  #3 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,049 since Dec 2013
Thanks Given: 4,388
Thanks Received: 10,207


You mention R, Google Sheets and then Excel. R is statistical heavy scripting programming language and nothing like a spreadsheet. There are some R packages designed especially for financial modeling of trading (QuantMod being the most popular I think) but I don't think that's what your looking for. You could perform the calculations you want in R, but I think it would take a lot more work than many better available options (like spreadsheets). What exactly are you trying to automate? If you really are determined to use R, RStudio is a good place to start.

Reply With Quote
Thanked by:
  #4 (permalink)
 
matthew28's Avatar
 matthew28 
United Kingdom
Elite_Member
 
Experience: Beginner
Platform: Bookmap
Broker: Stage 5, Rithmic
Trading: US Equity Index Futures
Posts: 1,250 since Sep 2013
Thanks Given: 3,500
Thanks Received: 2,532

Or if you mean the Van Tharp version of 'R' for Risk multiples, then just divide the profit/loss of a trade by the risk per trade.
So if a trade made $200 and the total risk was $100, the trade has an R multiple of 2R. If you risked $200 and took a full stop for -$200 then that is a -1R trade.
Google "Van Tharp R multiples" will give you lots more if that's what you want.

Or sometimes people who aren't using firm stops (except maybe a hard safety stop just in case of platform or internet problems), could use the Maximum Adverse Excursion (MAE), of a trade instead of initial risk. So if trading two contracts say on the ES with an example trade which goes two ticks negative then gets a scale out at one point and the second contract at two points. That would be $50 Risk/MAE in total and $150 profit, so a 3R trade.

You do not win as a trader, you just get to play again the next day. If that game doesn’t appeal to you then you should not trade. Gary Norden
Reply With Quote
  #5 (permalink)
 
Leon of Pizza's Avatar
 Leon of Pizza 
St. Louis
 
Experience: Beginner
Platform: thinkorswim, NT8
Trading: equity and fx futures and options
Posts: 137 since Sep 2013
Thanks Given: 99
Thanks Received: 192

I prefer to collect a sample of risk experience measured in MAE.

R, as I understand it, can be determined by a single bar in a pattern and seems more arbitrary. maybe because its more variable. Whereas the pattern as a whole will produce a distribution of MAEs that can be used to set risk behind the fat part of the curve. Same goes for target setting.

Reply With Quote
Thanked by:
  #6 (permalink)
Kennard
Sydney,NSW,Australia
 
Posts: 5 since Feb 2013
Thanks Given: 5
Thanks Received: 2


matthew28 View Post
Or if you mean the Van Tharp version of 'R' for Risk multiples, then just divide the profit/loss of a trade by the risk per trade.
So if a trade made $200 and the total risk was $100, the trade has an R multiple of 2R. If you risked $200 and took a full stop for -$200 then that is a -1R trade.
Google "Van Tharp R multiples" will give you lots more if that's what you want.

Thanks a lot to all of you guys.

As Mathew28 pointed I am after simple calculation of R when entering my open, SL and TP prices in google sheets.

I know this site is mostly about futures but I trade mainly forex so I was hoping to find something to help me and simplify whole process of entering trades and recording R.

For example if I enter buy trade
Entry price : 1.3000
SL : 1.2900
TP: 1.3100

...and then also have "R"column

Then in case the price will hit TP and I enter 1.3100 in "close price" ideally it would automaticaly calculate my "R".

Now because I dont have this formula and dont know how to do it I have to manually calculate as Matthew28 suggested above - divide profit/loss by risk.

Reply With Quote
Thanked by:
  #7 (permalink)
 lutzs 
Dresden Saxony
 
Experience: Intermediate
Platform: TWS AgenaTrader
Trading: CL GC NQ HG
Posts: 1 since Dec 2017
Thanks Given: 0
Thanks Received: 1


Kennard View Post
Thanks a lot to all of you guys.

As Mathew28 pointed I am after simple calculation of R when entering my open, SL and TP prices in google sheets.

I know this site is mostly about futures but I trade mainly forex so I was hoping to find something to help me and simplify whole process of entering trades and recording R.

For example if I enter buy trade
Entry price : 1.3000
SL : 1.2900
TP: 1.3100

...and then also have "R"column

Then in case the price will hit TP and I enter 1.3100 in "close price" ideally it would automaticaly calculate my "R".

Now because I dont have this formula and dont know how to do it I have to manually calculate as Matthew28 suggested above - divide profit/loss by risk.

In this case it is simple (TP-Entry)/(Entry-SL)

(TP- Entry) is your profit or loss, (Entry - SL) is your risk. This is only for long trades, for short trades it is
(Entry-TP) /(SL-Entry).

It is better to say Exit to your TP.

Reply With Quote
Thanked by:
  #8 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,049 since Dec 2013
Thanks Given: 4,388
Thanks Received: 10,207

Guess I missed the boat on this one!

Reply With Quote
  #9 (permalink)
Kennard
Sydney,NSW,Australia
 
Posts: 5 since Feb 2013
Thanks Given: 5
Thanks Received: 2


matthew28 View Post
So if a trade made $200 and the total risk was $100, the trade has an R multiple of 2R. If you risked $200 and took a full stop for -$200 then that is a -1R trade.

Are my calculations correct?

124 profit / 100 risk -> 1.24R
-58/85 -> -0.68R
278/100 -> 2.78R
-75/130 -> -0.57R

Reply With Quote
  #10 (permalink)
 
matthew28's Avatar
 matthew28 
United Kingdom
Elite_Member
 
Experience: Beginner
Platform: Bookmap
Broker: Stage 5, Rithmic
Trading: US Equity Index Futures
Posts: 1,250 since Sep 2013
Thanks Given: 3,500
Thanks Received: 2,532



Kennard View Post
Are my calculations correct?

124 profit / 100 risk -> 1.24R
-58/85 -> -0.68R
278/100 -> 2.78R
-75/130 -> -0.57R

Yes those are all right. So along with the Profit/Loss column you already have in your spreadsheet, just add a couple of extra columns. One where you manually input the Risk in dollars for the trade and one with a simple calculation that divides the Profit/Loss column with the Risk column.
The only thing to be aware of is whether your trade results P/L are per contract or for the total trade. ie if you enter two lots say in the ES with a two point stop and you make two points with one contract and four points on the second contract, does your platform list that as one trade (each contract separate), or as one trade. If individual contracts your risk for each contract would be $100 (two point stop at $50 per point on the ES), but for the trade as a whole your risk column would be $200 for the two contracts.

You do not win as a trader, you just get to play again the next day. If that game doesn’t appeal to you then you should not trade. Gary Norden
Reply With Quote
Thanked by:




Last Updated on March 4, 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