Login Page - Create Account

Support Board


Date/Time: Tue, 26 Nov 2024 08:42:36 +0000



Adding comments to a Study Alert condition

View Count: 2180

[2016-07-31 23:13:17]
User360283 - Posts: 504
What is the format for adding comments in the study alert condition?
[2016-08-01 00:36:04]
Sierra Chart Engineering - Posts: 104368
There is no support to put a comment within an Alert Condition formula.

However, if using the Spreadsheet System/Alert study:
https://www.sierrachart.com/index.php?page=doc/SystemsAlerts.php

You can add comments to the cells.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2020-04-27 23:14:35]
User681150 - Posts: 62
i search for 'comment' in the link you provided and it says not found

what do you guys call it? or can you give me a more specific link
[2020-04-28 00:09:14]
Sierra Chart Engineering - Posts: 104368
This is all documented here:
Spreadsheet Menu: Spreadsheet >> Edit Comment
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2021-12-03 00:42:52]
j4ytr4der_ - Posts: 938
Just in case anyone else is still looking for a way to comment their code...

I'm sure what the OP was asking for, is what I was also wanting: The ability to comment my code (not an Excel-style comment, which is useless IMO). Some of my work in spreadsheets has gotten quite complex, with much logic and nesting and indenting to the point that I must develop in a decent text editor and copy/paste the results into the spreadsheet. I really wanted a way to comment the code, so I came up with this approach:

IF(REM="This is a comment...","",""),

Stick that line anywhere you like that's valid within your code. I can't speak to what sort of performance hit this might cause in your sheets, and maybe there's a way to optimize it for performance. All I know for sure is that this line will do nothing, but give you a nice clear visual comment in your code. Can always be pulled out for production use.

Hope it helps someone!
Date Time Of Last Edit: 2021-12-03 00:46:17
[2021-12-03 00:45:50]
j4ytr4der_ - Posts: 938
And no sooner do I post this, than I encounter a place where adding it has broken the formula. Can't really see why it has worked for me up to this point and now does not here. Anyway, in case it's helpful... there it is.

EDIT: Ah of course, it needs to go inside an AND block, like so:

=IF(REM="Name of my code block","",IF(
AND(
IF(REM="Some formula description","",""),
ID0.SG2@3 - ID0.SG3@3 >= J21,
IF(REM="Another formula description","",""),
ID102.SG1@3 = 0,
IF(REM="And yet another...","",""),
ID102.SG3@3 > ID102.SG2@3,
),
ID0.SG2@3,
0
))

Date Time Of Last Edit: 2021-12-03 01:00:10
[2023-12-19 16:34:05]
j4ytr4der_ - Posts: 938
BTW the above commenting technique can be greatly simplified to:

REM<>"Insert comment here",

Just keep in mind when it needs to be included in an AND block, and when it doesn't. Since it will always evaluate to true, it gets ignored and continues.
[2023-12-21 00:07:50]
User61168 - Posts: 403
Please convert this thread to "User Discussion" so others could contribute further to their best practice approach

Here's my "coding standards" for simple alerts only. It incorporates the following:
1) comments at the collection level
2) comments at the line/logic level
3) Allows you to enable and disable lines of code quickly
4) maintain entire codeset in notepad++ for a quick cut/paste
5) allows version control specific to different entry and exit criteria
6) allows you to build an entire coding library for future cut/pastes starting from a baseline set of services.
7) allows you to disable all Alert formula studies by setting ID1.SG1 line study to a non-zero value

ID1.SG1 is a simple "Line" study that is present in all my study collections. Go to the Alert tab of this study and enter freeform text on what the collection does, which Sim account you used, cut/paste trading stats, enter chart type used etc etc

For each alert condition/formula, use the following format (during development phase one as this code is not efficient for live trading!)

AND(ID1.SG1=0,OR(
  OR(ID1.SG1="Buy&Sell-ExitOnTick:@DailyMaxPrpfit-ALWAYS",AND(ID1.SG1=0,logic goes here... ))
  ,OR(ID1.SG1="Buy&Sell-ExitOnTick:@DailyMaxLoss-ALWAYS",AND(ID1.SG1=0,logic goes here... ))
  OR(ID1.SG1="Buy&Sell-ExitOnTick:@DailyMaxPrpfit-WhenCondition1Met",AND(ID1.SG1=0,logic goes here... ))
  ,OR(ID1.SG1="Buy&Sell-ExitOnTick:@DailyMaxLoss-WhenCondition1Met",AND(ID1.SG1=0,logic goes here... ))
  
  ,OR(ID1.SG1="Buy&Sell-ExitOnTick:SL-xxx-xxx-xxx",AND(ID1.SG1=0,logic goes here... ))
  ,OR(ID1.SG1="Buy&Sell-ExitOnTick:TP-xxx-xxx-xxx",AND(ID1.SG1=0,logic goes here... ))
  ,AND(ID1.SG1=0888,OR(
   OR(ID1.SG1="Buy&Sell-ExitOnTick:SL-xxx-v1",AND(ID1.SG1=0999,logic goes here... ))
   ,OR(ID1.SG1="Buy&Sell-ExitOnTick:SL-xxx-v2",AND(ID1.SG1=0999,logic goes here... ))
   ,OR(ID1.SG1="Buy&Sell-ExitOnTick:TP-xxx",AND(ID1.SG1=0999,logic goes here... ))
   ))
))


0888 - comments entire block of code
0999 - comments for single logic/code execution

Edit: Line study allows a string value without throwing syntax errors in alert formula at execution.... a blessing in disguise :-))))))))))))
Date Time Of Last Edit: 2023-12-21 00:19:35
[2023-12-21 00:27:55]
User61168 - Posts: 403
and one more tip:
How do you define "Global Input Parameters" for your algo?
use case: manual setting of global variables for Daily Max Profit/Loss
Use the "Line" study to define your input parameters and reference the line study in alert formula.... bingo!

And, if you want a mathematically calculated "global variable", use the awesome spreadsheet formula study to act as your global variable....bingo!
use case: Using Daily Max Profit as a percent of Session Range
Date Time Of Last Edit: 2023-12-21 00:28:18
[2023-12-21 13:13:07]
j4ytr4der_ - Posts: 938
Very clever tip about Line not throwing an error... how strange and wonderful! =) This commenting method is too difficult for me to read or debug personally but it's cool to see someone else has come up with a solution as well!
[2023-12-21 22:46:21]
User61168 - Posts: 403
"Necessity is the mother of most innovations and inventions" lol. This framework allows me to save 100s of entry and exit strategies in a single study collection in a single chart and in a single chartbook without taking too much hit on CPU performance.

I used to have 100s of collection files and another 100s for version control. I got rid of the practice of saving study collections into files and now just save everything in the chartbook. It's a beautiful stress-free model to handle changes through the SDLC from DEV to TEST to Production life cycle installations of SC. I love simplification!

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account