MQL4 - automated forex trading   /  

Code Base

Code Base  Expert Advisors  Fuzzy logic To post a new code, please log in or register

Download MetaTrader 5 and visit MQL5.community Code Base
and Trade on the Go!
Prepare for the Championship
Couldn't find the right code? Order it in the Jobs section

This Expert Advisor is for
MetaTrader 4
Download MT 4 - 455 Kb

and Trade on the Go!

Name:
Fuzzy logic [ ru ]
Author: Bass (2008.07.30 09:53)
Rating: 7
Downloaded: 4875
Download:
 Fuzzy logic.mq4 (15.6 Kb) View

Description:

There are lots of materials about the indistinct systems, so specifically about the EA:

1) The estimation is performed on the basis of values of five indicators (Gator, WPR, AC, DeMarker and RSI). The estimation is performed on the basis of trapezoidal membership functions.

2) You can modify the ranking and the weight of the properties directly in the code.

3) You can use not only the indicators specified above, but many other stuff (i.e. ones that you prefer to use), as the basis for the indistinct estimation (buy, sell, do nothing).

On the whole, the EA code is intended for practical acquaintance with the techonlogy of indistinct estimation of the current situation on the market. So I recommend to use, and also modify, it, after theory studying. A. Nedosekin's material Osnovy teoryi nechetnoy ocenky (The basics of indistinct estimation theory) should be enough for the primary introduction (the technology is a bit different there, but the theory itself is decribed fully well).


Advices:

  • If you are going to implement your own criterions of estimation instead of five embedded indicators, I recommend to divide these criterions into the borders of indistinct estimations (array arGator[7] in the code, etc.).
  • Do not try to overoptimize the parameters of memebership function (they are not taken out to the external varibles in the code), because it won't bring any significant effect, believe me, it's verified.
  • Experiment - I think that the indistinct logic as a technology of decision making is without a rival. May be it will help somebody to win the championship.
5 comments  To post a new comment, please log in or register
This system is brilliant.  I have been studying fuzzy logic theory and to my knowledge it has never been applied to Forex EA trading.  The system itself definitely needs tweaking, it will only sell, but this system shows a lot of promise.  Thanks for submitting it.  If you have any new updates to the system you would be willing to share I would love to see them.  If you want to know how I have been successfully trading this system please contact me directly.  Thanks again!  Great job Bass!!!! 
20.10.2008 22:09 tradervic1963

Hello Bass,

I interest your idea. After I test your EA, I found some problem.

1) Your fuzzy EA open only SELL order. I found the return value of FuzzyLogic() 
function alway below 0.5. Then, I look into FuzzyLogic and found wrong
value and code
  1.1) Size of Array variable in FuzzyLogic function are wrong.
  1.2) I think values of Array arGator are wrong number, The SumGator variable 
is too small (below 0.01)
  1.3) The double loop before finish the function has wrong code.

for (x=0;x<5;x++)       /* all element from 0 to 4 */
{
   for (y=0;y<5;y++)     /* all element from 0 to 4 */
   {
      Summary[x] = Summary[x] + Rang[y,x]*Weight[y];     /* index of Weight */
   }
}
 
for (x=0,Decision=0;x<5;x++)    /* initialize Decision */
{
   Decision = Decision + Summary[x]*(0.2*(x+1)-0.1);
}

2) In testing it generate many error order codes. I found your EA code 
send Order to server more than one in single tick. In start() function 
After it call CheckForOpen() function that send OrderSend() to server,
SetStopLoss() function is called and it send OrderModify() to server and then
it send OrderModify() in start() function again before finish. It send 3 order
to server in single tick!!!

if(CalculateCurrentOrders(Symbol())==0)
   {
      CheckForOpen();
      return;      /* finish OrderSend */
   }
   
   if (FirstSL==True)
   {
      if (SetStopLoss())     /* return the tic  */
      {
         FirstSL = False;
      }
      return;   /* finish 1st OrderModify */ 
   }
 
In SetStopLoss() function has wrong code 
  StopLoss=NormalizeDouble(SL*Point,0);

It alway zero. I change to

  StopLoss=NormalizeDouble(SL*Point,Digits);


Thanks

29.08.2008 22:33 coshzz
Bass wrote:
puncher wrote:

what time frame?

any

Hello Bass,

I am testing the Fuzzy logic EA and for the two first week it made good profits. But when I looked closely at the way it was behaving, my fear became reality this week with a HUGE loosing position of -1000. What happens is that whenever the market goes against the position taken, the EA doesn't have a S/L. That means it lets the market ride with it and you could get in big trouble. Then and if the market reverse and become profitable, then the EA puts a S/L order the same as the entry price, that's why you have so much trades at 0. If the market goes more in the money then a trailing stop loss is trigger at 35 pips. For the past two days EURUSD has been going up, against the sell position taken two days ago by the EA. There is no S/L and i'm now at a projected loss of -1000. How come there is no S/L when into a loosing position ??

Thanks

 

Denis

21.08.2008 18:39 zoront
puncher wrote:

what time frame?

any
31.07.2008 09:36 Bass

what time frame?

30.07.2008 13:01 puncher