Discussion of article "Learn how to design a trading system by Fractals"

 

New article Learn how to design a trading system by Fractals has been published:

This article is a new one from our series about how to design a trading system based on the most popular technical indicators. We will learn a new indicator which Fractals indicator and we will learn how to design a trading system based on it to be executed in the MetaTrader 5 terminal.

1. Fractals highs and lows

    Based on this strategy we need to create a trading system that can be used to return the highs and lows of the Fractals indicator as a comment on the chart by continuously checking the fracUpvalue and the fracDownValue. If the fracUp is greater than zero or it has no empty value and the fracDown has an empty value, we need the trading system to return a signal on the chart as a comment with the following value:

      • Fractals High around: n

    In the other case, if the fracDown is greater than zero or it has no empty value and the fracUp has an empty value, we need the trading system to return a signal on the chart as a comment with the following value:

      • Fractals Low around: n

    The following is the blueprint of this strategy:

    Fractals highs and lows blueprint


      Author: Mohamed Abdelmaaboud

       


      Thanks to the author. Everything is very well explained in the articles. I myself do not exclude - that the code on fractals signals and Ma will take to complete it with something else - for example, the speed of ticks for his stock scalper robot. And on ticks can do everything at all - and maybe on m1. You can also a la averaging purely on rebounds from fractals and trawl on the first ts here also something to finish. In general, I respect the author for useful articles on these topics!
       

      Please, answer the questions.

      1. Why do you use the Fractal's value on the 2nd closed bar? It's not formed yet. I think you should use the 3rd closed bar value:

         CopyBuffer(fracDef,UPPER_LINE,3,1,fracUpArray);
         CopyBuffer(fracDef,LOWER_LINE,3,1,fracDownArray);

      2. Why do you call them trading systems? They don't make trades. Only comments on the chart.

       
      Ivan Titov #:

      Please, answer the questions.

      1. Why do you use the Fractal's value on the 2nd closed bar? It's not formed yet. I think you should use the 3rd closed bar value:

      2. Why do you call them trading systems? They don't make trades. Only comments on the chart.

      Current candle is 0, the previous one is 1, and the third is 2 not 3.

      Trading systems as they programmed based on systematic and logical steps to help you to trade even if they are comments, You can add sending orders if you tested them and found them useful for you.

       
      Mohamed Abdelmaaboud #:

      Current candle is 0, the previous one is 1, and the third is 2 not 3.

      The 3rd closed candle is 3. The current candle (0) is not closed yet, and using it could give many false entries, especially when it has recently opened.

       

      Hi, I have taken the liberty of implementing your example "Fractals_with_Alligator" in the functions provided for this purpose (declaration/definition). Please correct me if I amwrong😊

      //creating arrays
      double   fracUpArray[];
      double   fracDownArray[];
      MqlRates priceArray[];
      double   jawsArray[];
      double   teethArray[];
      double   lipsArray[];
      // init
      int      fracDef;
      int      Data;
      int      alligatorDef;
      //get values
      double   fracUpValue;
      double   fracDownValue;
      double   closingPrice;
      double   jawsValue;
      double   teethValue;
      double   lipsValue;
      //creating bool variables to aviod buy ans sell signals at the same time
      bool     isBuy;
      bool     isSell;
      
      int OnInit() {
      //creating bool variables to aviod buy ans sell signals at the same time
         isBuy    = false;
         isSell   = false;
      
         ArraySetAsSeries(fracUpArray, true);
         ArraySetAsSeries(fracDownArray, true);
         ArraySetAsSeries(jawsArray, true);
         ArraySetAsSeries(teethArray, true);
         ArraySetAsSeries(lipsArray, true);
      
         fracDef        =  iFractals(_Symbol, _Period);
         Data           =  CopyRates(_Symbol, _Period, 0, 3, priceArray);
         alligatorDef   =  iAlligator(_Symbol, _Period, 13, 8, 8, 5, 5, 3, MODE_SMMA,PRICE_MEDIAN);
      
      
         return(INIT_SUCCEEDED);
      }
      
      void OnTick() {
      
         CopyBuffer(fracDef, UPPER_LINE, 2, 1, fracUpArray);
         CopyBuffer(fracDef, LOWER_LINE, 2, 1, fracDownArray);
         CopyBuffer(alligatorDef, 0, 0, 3, jawsArray);
         CopyBuffer(alligatorDef, 1, 0, 3, teethArray);
         CopyBuffer(alligatorDef, 2, 0, 3, lipsArray);
      
      //get values
         fracUpValue    = NormalizeDouble(fracUpArray[0], 5);
         fracDownValue  = NormalizeDouble(fracDownArray[0], 5);
         closingPrice   = priceArray[0].close;
         jawsValue      = NormalizeDouble(jawsArray[0], 5);
         teethValue     = NormalizeDouble(teethArray[0], 5);
         lipsValue      = NormalizeDouble(lipsArray[0], 5);
      
      //conditions of the strategy and comment on the chart
      //in case of buy
         if(lipsValue>teethValue && lipsValue > jawsValue && teethValue > jawsValue
            && closingPrice > teethValue && fracDownValue != EMPTY_VALUE) {
            Comment("Buy", "\n",
                    "jawsValue = ", jawsValue, "\n",
                    "teethValue = ", teethValue, "\n",
                    "lipsValue = ", lipsValue, "\n",
                    "Fractals Low around: ", fracDownValue);
            isBuy = true;
         } // end if
      //in case of sell
         if(lipsValue < teethValue && lipsValue < jawsValue && teethValue < jawsValue
            && closingPrice < teethValue && fracUpValue != EMPTY_VALUE) {
            Comment("Sell", "\n",
                    "jawsValue = ", jawsValue, "\n",
                    "teethValue = ", teethValue, "\n",
                    "lipsValue = ", lipsValue, "\n",
                    "Fractals High around: ", fracUpValue);
            isSell = true;
         } // end if
      }
      
      void OnDeinit(const int reason) {
         EventKillTimer();
         ObjectsDeleteAll(0,0,-1);
      
         IndicatorRelease(fracDef);
         IndicatorRelease(Data);
         IndicatorRelease(alligatorDef);
         
         ArrayFree(fracUpArray);
         ArrayFree(fracDownArray);
         ArrayFree(jawsArray);
         ArrayFree(teethArray);
         ArrayFree(lipsArray);
      
         Comment("");
      }
       

      Hi , thank you for such a clear article... i getting an error in my fractal code  (2024.11.10 17:42:12.121 _24 Dev 3 EA Strat1 (EURUSD,H1) _24 Dev 3 EA Strat1.mq5:void OnDeinit(const int):OnDeinit:48 Error Code:INDICATOR_DATA_NOT_FOUND )  .

      When running your code i get the same error .


      Can you please help. I have tried lots of different combinations .


      Appreciate the support .

      Jay