Back to Learning

Coding

814 prompts available

Add Open Time Input MT5

You are tasked with enhancing an existing MetaTrader 5 (MT5) indicator by adding a new input parameter for 'indicator open time'. Your goal is to integrate this input seamlessly into the existing indicator code to allow users to specify or adjust the open time setting for the indicator. Ensure that: - The new input parameter is clearly defined and properly documented within the code. - Input validation is included if necessary to prevent invalid time values. - The functionality of the indicator correctly utilizes this new 'open time' input in its calculations or display. - The code remains clean, readable, and maintainable. - Include comments explaining your changes. # Steps 1. Analyze the existing MT5 indicator code to understand where and how the open time should influence the indicator. 2. Add input parameter syntax compatible with MQL5, such as `input datetime OpenTime = DEFAULT_VALUE;` or appropriate time format. 3. Implement logic to use this input within the indicator's calculations or display routines. 4. Test the updated indicator to ensure correct behavior with various open time inputs. 5. Document the new input in the indicator header and code comments. # Output Format Provide the full updated MQL5 indicator source code with the new input parameter included and detailed comments explaining the addition. # Notes If the existing indicator code is not provided, specify the general approach and example code snippet to add such an input in an MT5 indicator script.

Add MACD and RSI Trend Filters

You are tasked with enhancing a Pine Script trading strategy by integrating trend filters using MACD and RSI indicators, similar to existing EMA 50 or EMA 200 filters. The goal is to reduce losing trades during ranging markets by allowing trades only when trend conditions, as defined by MACD and RSI criteria, are favorable. Instructions: - Understand how MACD and RSI can act as trend filters. - Implement conditions that filter trades based on MACD (e.g., MACD line relative to signal line or zero line) and RSI levels that indicate overbought/oversold or momentum. - Integrate these filters into an existing buy/sell Pine Connector strategy, ensuring trades are placed only when the trend filter conditions are met. - Provide clear explanations of the filter logic. # Steps 1. Analyze the current strategy's EMA-based trend filters to understand filtering logic. 2. Define MACD-based trend filter criteria (e.g., MACD above signal line and zero for bullish trend). 3. Define RSI-based trend filter criteria (e.g., RSI above 50 for bullish momentum). 4. Code these filters in Pine Script, adding them as conditions to enable or disable buy/sell signals. 5. Test and validate the strategy to confirm reduced losses during ranging markets. # Output Format - Provide commented Pine Script code snippets showing MACD and RSI trend filter implementations. - Include a brief rationale explaining how these filters help avoid losing trades in ranging markets.

Add optional cover letter attachment

You are a skilled software developer tasked with modifying an existing mail sending API function. The goal is to minimally impact the current function implementation while adding support for an optional new field. Specifically, add a new optional string field named `cover_letter_content` inside the `ForwardMailListModelIn` input model. If this field is present in the input, the content should be included as an attachment to the mail being sent. Provide only the modified parts of the code necessary to implement this addition, without rewriting or altering other parts of the function. Ensure the new logic integrates cleanly and respects the existing code style. # Steps - Identify where `ForwardMailListModelIn` is defined and add the optional `cover_letter_content` field. - Modify the mail sending logic to check if `cover_letter_content` exists. - If present, attach it to the mail appropriately. - Return only the modified segments of code reflecting these changes. # Output Format Return a snippet containing just the code modifications needed to support the optional `cover_letter_content` field and its handling in the mail sending process.

Add Page at App Start

You are asked to add a specific page to the starting of an application. Please provide clear instructions or code snippets for how to integrate the given page as the app's launch or initial screen. # Steps 1. Identify the app framework and language (e.g., React Native, Flutter, Android with Java/Kotlin, iOS with Swift). 2. Specify the exact page or component that needs to be added at the start. 3. Explain how to modify the app's entry point to set this page as the first screen the user sees. 4. Highlight any navigation changes needed, such as adjusting the main router or stack navigator. 5. Mention considerations like splash screens or loading states if relevant. # Output Format Provide a step-by-step guide or code examples tailored to the app's framework and language, explaining how to add the given page at the start of the application.

Add Max Trades and Lot Size Inputs

Add input parameters for maximum open trades and lot size limit to the provided MQL5 Expert Advisor code for the Aivex-Lumina Fusion AI robot, without removing or altering the existing strategy, logic, or functionality. Integrate these inputs so that the robot respects these user-defined constraints when executing trades. Ensure that all existing conditions, trade execution logic, and risk management remain intact. Provide the modified code snippet with the new input parameters clearly added and used within the trade execution to limit the number of open trades and the size of lots per trade as specified by the user. The original code is: ```mql5 //+------------------------------------------------------------------+ //| Expert Advisor: Aivex-Lumina Fusion AI | //| Strategy: Combines Smart Money Concepts with AI Confirmation | //+------------------------------------------------------------------+ #include <Trade\Trade.mqh> #include <Indicators\Trend.mqh> CTrade trade; //--- Input parameters input ENUM_TIMEFRAMES EntryTF = PERIOD_M15; input ENUM_TIMEFRAMES TrendTF = PERIOD_H4; input double RiskPercent = 1.0; input double ATRMultiplier = 1.5; input int ATRPeriod = 14; input int TrendMAPeriod = 50; input bool UseNewsFilter = true; input bool UseATRStop = true; input bool EnableLondonNY = true; input bool EnablePatternAI = true; //--- Risk mode enum RiskMode { None, Low, Medium, High }; input RiskMode risk_mode = Low; //--- Global variables datetime lastTradeTime = 0; int tradesToday = 0; //--- Indicator handles int atrHandle; double atrValue[]; int maHandle; double trendMA[]; //+------------------------------------------------------------------+ //| Structure Analysis Functions | //+------------------------------------------------------------------+ bool MarketStructureShiftDetected() { double high1 = iHigh(_Symbol, EntryTF, 1); double high2 = iHigh(_Symbol, EntryTF, 2); double low1 = iLow(_Symbol, EntryTF, 1); double low2 = iLow(_Symbol, EntryTF, 2); return ((high1 > high2 && low1 > low2) || (high1 < high2 && low1 < low2)); } bool PriceSweptLiquidity() { double high = iHigh(_Symbol, EntryTF, 1); double prevHigh = iHigh(_Symbol, EntryTF, 2); double low = iLow(_Symbol, EntryTF, 1); double prevLow = iLow(_Symbol, EntryTF, 2); return (high > prevHigh || low < prevLow); } bool OrderBlockPresent() { double bodySize = MathAbs(iClose(_Symbol, EntryTF, 1) - iOpen(_Symbol, EntryTF, 1)); double wickSize = MathAbs(iHigh(_Symbol, EntryTF, 1) - iLow(_Symbol, EntryTF, 1)) - bodySize; return (bodySize > wickSize * 2); } bool TrendAligned() { if (CopyBuffer(maHandle, 0, 0, 1, trendMA) <= 0) return false; return (iClose(_Symbol, EntryTF, 0) > trendMA[0]); } bool VolatilitySafe() { return (atrValue[0] > 0); } bool PatternAIConfirmed() { if (!EnablePatternAI) return true; double close0 = iClose(_Symbol, EntryTF, 0); double close1 = iClose(_Symbol, EntryTF, 1); double close2 = iClose(_Symbol, EntryTF, 2); return (close1 < close2 && close0 > close1); // Example pattern: bullish reversal } bool InTradingSession() { if (!EnableLondonNY) return true; datetime time = TimeCurrent(); MqlDateTime dt; TimeToStruct(time, dt); int hour = dt.hour; return (hour >= 8 && hour <= 11) || (hour >= 13 && hour <= 17); } //+------------------------------------------------------------------+ //| Trade Execution Logic | //+------------------------------------------------------------------+ void ExecuteTrade() { double sl = UseATRStop ? atrValue[0] * ATRMultiplier : 500 * _Point; double tp = UseATRStop ? atrValue[0] * ATRMultiplier * 2 : 1000 * _Point; double lot = CalculateLotSize(sl); if (PositionSelect(_Symbol)) return; for (int i = 0; i < GetTradeCount(); i++) { if (TrendAligned() && iClose(_Symbol, EntryTF, 1) > iOpen(_Symbol, EntryTF, 1)) trade.Buy(lot, _Symbol, 0, iClose(_Symbol, EntryTF, 0) - sl, iClose(_Symbol, EntryTF, 0) + tp, "FusionAI Buy"); else if (!TrendAligned() && iClose(_Symbol, EntryTF, 1) < iOpen(_Symbol, EntryTF, 1)) trade.Sell(lot, _Symbol, 0, iClose(_Symbol, EntryTF, 0) + sl, iClose(_Symbol, EntryTF, 0) - tp, "FusionAI Sell"); } lastTradeTime = TimeCurrent(); tradesToday++; } int GetTradeCount() { switch (risk_mode) { case Low: return 1; case Medium: return 3; case High: return 5; default: return 0; } } double CalculateLotSize(double slPoints) { double risk = AccountInfoDouble(ACCOUNT_BALANCE) * RiskPercent / 100.0; double tickValue; if (!SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE, tickValue)) tickValue = 1.0; double lotStep = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP); double contractSize = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_CONTRACT_SIZE); double lots = (risk / (slPoints * tickValue / _Point)) / contractSize; return NormalizeDouble(lots, 2); } //+------------------------------------------------------------------+ //| Expert Initialization | //+------------------------------------------------------------------+ int OnInit() { atrHandle = iATR(_Symbol, EntryTF, ATRPeriod); maHandle = iMA(_Symbol, TrendTF, TrendMAPeriod, 0, MODE_EMA, PRICE_CLOSE); ArraySetAsSeries(trendMA, true); ArraySetAsSeries(atrValue, true); return INIT_SUCCEEDED; } //+------------------------------------------------------------------+ //| Expert Tick | //+------------------------------------------------------------------+ void OnTick() { if (TimeCurrent() - lastTradeTime < 60) return; if (!InTradingSession()) return; if (CopyBuffer(atrHandle, 0, 0, 1, atrValue) <= 0) return; if (MarketStructureShiftDetected() && PriceSweptLiquidity() && OrderBlockPresent() && PatternAIConfirmed() && VolatilitySafe()) { ExecuteTrade(); } } //+------------------------------------------------------------------+ ``` # Steps 1. Add new input parameters for `MaxOpenTrades` (integer) and `MaxLotSize` (double) with informative default values. 2. Modify or add helper functions if necessary to count current open trades. 3. Integrate logic in `ExecuteTrade()` so that it does not open more trades than `MaxOpenTrades` allows. 4. Modify `CalculateLotSize()` or cap the lot size used in trade orders to not exceed `MaxLotSize`. 5. Ensure all other existing trade checks, strategies, and the original logic remain untouched. 6. Provide the complete modified code snippet reflecting these changes while preserving the original formatting and comments. # Output Format Provide the complete MQL5 code snippet with the new inputs and logic incorporated as described. Highlight or comment the additions clearly but do not remove or alter existing original code except where necessary to integrate the new features. # Notes - Do not remove any existing inputs or logic. - Add only the minimum needed to respect max open trades and max lot size. - Ensure your changes compile and logically integrate with the original expert advisor. # Response Format Return only the modified MQL5 code snippet as a single code block with all changes included and properly commented.

Add Month Filter and Button

Please update the provided HTML code by adding a new select option for months, and include a button that resets the filter and reloads the page accordingly. The updated code should maintain the original styling and structure in the code snippet. Make sure to initialize the new month dropdown properly, and ensure that the button triggers the filtering action. Here's the updated code snippet: ```html <div class="card-toolbar"> <div class="input-group w-100 float-end"> <div class="btn-group"> <button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> <i class="ki-duotone ki-abstract-37 fs-2x me-2 text-primary"> <span class="path1"></span> <span class="path2"></span> </i> Year : @Model.ActiveYear </button> <ul class="dropdown-menu"> <li><a asp-controller="Rent" asp-action="Rentals" asp-route-year="0" class="dropdown-item">All</a></li> @foreach (int year in Model.ActiveYears.Take(10)) { <li><a asp-controller="Rent" asp-action="Rentals" asp-route-year="@year" class="dropdown-item">@year</a></li> } </ul> </div> <div class="input-group"> <select id="monthSelect" class="form-select"> <option value="0">Select Month</option> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <button id="filterButton" class="btn btn-primary" onclick="applyFilter()">Apply Filter</button> </div> </div> </div> ``` Additionally, please create the appropriate JavaScript function `applyFilter()` that grabs the selected month and year, then reloads the page according to the filters applied. The following is an example of how you can implement this function: ```javascript function applyFilter() { var selectedYear = document.querySelector('.btn-group .dropdown-toggle').innerText.split(': ')[1]; // Get the current selected year var selectedMonth = document.getElementById('monthSelect').value; window.location.href = `/Rent/Rentals?year=${selectedYear}&month=${selectedMonth}`; // Redirect to the filtered URL } ``` This will ensure that when users select a month and click the button, they will be redirected to the Rentals page with the specified filters activated. Make sure to test the functionality after implementation to verify that the filters work as intended!

Add Parameters to HttpRequestMessage

You are a software engineer specialized in .NET Core tasked with demonstrating how to add parameters to an HttpRequestMessage in C#. Your response should focus on producing clean, maintainable, and high-quality code. Include detailed comments explaining each step and decision in the code to ensure clarity and ease of understanding for other developers. # Steps - Briefly explain what HttpRequestMessage is and its typical use. - Show how to add query parameters to the request URL. - Demonstrate adding headers to the HttpRequestMessage. - Optionally, show how to add content parameters if appropriate (for POST or PUT requests). - Apply best practices for readability and maintainability, such as using helper methods or builders if needed. - Provide comments explaining the purpose of each part of the code. # Output Format Provide well-formatted C# code snippets with inline comments. The code should be executable within a .NET Core environment and follow standard conventions. # Examples ```csharp // Create an HttpRequestMessage and add query parameters and headers var baseUri = new Uri("https://api.example.com/resource"); var builder = new UriBuilder(baseUri); var query = HttpUtility.ParseQueryString(builder.Query); query["param1"] = "value1"; query["param2"] = "value2"; builder.Query = query.ToString(); var request = new HttpRequestMessage(HttpMethod.Get, builder.Uri); request.Headers.Add("Custom-Header", "HeaderValue"); // Use the request in HttpClient ``` # Notes - Ensure the query parameters are URL-encoded properly. - Avoid hardcoding strings; demonstrate the use of variables and constants where applicable. - Mention any relevant namespaces or dependencies (like System.Net.Http or System.Web). - Consider maintainability by avoiding code duplication and enhancing readability.

Add Multiplayer and Money Split

Enhance the existing script by adding a multiplayer feature allowing up to three participants to join a game session. Implement an invitation mechanic so players can invite others to join. Incorporate functionality for splitting money among players either equally or by user-defined amounts as decided by the participants. Key Requirements: - Enable inviting up to 2 additional players (maximum 3 total). - Provide a way for players to accept or decline invitations. - Allow money distribution to be either evenly split or custom split based on user input. - Ensure the multiplayer logic integrates smoothly with existing game mechanics. # Steps 1. Implement invitation system for inviting 1-2 other players. 2. Add user responses to accept or decline invitations. 3. Create an interface or prompts for selecting money split method (equal or custom). 4. Adjust game logic to manage multiple players and corresponding money splits. 5. Test multiplayer functionality thoroughly for stability and correctness. # Output Format Provide the enhanced script code with comments explaining the multiplayer additions clearly, maintaining consistency with the original script style. # Notes Maintain the original game flow and logic where possible, only extending it to handle multiple players and money splitting.

8-Week CrossFit Program

Generate an 8-week CrossFit program that includes the following components: warm-up, lifting, Metcon (metabolic conditioning), accessory work, and cool down/stretching. The program should specifically focus on improving strength in lifting and enhancing endurance throughout the duration of the 8 weeks. Ensure each week has a structured layout with progressive intensity and volume adjustments.

Add Partial Close Inputs MT5 EA

You are given an Expert Advisor (EA) code for MetaTrader 5 (MT5) that currently lacks the ability to close positions partially. Your task is to enhance the EA by adding inputs that enable partial position closing functionality without altering any existing code logic or structure. Specifically, you must: - Add new input parameters to the EA that allow specifying the portion or volume of the position to close partially. - Ensure that no existing code or business logic is modified; only add inputs to facilitate partial closing. - Maintain the original behavior and integrity of the EA aside from incorporating these inputs. # Steps 1. Review the current EA inputs and identify how to add parameters related to partial position closing without changing code logic. 2. Define new input parameters indicating the partial close volume or percentage. 3. Make sure these inputs are integrated properly within the EA’s input declarations. 4. Avoid any alteration of existing functions, calculations, or code flow. # Output Format Provide the exact input declarations to be added to the EA code in MQL5, with appropriate data types and default values, formatted as they would appear in the EA source code. # Notes - Do not implement any closing logic or modify existing functions. - Only the input definitions and minimal comment additions related to partial close should be included.

Add PayNow Button

You are tasked with integrating a 'PayNow' button into the 'order_history.php' page similar to the existing button found on 'payment.php'. To achieve this, please review the Payment button implementation on 'payment.php' and recreate the functionality within 'order_history.php' using the provided code as the base. Be sure to maintain consistency in style and functionality, ensuring that the button triggers the appropriate payment processing for each order listed in the order history. # Steps 1. Examine the 'payment.php' file to understand how the 'PayNow' button is implemented, including its HTML structure, styling, and any related JavaScript or PHP code. 2. Identify how the button integrates with the backend payment processing logic. 3. Review the 'order_history.php' code provided. 4. Insert the 'PayNow' button in the relevant part of 'order_history.php', ideally adjacent to each order entry. 5. Ensure that clicking the 'PayNow' button initiates payment specifically for the associated order. 6. Test the integration thoroughly to confirm functionality and UI consistency. # Output Format Please provide the modified 'order_history.php' code incorporating the 'PayNow' button with clear comments indicating your additions or modifications. # Notes - Assume you have access to the full source code of both files. - Preserve the existing order history functionality when adding the button. - Use proper security practices when handling payment initiation. # Response Formats Provide the complete PHP code for 'order_history.php' with the integrated 'PayNow' button, formatted as a single code block for clarity.

80% Accurate Pine Script Strategy

Create a Pine Script trading strategy that aims to achieve approximately 80% accuracy in its signals. The script should include clear logic for entry and exit points based on technical indicators or conditions that systematically evaluate buy and sell signals. Ensure the strategy includes the following: - Well-defined entry criteria for long and short positions. - Clear exit criteria to close positions. - Risk management features such as stop losses and take profits. - Comments explaining each part of the code for clarity. Think through and describe your reasoning process before providing the final code to enhance understanding. # Steps 1. Outline the technical indicators or conditions that could support an 80% accuracy rate. 2. Define the entry rules using these indicators. 3. Define the exit rules and risk management parameters. 4. Implement the strategy in Pine Script with comments. 5. Test and adjust parameters to approach 80% accuracy. # Output Format Provide the complete Pine Script code with comments explaining logic and parameters. Include a brief summary of the strategy's logic and how it aims to achieve 80% accuracy.

Page 33 of 68

    Coding Prompts - Learning AI Prompts | Elevato