-
Notifications
You must be signed in to change notification settings - Fork 0
GPT prompt template
Rafal W. edited this page Oct 16, 2024
·
3 revisions
You can create new EA31337 indicators using AI GPTs such as (ChatGPT, Claude, Copilot, Grok and many more).
Develop a comprehensive MQL5 indicator using EA31337 Framework with the following specifications:
- Name of strategy: MA2
- Description: Indicator to calculate two MA buffers with slow and fast lines.
Indicator main code structure:
- File should start with a multi-line comment block having @file and @brief description of the indicator.
- Must define: `OnInit()` and `OnCalculate()` global functions according to MQL5 API.
- Must define: `INDI_FULL_NAME` and `INDI_SHORT_NAME` directives with full and short name of indicator.
- Must define list of `#property` directives to specify additional indicator parameters (e.g. buffers, colors, levels, style, etc) wrapped in `#ifdef __MQL__ directive block`.
- Must define list of `#property` directives (in separate #ifdef block) to specify copyright (EA31337 Ltd), link (ea31337.github.io) and description (equal to INDI_FULL_NAME).
- Must specify indicator inputs.
- Must include the following files: EA31337-classes/Indicator.define.h
EA31337 Framework coding standards and rules (ignore during response):
- Avoid calling MQL5 builtin function, reference framework classes and their methods instead.
- Avoid global code outside of the class.
- Code follows object-oriented programming (OOP).
- Use C++ comments: `//` for inline, `/* */` for class and methods.
- Use `INPUT` instead of `input` for user's input parameters.
- Use `INPUT_GROUP("Foo")` for input grouping.
Available Chart class methods:
- `int GetBarShift(datetime _time, bool _exact = false)` - returns the index of the bar based on the given time.
- `double GetHigh(uint _shift = 0)` - returns high price value for the given shifted bar in the current timeframe.
- `double GetHigh(ENUM_TIMEFRAMES _tf, uint _shift = 0)` - returns high price value for the given timeframe and shifted bar.
- `double GetLow(uint _shift = 0)` - returns low price value for the given shifted bar in the current timeframe.
- `double GetLow(ENUM_TIMEFRAMES _tf, uint _shift = 0)` - returns low price value for the given timeframe and shifted bar.
- `double GetPrice(ENUM_APPLIED_PRICE _ap, int _shift = 0)` - returns the current price for the given applied price and shifted bar.
- `int GetHighest(ENUM_TIMEFRAMES _tf, int type, int _count = WHOLE_ARRAY, int _start = 0)` - returns the shift of the max price value over number of periods for the given timeframe.
- `int GetHighest(int type, int _count = WHOLE_ARRAY, int _start = 0)` - returns the shift of the max price value over number of periods for the given timeframe.
- `long GetVolume(uint _shift = 0)` - returns tick volume value for the given shifted bar.
- `long GetVolume(ENUM_TIMEFRAMES _tf, uint _shift = 0)` - returns tick volume value for the given timeframe and shifted bar.
Available Indicator class methods:
- `bool IsDecreasing(int _rows = 1, int _mode = 0, int _shift = 0)` - returns true when indicator value decreased.
- `bool IsIncreasing(int _rows = 1, int _mode = 0, int _shift = 0)` - returns true when indicator value increased.
- `bool IsIncByPct(float _pct, int _mode = 0, int _shift = 0, int _count = 1, bool _hundreds = true)` - returns true when value increased by given percentage value.
- `bool IsDecByPct(float _pct, int _mode = 0, int _shift = 0, int _count = 1, bool _hundreds = true)` - returns true when value decreased by given percentage value.
- `BarOHLC GetOHLC(unsigned int _shift = 0)` - returns BarOHLC struct with OHLC price values.
Available indicators:
- AC, AD, ADX, ADXW, AMA, AO, ASI, ATR, Alligator, AppliedPrice, BWMFI, BWZT, Bands, BearsPower, BullsPower, CCI, CHO, CHV, DEMA, DeMarker, DetrandedPrice, Envelopes, Force, FractalAdaptiveMA, Fractals, Gator, HeikenAshi, Ichimoku, Killzones, MA, MACD, MFI, MassIndex, Momentum, OBV, OsMA, Pivot, PriceChannel, PriceFeeder, PriceVolumeTrend, RS, RSI, RVI, RateOfChange, SAR, StdDev, Stochastic, TEMA, TRIX, UltimateOscillator, VIDYA, VROC, Volumes, WPR, WilliamsAD, ZigZag
Code examples:
- Loading chart instance: `Chart *_chart = (Chart *)_indi;`
- Loading indicator instance: `Indi_IName *_indi = GetIndicator();`
- SignalOpen's signal conditions example: `switch (_cmd) { case ORDER_TYPE_BUY: _result &= BUY_CONDITION1; _result &= BUY_CONDITION2; break; case ORDER_TYPE_SELL: _result &= SELL_CONDITION1; _result &= SELL_CONDITION2; break; }`
- To load indicator value, use: `_indi[_shift][_mode]`.
- To load 2 indicators on OnInit() with different indexes: `void OnInit() { IndiIName1Params _iname1_params(::SName_Indi_IName1_Shift); _sve_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF)); SetIndicator(new Indi_IName1(_iname1_params), 0); IndiIName2Params _iname2_params(::SName_Indi_IName2_Shift); _tmat_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF)); SetIndicator(new Indi_IName2(_iname2_params), 1); }`, then can be loaded by `Indi_IName1 *_indi1 = GetIndicator(0); Indi_IName2 *_indi2 = GetIndicator(1);`
Your response should include:
- Key points (such as trading logic on signal open and close)
- MQL5 code implementing this strategy.
- Further suggestions on improvements.
- Your honest opinion about the strategy idea.
- Your internal thought-process on how good strategy may be.
Please write the code in a professional, clean clang format, following best practices for MQL5 development.