Beginner's Guide to MultiCharts Programming: Difference between revisions
From MultiCharts
Beginner's Guide to MultiCharts Programming (view source)
Revision as of 16:24, 26 January 2022
, 26 January 2022no edit summary
No edit summary |
mNo edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This article highlights some PowerLanguage formatting tips, as discussed in a forum topic | This article highlights some PowerLanguage formatting tips, as discussed in a forum topic [http://www.multicharts.com/discussion/viewtopic.php?f=1&t=9792 MC Programing - What I’ve learned]. | ||
== Layout == | == Layout == | ||
Some tips regarding the layout of a coding script. | Some tips regarding the layout of a coding script. | ||
=== General layout tips === | |||
Some general layout tips are: | |||
* Use tabs and empty lines to make the code better readable - don't forget: if you want to edit your script a half-year from now, you'll still need to be able to comprehend it. | |||
* Make use of comments. | |||
* While it isn't needed in EasyLanguage to use parentheses ( & ) after an 'if' statement, it makes the code better readable and prevents errors. | |||
* Make your code explicit. For example, instead of writing ''if LastBarOnChart then'' write ''if (LastBarOnChart = True) then''. While both statements work, the latter makes it easier to debug and makes the implicit assumptions you're making explicit. | |||
=== Description === | === Description === | ||
Line 37: | Line 45: | ||
==== Other Input formatting suggestions ==== | ==== Other Input formatting suggestions ==== | ||
* Start[[IntraBarPersist]] variables with a captial letter (e.g. ''MyDefinedVariable'') and start regular variables with a normal letter (e.g. ''myDefinedVariable''). This helps to keep track of which variables are regular and which ones are IntraBarPersist. | * Start [[IntraBarPersist]] variables with a captial letter (e.g. ''MyDefinedVariable'') and start regular variables with a normal letter (e.g. ''myDefinedVariable''). This helps to keep track of which variables are regular and which ones are IntraBarPersist. | ||
== If else statements == | == If else statements == | ||
When writing [[ | When writing [[:Category:Comparisons and Loops|If Else statements]] the use of '''tabs''' is highly recommended. | ||
Some examples of poor formatting would be: | Some examples of poor formatting would be: | ||
Line 97: | Line 105: | ||
== References == | == References == | ||
You can find useful information about Power Language coding [[Additional Information Sources | here]]. |