eqF - FuzzyRange meaning

Posted By: tomaslolo

eqF - FuzzyRange meaning - 06/07/18 09:00

Hi all, keep learning and enjoying with Zorro. Now trying to understand eqF:

For "Pattern Analyzer", from the manual (http://www.zorro-trader.com/manual/en/advisor.htm)
Quote:
int EURUSD_S(float* sig)
{
if(sig[1]<sig[2] && eqF(sig[2]-sig[4]) && sig[4]<sig[0] && sig[0]<sig[5] && sig[5]<sig[3]
&& sig[10]<sig[11] && sig[11]<sig[7] && sig[7]<sig[8] && sig[8]<sig[9] && sig[9]<sig[6])
return 19;
if(sig[4]<sig[1] && sig[1]<sig[2] && sig[2]<sig[5] && sig[5]<sig[3] && sig[3]<sig[0] && sig[7]<sig[8]
&& eqF(sig[8]-sig[10]) && sig[10]<sig[6] && sig[6]<sig[11] && sig[11]<sig[9])
return 170;
if(sig[1]<sig[4] && eqF(sig[4]-sig[5]) && sig[5]<sig[2] && sig[2]<sig[3] && sig[3]<sig[0]
&& sig[10]<sig[7] && eqF(sig[7]-sig[8]) && sig[8]<sig[6] && sig[6]<sig[11] && sig[11]<sig[9])
return 74;
if(sig[1]<sig[4] && sig[4]<sig[5] && sig[5]<sig[2] && sig[2]<sig[0] && sig[0]<sig[3] && sig[7]<sig[8]
&& eqF(sig[8]-sig[10]) && sig[10]<sig[11] && sig[11]<sig[9] && sig[9]<sig[6])
return 143;
if(sig[1]<sig[2] && eqF(sig[2]-sig[4]) && sig[4]<sig[5] && sig[5]<sig[3] && sig[3]<sig[0]
&& sig[10]<sig[7] && sig[7]<sig[8] && sig[8]<sig[6] && sig[6]<sig[11] && sig[11]<sig[9])
return 168;
....
return 0;
}


Quote:
The eqF function in the code above checks if two signals are almost equal, i.e. differ less than FuzzyRange.


And in the Fuzzy Logic chapter (http://www.zorro-trader.com/manual/en/fuzzy.htm):

Quote:
FuzzyRange
Determines the 'fuzziness' range of the input data (default: 0 = no fuzziness). When comparing two variables, the truth value goes from 0 to 1 within that range. Set this to a small fraction of the price volatility, or f.i. to 0.1*PIP for comparing moving averages, or to 0.1 for comparing percentage values. The smaller this value, the 'less fuzzy' is the logic. At the default value 0 the logic is binary. The FuzzyRange variable is also used for classifying signal patterns for price action trading.


Does this mean that, f.i.
Quote:
eqF(sig[2]-sig[4])
is the same that saying
Quote:
0<(sig[2]-sig[4])<1
or am I completely lost? (probably)

In Workshop7, you donīt "set" any FuzzyRange, is there a default FuzzyRange?

Thank you zorro experts.
Posted By: Spirit

Re: eqF - FuzzyRange meaning - 06/09/18 09:11

it is the same as saying

abs(sig[2]-sig[4]) < FuzzyRange

at least thats what I think.
Posted By: tomaslolo

Re: eqF - FuzzyRange meaning - 06/11/18 11:40

Thank you, but how is FuzzyRange calculated?

When running Workshop7.c
Code:
function run()
{
  StartDate = 2005;   // use > 10 years data
  BarPeriod = 1440;   // 1 day
  BarZone = WET;      // West European midnight
  Weekend = 1;        // separate Friday and Sunday bars
  LookBack = 3;       // only 3 bars needed
  NumWFOCycles = 10;   // mandatory for machine learning functions
 
  set(RULES+TESTNOW); // generate rules, test after training
  if(Train) Hedge = 2; // allow long + short
  LifeTime = 5;        // = one week
  MaxLong = MaxShort = 1; // only 1 open trade
 
  if(adviseLong(PATTERN+2,0,
    priceHigh(2),priceLow(2),priceClose(2),
    priceHigh(1),priceLow(1),priceClose(1),
    priceHigh(1),priceLow(1),priceClose(1),
    priceHigh(0),priceLow(0),priceClose(0)) > 40)
    enterLong();
  if(adviseShort() > 40)
    enterShort();
}



You can even have eqF(sig[8]-sig[8]) which should be 0.
© 2024 lite-C Forums