Support Board
Date/Time: Wed, 27 Nov 2024 23:30:29 +0000
[Programming Help] - Programming Help - Display of cumulative PnL in points
View Count: 634
[2023-06-17 02:12:07] |
User61168 - Posts: 403 |
Hi, I am embarrassed to ask why is this simple logic is not working. Objective: To cumulatively keep a running count of my total (realized) PnL in Points across all bars loaded in my chart. This is similar to Account Balance in points reflecting PnL from day1 of the date range selected in chart settings Studies in use: ID10.SG1=Trading Daily Profit/Loss, ID19.SG1=Bar Numbering (resets at start of session to value=1), ID18.SG1=Spreadsheet Formula Study to calculate running Account Balance in Points (i.e. realized PnL) as of Yesterday's closing session. All studies are displayed in Chart region2 Formula: IF(ID19.SG1=1,ID10.SG1[-1]+ID18.SG1[-1],ID18.SG1[-1]) Date Time Of Last Edit: 2023-06-17 02:13:14
|
[2023-06-17 03:56:44] |
Sawtooth - Posts: 4120 |
Try this: =IF(ID19.SG1=1,0,IF(ID19.SG1>1,ID10.SG1+ID18.SG1[-1],ID18.SG1[-1])) |
[2023-06-17 06:04:12] |
User61168 - Posts: 403 |
Thanks Tom. It's printing 100K+ points. At each Bar in today's session, I want this formula to only print Yesterday's cumulative/YTD PnL (i.e. EndOfDay "Account Balance" in Points...same value for each bar). Then, at the last bar of today's session (or start of tomorrow's session), I want to do the addition of today's pnl to generate the new end of day account balance.
Date Time Of Last Edit: 2023-06-17 06:04:47
|
[2023-06-17 13:32:22] |
Sawtooth - Posts: 4120 |
Do you want yesterday's YearToDate PnL to print all day in the current day, then sum the current day's PnL to yesterday's YTD PnL in the last bar of the current day?
Date Time Of Last Edit: 2023-06-17 14:34:57
|
[2023-06-17 20:45:40] |
User61168 - Posts: 403 |
Objective is to implement money management (Compounding) solution by setting a daily profit target to a % of YTD balance instead of a fixed $ or point value. To achieve this, I need a running counter of cumulative sum of all Daily PnL from the start of the chosen date range setting used under Chart Settings> "Date Range From YYYY-MM-DD" field. Ideally, I want the summation to occur on the first tick of first bar of the current day at session start instead of last bar of yesterday's chart. This way, I can account for morning and evening sessions as well if I need to. Currently, I am only trading 9:30 to 16:00 NYSE session and using Renko chart type with new bar at session open setting. EDIT: I am confirming I need the calculation to be done on the first tick of each morning/evening session. This is required because the Daily PnL Study ID10.SG1 is not printing accurate pnl value on the last bar of previous session if I have any fills made on the last bar (I notice this in market replay or not sure if this is a bug) Date Time Of Last Edit: 2023-06-17 20:52:04
|
[2023-06-17 22:56:48] |
Sawtooth - Posts: 4120 |
I need a running counter of cumulative sum of all Daily PnL from the start of the chosen date range setting used under Chart Settings> "Date Range From YYYY-MM-DD" field.
Use the Trading: Closed Profit/Loss study.(IMO this study should be named Trading: Cumulative Profit/Loss). The challenge will be to not let it display its cumulative value until the following day's open. Try this in the Spreadsheet Formula study's Formula Field: =IF(BARDATE>BARDATE[-1],ID20.SG1,ID21.SG1[-1]) where ID20 is the Trading: Closed Profit/Loss study, and ID21 is this Spreadsheet Formula study. |
[2023-06-18 03:49:24] |
User61168 - Posts: 403 |
Thanks for your time Tom. I really appreciate it. This simple solution will work for me.
|
To post a message in this thread, you need to log in with your Sierra Chart account: