Skip to content

Commit 70fd69b

Browse files
Update CONTRIBUTING.md
1 parent ffd1f12 commit 70fd69b

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

.github/CONTRIBUTING.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,78 @@ This site can be developed on Windows, however a few potential gotchas need to b
120120
4. Filename too long error: There is a 260 character limit for a filename when Git is compiled with `msys`. While the suggestions below are not guaranteed to work and could cause other issues, a few workarounds include:
121121
- Update Git configuration: `git config --system core.longpaths true`
122122
- Consider using a different Git client on Windows
123+
//+------------------------------------------------------------------+
124+
//| Calc.mqh |
125+
//| |
126+
//| KnitPkg for MetaTrader — Demo |
127+
//| |
128+
//| MIT License |
129+
//| Copyright (c) 2025 Douglas Rechia |
130+
//| |
131+
//| Common technical analysis functions built on @douglasrechia/bar.|
132+
//| Provides lightweight implementations of SMA, ATR, and other |
133+
//| indicators for use in KnitPkg packages and MetaTrader projects. |
134+
//| |
135+
//| DISCLAIMER: |
136+
//| This code is provided AS-IS for educational purposes only. |
137+
//| No warranty is given. The author assumes no liability for any |
138+
//| damages or legal consequences arising from its use. |
139+
//| |
140+
//+------------------------------------------------------------------+
141+
142+
//------------------------------------------------------------------
143+
// Development autocomplete — resolves dependencies and enables
144+
// MetaEditor IntelliSense; automatically neutralized by KnitPkg
145+
// installer.
146+
// Run `kp autocomplete` to regenerate.
147+
//------------------------------------------------------------------
148+
#include "../../../autocomplete/autocomplete.mqh"
149+
150+
151+
//------------------------------------------------------------------
152+
// KnitPkg include directives — used by KnitPkg installer at the time
153+
// this package is installed as a dependency into another KnitPkg
154+
// project.
155+
//------------------------------------------------------------------
156+
/* @knitpkg:include "douglasrechia/bar/TimeSeries.mqh" */
157+
/* @knitpkg:include "douglasrechia/bar/Bar.mqh" */
158+
159+
namespace douglasrechia
160+
{
161+
//+------------------------------------------------------------------+
162+
//| Simple Moving Average |
163+
//+------------------------------------------------------------------+
164+
double SMA(douglasrechia::ITimeSeries<double> &series, int period, int shift = 0)
165+
{
166+
if(series.Size() < (period + shift))
167+
return 0.0;
168+
169+
double sum = 0.0;
170+
for(int i = shift; i < shift + period; i++)
171+
sum += series.ValueAtShift(i);
172+
173+
return sum / period;
174+
}
175+
176+
//+------------------------------------------------------------------+
177+
//| Average True Range |
178+
//+------------------------------------------------------------------+
179+
double ATR(douglasrechia::IBar &bar, int period, int shift = 0)
180+
{
181+
if(bar.Size() < (period + shift + 1))
182+
return 0.0;
183+
184+
double sum = 0.0;
185+
for(int i = shift; i < shift + period; i++)
186+
{
187+
double tr = MathMax(bar.High(i) - bar.Low(i),
188+
MathMax(MathAbs(bar.High(i) - bar.Close(i+1)),
189+
MathAbs(bar.Low(i) - bar.Close(i+1))));
190+
sum += tr;
191+
}
192+
193+
return sum / period;
194+
}
195+
196+
}
197+
//+------------------------------------------------------------------+

0 commit comments

Comments
 (0)