Parser functions are a powerful feature of MediaWiki that allow you to perform calculations, manipulate strings, and control the output of your wiki pages dynamically. They are essentially functions that operate on the wikitext before it is rendered into HTML. This allows you to create complex and reusable content, automate tasks, and add a level of interactivity to your wiki. This guide will serve as a beginner-friendly introduction to parser functions, covering their syntax, common uses, and some examples.
== What are Parser Functions?
At their core, parser functions are snippets of code embedded within your wikitext that are evaluated by the MediaWiki parser. The result of the evaluation is then substituted into the page. They are denoted by a hash symbol (`#`) followed by the function name and any necessary arguments, enclosed in double curly braces (`Template:...`).
For example: `{{#title:My Page}}` would output "My Page" with the first letter capitalized.
Parser functions are *not* programming languages in the full sense. They have a limited set of operations, primarily focused on text manipulation, mathematical calculations, and date/time handling. They are designed for presentation and formatting, not for complex logic or data processing. For more complex tasks, consider using Extensions.
== Basic Syntax
The general syntax of a parser function is:
`{{#function_name: argument1 | argument2 | ...}}`
`#`: Indicates that this is a parser function call.
`function_name`: The name of the function you want to use (e.g., `title`, `if`, `expr`). See the section on [Common Parser Functions](#common_parser_functions) for a list.
`argument1`, `argument2`, etc.: The inputs to the function.
**Other parser function calls:** You can nest parser functions within each other.
**Empty arguments:** Represented by `|` without a value.
== Common Parser Functions
Here's a breakdown of some of the most commonly used parser functions. This is not an exhaustive list, but it provides a good starting point.
**`#title`**: Formats a string as a title, capitalizing the first letter of each word. Useful for creating consistent headings.
```wiki
{{#title:my awesome page}}
```
**`#if`**: A conditional statement. If the first argument evaluates to a non-empty string, it outputs the second argument; otherwise, it outputs the third argument (if provided).
```wiki
{{#if:Parser functions | This is the page Parser functions | This page does not exist}}
```
**`#ifeq`**: Checks if two arguments are equal. Outputs the third argument if they are equal, otherwise outputs the fourth argument (if provided).
```wiki
{{#ifeq:Parser functions | Help:Parser functions | You are on the Parser functions help page! | You are not on the Parser functions help page.}}
```
**`#ifexist`**: Checks if a page exists. Outputs the second argument if the page exists, otherwise outputs the third argument (if provided).
```wiki
{{#ifexist:Help:Parser functions | This page exists. | This page does not exist.}}
```
**`#expr`**: Evaluates a mathematical expression. Supports basic arithmetic operations (+, -, *, /, %), as well as some functions. This is critical for Technical Analysis calculations.
```wiki
{{#expr: 2 + 2}}
{{#expr: 10 / 3}}
```
For more advanced calculations involving Moving Averages or Bollinger Bands, `#expr` is essential.
**`#time`**: Formats a date and time according to a specified format string. The first argument is the date/time string to format (often `20250703231730`), and the second argument is the format string. See [Manual:Time and date parameters](https://www.mediawiki.org/wiki/Manual:Time_and_date_parameters) for format string details. This is vital for tracking Trend Duration.
**`#formatdate`**: Similar to `#time`, but provides more flexibility and pre-defined formats.
```wiki
long
```
**`#stringlength`**: Returns the length of a string.
```wiki
{{#stringlength:Hello World}}
```
**`#subst`**: Substitutes a template into the current page. Unlike using a template directly (e.g., `
Template:Infobox Trading Strategy
This article details the use of the `Template:Infobox Trading Strategy` template in MediaWiki. This template is designed to standardize the presentation of information about various trading strategies within a wiki dedicated to financial markets, technical analysis, and trading. It provides a consistent and easily navigable format for users to understand the key characteristics, mechanics, and performance metrics of different strategies. This is crucial for a knowledge base that aims to be both comprehensive and user-friendly.
The primary purpose of `Template:Infobox Trading Strategy` is to create a concise, informative summary of a trading strategy on a dedicated page. This allows readers to quickly grasp the core concepts without needing to read lengthy, detailed explanations. It also facilitates comparison between different strategies. The template focuses on providing structured data, aiding in research and understanding, and promoting a standardized approach to documenting strategies. Without such a template, information could be scattered and inconsistent, making it difficult for newcomers to learn and experienced traders to quickly reference key details.
Usage
To use the template, simply include `Template:Infobox Trading Strategy` at the beginning of a page dedicated to a trading strategy. The template uses a series of parameters to populate the infobox with specific information. Here's a breakdown of each parameter:
`strategy_name`: (Required) The name of the trading strategy. This should be the common name used to refer to the strategy (e.g., "Moving Average Crossover", "Fibonacci Retracement").
`image`: (Optional) A URL to an image illustrating the strategy, such as a chart with the strategy applied. The image should be relevant and informative. Use the `File:ImageName.png` format.
`image_caption`: (Optional) A caption for the image, providing context or explaining what the image depicts.
`type`: (Optional) The category of trading strategy. Examples include "Trend Following", "Mean Reversion", "Breakout", "Scalping", "Day Trading", "Swing Trading", "Position Trading", "Arbitrage", "Algorithmic Trading". Use a link to a relevant wiki page if one exists (e.g., `Trend Following`).
`asset_class`: (Optional) The asset class the strategy is best suited for. Examples include "Forex", "Stocks", "Cryptocurrencies", "Commodities", "Options", "Futures". Use a link where appropriate (e.g., `Forex`).
`timeframe`: (Optional) The recommended timeframe for using the strategy (e.g., "5-minute", "15-minute", "Daily", "Weekly").
`indicators`: (Optional) A comma-separated list of technical indicators used in the strategy. Link to relevant indicator pages where available (e.g., "Moving Average", "RSI", "MACD", "Bollinger Bands").
`risk_level`: (Optional) The level of risk associated with the strategy. Options include "Low", "Moderate", "High", "Very High".
`profit_potential`: (Optional) The potential profit level of the strategy. Options include "Low", "Moderate", "High", "Very High".
`complexity`: (Optional) The complexity of the strategy. Options include "Simple", "Intermediate", "Complex".
`entry_rules`: (Optional) A brief description of the rules for entering a trade. Be concise.
`exit_rules`: (Optional) A brief description of the rules for exiting a trade. Be concise.
`stop_loss`: (Optional) How stop-loss levels are determined (e.g., "Percentage based", "Support/Resistance", "ATR").
`take_profit`: (Optional) How take-profit levels are determined (e.g., "Risk/Reward Ratio", "Resistance Level", "Fibonacci Extension").
`backtesting_results`: (Optional) A summary of backtesting results, including win rate, average profit per trade, and maximum drawdown. Be specific and provide dates for the backtest.
`notes`: (Optional) Any additional notes or considerations regarding the strategy.
`see_also`: (Optional) A comma-separated list of related strategies or concepts. Link to relevant wiki pages.
Example
Here's an example of how the template might be used to document a "Moving Average Crossover" strategy:
The Moving Average Crossover is a widely used trend-following strategy... (rest of the article content)
```
Advanced Usage & Considerations
**Consistent Formatting:** Maintain consistency in the information provided for each strategy. This makes it easier to compare strategies and identify potential opportunities.
**Accuracy:** Ensure the information provided is accurate and up-to-date. Backtesting results should be clearly documented and the methodology explained.
**Objectivity:** Present the strategy objectively, highlighting both its strengths and weaknesses. Avoid making overly optimistic claims.
**Image Quality:** Use high-quality images that are clear and easy to understand. Ensure the images are properly labeled and captioned.
**Regular Updates:** Trading strategies can evolve over time. Regularly review and update the information in the infobox to reflect any changes.
**Backtesting Details:** When providing backtesting results, include details such as the backtesting period, the asset tested, the commission costs, and the slippage assumptions.
**Risk Disclosure:** Always include a disclaimer stating that trading involves risk and that past performance is not indicative of future results.
**Parameter Descriptions:** When describing parameters like `stop_loss` and `take_profit`, be specific about how those levels are calculated. For example, instead of simply saying "Percentage based," specify "2% below entry price."
**Alternative Strategies:** In the `see_also` section, consider linking to alternative strategies that address the same market conditions or trading goals.
**Nested Templates:** While not directly part of this template, consider using nested templates for complex indicators or concepts to avoid cluttering the infobox.
Troubleshooting
**Infobox Not Rendering:** If the infobox is not rendering correctly, double-check the syntax of the template tags and parameters. Ensure that all required parameters are present and that there are no typos.
**Image Not Displaying:** If the image is not displaying, verify that the image file exists and that the URL is correct. Also, check the image permissions to ensure that it is publicly accessible.
**Incorrect Formatting:** If the formatting is incorrect, review the MediaWiki syntax for the template and ensure that it is being used correctly. Pay attention to whitespace and special characters.
**Parameter Conflicts:** If you encounter parameter conflicts, ensure that you are not using the same parameter name multiple times.
Future Enhancements
**Automated Backtesting Integration:** Integrate the template with automated backtesting tools to automatically populate the `backtesting_results` parameter.
**Performance Visualization:** Add a feature to dynamically generate charts and graphs based on the backtesting results.
**Strategy Comparison Tool:** Develop a tool that allows users to compare multiple strategies side-by-side based on the information in the infoboxes.
**User-Contributed Data:** Allow users to contribute data and feedback on strategies, subject to moderation.
**Dynamic Risk Assessment:** Implement a dynamic risk assessment feature that calculates the risk level of a strategy based on its parameters and market conditions.
**Integration with Real-Time Data Feeds:** Connect the template to real-time data feeds to provide live performance updates.
**Multilingual Support:** Translate the template into multiple languages to make it accessible to a wider audience.
**Improved Search Functionality:** Enhance the wiki's search functionality to allow users to easily find strategies based on specific criteria.
This `Template:Infobox Trading Strategy` is a vital tool for building a comprehensive and user-friendly wiki dedicated to trading and technical analysis. By adhering to the guidelines outlined in this article, contributors can ensure that the information presented is consistent, accurate, and informative, ultimately benefiting all users of the wiki. The careful application of this template, combined with diligent research and clear writing, will significantly enhance the quality and value of the wiki's content.
Subscribe to our Telegram channel @strategybin to receive:
✓ Daily trading signals
✓ Exclusive strategy analysis
✓ Market trend alerts
✓ Educational materials for beginners`), `#subst` replaces the template call with the *expanded* content of the template.
```wiki
{{#subst:Template:Example}}
```
**`#switch`**: A multi-way conditional statement. It checks the first argument against a series of cases and outputs the corresponding result. Useful for handling different scenarios based on a variable value. Can be used to categorize different Trading Strategies.
```wiki
{{#switch: Parser functions
| Help:Parser functions = You are reading the Parser Functions help page.
| Main Page = Welcome to the wiki!
| #default = This is a different page.
}}
```
**`#vardefine` and `#varbyname`**: These functions allow you to define and use named variables within a page. This can improve readability and maintainability, especially when dealing with complex calculations or templates. Think of them as local variables for your wiki page. Crucial for implementing complex Indicator calculations.
**Nesting Parser Functions:** You can combine parser functions to achieve more complex results. For example:
```wiki
{{#ifexist:Parser functions | {{#title:Parser functions}} | Page does not exist}}
```
This checks if the current page exists, and if it does, formats the page title.
**Using with Templates:** Parser functions are often used within templates to create dynamic and reusable content. Templates can accept arguments and use parser functions to process them. This is how complex Chart Patterns can be displayed.
**Looping (Limited):** While MediaWiki doesn't have explicit looping constructs, you can sometimes simulate looping behavior using recursion and `#if` statements, although this can be complex and resource-intensive.
**Error Handling:** Error handling within parser functions is limited. `#expr` will often return an error message if the expression is invalid. You can use `#if` to check for empty results and handle errors gracefully.
**Performance Considerations:** Excessive use of complex parser functions, especially nested ones, can impact page rendering performance. Keep your functions as simple as possible and avoid unnecessary calculations. Consider using Extensions for computationally intensive tasks.
== Examples in a Trading Context
Let's illustrate how parser functions can be used in a wiki dedicated to financial trading.
7. **Displaying Moving Average Crossover Signals:**
```wiki
{{#if: Template:ShortMA > Template:LongMA | Bullish Crossover | Bearish Crossover}}
```
Displays a bullish or bearish crossover signal based on two moving averages.
8. **Evaluating Volatility:**
```wiki
{{#expr: Template:ATR / Template:Close * 100}}
```
Calculates the Average True Range (ATR) as a percentage of the closing price. This is a common measure of Market Volatility.
9. **Identifying Breakout Points:**
```wiki
{{#if: Template:Close > Template:Resistance | Breakout! | Below Resistance}}
```
Checks if the closing price has broken through a resistance level.
**Limited Functionality:** Parser functions are not a full-fledged programming language. Their capabilities are limited to text manipulation, mathematical calculations, and date/time handling.
**Performance:** Complex and nested parser functions can significantly impact page rendering performance.
**Error Handling:** Error handling is limited.
**Security:** Be cautious when using user-supplied data within parser functions, as it could potentially lead to security vulnerabilities.
**Recursion Depth:** There is a limit to the recursion depth, so deeply nested functions may fail.