Login Page - Create Account

Support Board


Date/Time: Thu, 28 Nov 2024 10:51:34 +0000



Post From: How to display Daily Breakeven Line??

[2023-05-13 01:28:38]
Sawtooth - Posts: 4120
In essence, I need to draw a line at C+/- "NPL" (the value displayed in the trade ticket window) automatically when a trade is open.
I'm not sure this can be done without a spreadsheet study because you need to find the current bar, and make every other value a persistent absolute reference from that bar.

(Note: Despite it's name, the Spreadsheet Formula study is not a spreadsheet study. It uses Alert syntax, not spreadsheet syntax.)

Don't let the spreadsheet study syntax intimidate you.
You've written a complex Alert formula, so you can readily use a spreadsheet study.

C= E3
ID7.SG1 = ID7.SG1@3
ID9.SG1 = ID9.SG1@3
ID10.SG1 = ID10.SG1@3

The @3 is the row number, and row 3 is the current bar, with previous bars in rows below.
e.g, the previous bar is @4, instead of [-1]

So, try this:
Add the Spreadsheet Study study
- Give it a name in the Spreadsheet Name field
- Set the Chart Region to 1
- Click OK, a spreadsheet sheet will appear.
- Use this formula in cell K3:
=IF(ID7.SG1@$3=0,0,IF(ID7.SG1@3>0,E$3+(E$3-ID9.SG1@$3)*ID7.SG1@$3+ID10.SG1@$3,K4))
- Use this formula in cell L3:
=IF(ID7.SG1@$3=0,0,IF(ID7.SG1@3<0,E$3+(ID9.SG1@$3-E$3)*ABS(ID7.SG1@$3)+ID10.SG1@$3,L4))

These are your formulas, converted to spreadsheet syntax, with absolute references (using $) to the current bar, and made persistent by using the IF function referring to the previous value (K4/L4), with an added IF to clear the line if flat.

Column K is SG1, Column L is SG2. Set the line colors on the Subgraphs tab.
Date Time Of Last Edit: 2023-05-13 02:26:10