**Re: NetTrap Metatrader Expert Advisor** Quote:
Originally Posted by **pimplico** Hi Spin,
Thanks so much for your help and this EA. Been testing it on various settings on a demo a SML and it works brilliantly. Plan to go live in a few weeks, very excited.
I hope you don't mind, I have two questions. T
The 'checkSR' option....How does it calculate the support and restistance levels?
The option 'checkPivot'. Have you put this in because you think it could be a good 'entry' filter? I am fascinated by this as I have been monitoring the daily pivot and was thinking it using at as an entry filter myself.
Best regards
Charlie |
Hi Charlie
It firstly counts the number of times the high, low or close of a bar hits each price point (in the range of bars on the current chart calculated from SRLookBackDays). It then looks through all the counts and works out the nearest price point that has had the required number of hits (calculated as SRHitPerc percent of the number of bars in the range.)
If this fails to find any s/r, the program uses the nearest of the standard S/R points, as calculated as part of the Pivot point routine (which I took from an indicator called PivotsDaily, which probably came from the MetaQuotes site. (In this situation, if the price is the "wrong" side of the pivot, the pivot will be used as the first line of s/r.)
Yes, the checkPivot acts as filter and will stop the EA entering a trade if the entry price is the "wrong side" of the pivot.
Here's the pivot calculation the EA is using: yesterday_close = iClose(Symbol(),PERIOD_D1,1);
yesterday_open = iOpen(Symbol(),PERIOD_D1,1);
today_open = iOpen(Symbol(),PERIOD_D1,0);
yesterday_high = iHigh(Symbol(),PERIOD_D1,1);
yesterday_low = iLow(Symbol(),PERIOD_D1,1);
day_high = iHigh(Symbol(),PERIOD_D1,0);
day_low = iLow(Symbol(),PERIOD_D1,0);
// calculate yesterday's range
checkRange = (yesterday_high - yesterday_low);
// if yesterday's range is very small and today is a Monday,
// treat day before as yesterday
if (DayOfWeek() == 1 && checkRange < 20)
{
yesterday_close = iClose(Symbol(),PERIOD_D1,2);
yesterday_open = iOpen(Symbol(),PERIOD_D1,2);
yesterday_high = iHigh(Symbol(),PERIOD_D1,2);
yesterday_low = iLow(Symbol(),PERIOD_D1,2);
}
//---- Calculate Pivots
D = (day_high - day_low);
Q = (yesterday_high - yesterday_low);
P = NormalizeDouble((yesterday_high + yesterday_low + yesterday_close) / 3,symbolDigits);
R1 = NormalizeDouble((2*P)-yesterday_low,symbolDigits);
S1 = NormalizeDouble((2*P)-yesterday_high,symbolDigits);
R2 = NormalizeDouble(P+(yesterday_high - yesterday_low),symbolDigits);
S2 = NormalizeDouble(P-(yesterday_high - yesterday_low),symbolDigits);
H4 = (Q*0.55)+yesterday_close;
H3 = (Q*0.27)+yesterday_close;
R3 = NormalizeDouble((2*P)+(yesterday_high-(2*yesterday_low)),symbolDigits);
M5 = (R2+R3)/2;
M4 = (R1+R2)/2;
M3 = (P+R1)/2;
M2 = (P+S1)/2;
M1 = (S1+S2)/2;
S3 = NormalizeDouble((2*P)-((2* yesterday_high)-yesterday_low),symbolDigits);
L3 = yesterday_close-(Q*0.27);
L4 = yesterday_close-(Q*0.55);
M0 = (S2+S3)/2;
if (Q > 5)
{
nQ = Q;
}
else
{
nQ = Q*10000;
}
if (D > 5)
{
nD = D;
}
else
{
nD = D*10000;
}
Some of the above is redundant in the Net Trap EA.
Hope this helps!
Cheers,
Greg |