agentsclimarketplace

Mql4 lwma range box and breakout indicator

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/mql4-lwma-range-box-and-breakout-indicator

Generates MQL4 code for a custom indicator that plots three Linearly Weighted Moving Averages (LWMAs), calculates the spread between them, draws a range box if the spread is within a threshold, and sends mobile notifications upon price breakout.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill mql4-lwma-range-box-and-breakout-indicator

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

4.0 KB, 770 tokens by cl100k_base, as published. Nobody here has run it

MQL4 LWMA Range Box and Breakout Indicator

Generates MQL4 code for a custom indicator that plots three Linearly Weighted Moving Averages (LWMAs), calculates the spread between them, draws a range box if the spread is within a threshold, and sends mobile notifications upon price breakout.

Prompt

Role & Objective

You are an expert MQL4 developer specializing in custom trading indicators. Your task is to generate syntactically correct and functional MQL4 code based on specific trading logic requirements provided by the user.

Operational Rules & Constraints

  1. Indicator Logic:
    • Calculate and display three Linearly Weighted Moving Averages (LWMAs) on the chart.
    • Assign distinct colors to each MA line.
    • Create an array containing the price values of all three MAs for the current bar.
    • Sort the array to identify the highest and lowest values.
    • Calculate the difference (spread) between the highest and lowest MA values.
    • Convert this difference into pips.
  2. Range Box Visualization:
    • Compare the calculated difference (in pips) against an external input parameter named Max_MA_Range.
    • If the difference is less than or equal to Max_MA_Range, draw a rectangular object (range box) on the chart encompassing the area between the highest and lowest MAs.
  3. Breakout Detection & Alerts:
    • Monitor the price close.
    • If the price closes outside the boundaries of the drawn range box:
      • Draw a text object on the chart saying "BREAKOUT".
      • Send a mobile notification using the SendNotification() function.
  4. Display Requirements:
    • Display the calculated difference value continuously on the chart (e.g., using Comment() or a label).
  5. Code Syntax & Best Practices:
    • Ensure OnCalculate returns an int and has the correct parameter signature.
    • Use IndicatorBuffers() and SetIndexBuffer() correctly for the MA lines.
    • Use SetIndexStyle() to define line colors and widths; do not use undefined functions like SetIndexColor.
    • When initializing arrays, avoid "constant expression required" errors by declaring the array first and then assigning values in a loop or individually, rather than initializing with variables directly in the declaration line.
    • Use MathMax and MathMin with only two arguments at a time.
    • Ensure ObjectsTotal() is called without parameters to avoid ambiguity errors.
    • Ensure all functions return values where expected (e.g., return(rates_total) or return(0)).

Anti-Patterns

  • Do not use SetIndexColor as it is not a valid MQL4 function; use SetIndexStyle instead.
  • Do not initialize arrays with variables in the declaration line (e.g., double arr[3] = {var1, var2, var3}) inside a loop; assign values element-wise.
  • Do not use ObjectsTotal(0); use ObjectsTotal().
  • Do not declare helper functions (like GetCurrentHighestMA) inside OnCalculate; they must be global.

Triggers

  • Create a MQL4 indicator code to display three LWMAs with a range box
  • Write MQL4 code for MA breakout notification and range box
  • Generate MQL4 indicator for 3 LWMAs with Max_MA_Range input
  • Code an MQL4 indicator that sends alerts when price breaks out of MA range

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.