fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Custom Indicator - double count at change

    Questions & Answers
    4
    19
    630
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      Domeonline last edited by

      Hi,
      I started to play with fxDreema and want to test a simple strategy. It uses a kind of super trend as a custom indicator. The colour changes with buffer 0 and buffer 1.
      If I display the values both values get fired at the first time the trend changes.
      027fc50c-5012-427a-b751-eb431abf93eb-image.png
      I tested 2 ways both give the same results:
      9d7cae07-f49d-4a0e-bb68-880f8620f6d2-image.png
      Any idea?
      Thanks

      1 Reply Last reply Reply Quote 0
      • jstap
        jstap last edited by

        What value gets returned from the indicator buffer? Put into a comment to see what value you are working with, as for buffer 0 it will always ==, what are you expecting this to tell you?

        Learn fxDreema Without the Wait!

        My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

        The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

        Don’t miss out

        Click here➡️ https://mybook.to/fxDreema to get your copy today!

        Enjoy! 😊

        1 Reply Last reply Reply Quote 0
        • D
          Domeonline last edited by

          Thanks for your reply.
          the system is pretty easy. I have a band and a trend indicator. The trend indicator just changes the color red (buffer 1) to blue (buffer 2).
          I made both now > value 0.1 since it uses price +- a few pips I think.
          image.png
          It's not perfect that I have the double but it should work nevertheless since the idea is it needs to be overbought/oversold first.
          As soon as the price hits the red or green band. Indicated with the thumb up and thumb down
          image.png
          So far I'm using this blocks:
          image.png

          So my next "challenge" will be when I have a thumb down wait for the arrow down 🙂

          1 Reply Last reply Reply Quote 0
          • jstap
            jstap last edited by

            Ok but what values are returned for you to calculate when it has changed?

            Learn fxDreema Without the Wait!

            My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

            The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

            Don’t miss out

            Click here➡️ https://mybook.to/fxDreema to get your copy today!

            Enjoy! 😊

            1 Reply Last reply Reply Quote 0
            • D
              Domeonline last edited by

              Blue Line (up[]):
              Purpose: Represents an uptrend. When the market is in an uptrend, the blue line is displayed.
              Calculation:
              The up[] value is set when the market switches from a downtrend to an uptrend.
              It uses the maxlowprice, which is the maximum low price of the last few bars.
              If the market was in a downtrend and switches to an uptrend, the blue line is adjusted to reflect the maximum low price from previous bars.
              The blue line value is further adjusted with ATR to calculate atrlo[] and atrhi[].

              1 Reply Last reply Reply Quote 0
              • D
                Domeonline last edited by

                // Indicator settings
                #property indicator_chart_window
                #property indicator_buffers 1
                #property indicator_color1 Blue // up[]
                #property indicator_width1 2

                // External parameters
                extern int Amplitude = 2;

                // Indicator buffers
                double up[];

                //+------------------------------------------------------------------+
                //| Custom indicator initialization function |
                //+------------------------------------------------------------------+
                int init()
                {
                IndicatorBuffers(1); // We are only using one buffer for the blue line

                SetIndexBuffer(0, up); // Assign the buffer for the blue line
                SetIndexStyle(0, DRAW_LINE); // Draw it as a line

                SetIndexEmptyValue(0, 0.0); // Set empty value for the buffer

                return(0);
                }
                //+------------------------------------------------------------------+
                //| Custom indicator iteration function |
                //+------------------------------------------------------------------+
                int start()
                {
                double atr;
                double lowprice_i, highprice_i;
                double lowma, highma;
                double maxlowprice;
                bool nexttrend = 0;

                int counted_bars = IndicatorCounted();
                if(counted_bars < 0) return(-1);
                if(counted_bars > 0) counted_bars--;

                int limit = MathMin(Bars - counted_bars, Bars - 1);

                // Loop through each bar
                for(int i = Bars - 1; i >= 0; i--)
                {
                // Get the lowest price and highest price over the amplitude range
                lowprice_i = iLow(Symbol(), Period(), iLowest(Symbol(), Period(), MODE_LOW, Amplitude, i));
                highprice_i = iHigh(Symbol(), Period(), iHighest(Symbol(), Period(), MODE_HIGH, Amplitude, i));

                  // Calculate moving averages for low and high prices
                  lowma = NormalizeDouble(iMA(NULL, 0, Amplitude, 0, MODE_SMA, PRICE_LOW, i), Digits());
                  highma = NormalizeDouble(iMA(NULL, 0, Amplitude, 0, MODE_SMA, PRICE_HIGH, i), Digits());
                  
                  // Calculate ATR
                  atr = iATR(Symbol(), 0, 100, i) / 2;
                  
                  // Initialize maxlowprice
                  if(i == Bars - 1)
                     maxlowprice = lowprice_i;
                  
                  // Check if the trend is up
                  if(nexttrend == 1)
                    {
                     maxlowprice = MathMax(lowprice_i, maxlowprice);
                
                     if(highma < maxlowprice && Close[i] < Low[i + 1])
                       {
                        nexttrend = 0;
                       }
                    }
                  else
                    {
                     maxlowprice = MathMax(lowprice_i, maxlowprice);
                
                     if(lowma > highprice_i && Close[i] > High[i + 1])
                       {
                        nexttrend = 1;
                       }
                    }
                
                  // Set the blue line values if in an uptrend
                  if(nexttrend == 0)
                    {
                     if(i < Bars - 1 && up[i + 1] != 0.0)
                       {
                        up[i] = MathMax(maxlowprice, up[i + 1]);
                       }
                     else
                       {
                        up[i] = maxlowprice;
                       }
                    }
                  else
                    {
                     up[i] = 0.0;
                    }
                 }
                

                return(0);
                }

                S 1 Reply Last reply Reply Quote 0
                • jstap
                  jstap last edited by

                  That is not what I meant, I mean what value is in the buffer, likely indicator appears and is visible will work for you.

                  Learn fxDreema Without the Wait!

                  My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                  The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                  Don’t miss out

                  Click here➡️ https://mybook.to/fxDreema to get your copy today!

                  Enjoy! 😊

                  1 Reply Last reply Reply Quote 0
                  • D
                    Domeonline last edited by

                    Seems that it always has a 0 the first time the trend changes

                    image.png

                    1 Reply Last reply Reply Quote 0
                    • jstap
                      jstap last edited by

                      If you move the arrow to the line as it's going up or across what value does it have?

                      Learn fxDreema Without the Wait!

                      My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                      The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                      Don’t miss out

                      Click here➡️ https://mybook.to/fxDreema to get your copy today!

                      Enjoy! 😊

                      1 Reply Last reply Reply Quote 0
                      • D
                        Domeonline last edited by

                        the same values as in my second post.
                        The lowprice x candles away...

                        image.png

                        1 Reply Last reply Reply Quote 0
                        • jstap
                          jstap last edited by

                          In that case, once per bar - condition buffer == 0 - buy/sell, maybe add a condition so candle id 1 or 2 opposite buffer is != to 0, some combination of this should create a signal.

                          Learn fxDreema Without the Wait!

                          My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                          The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                          Don’t miss out

                          Click here➡️ https://mybook.to/fxDreema to get your copy today!

                          Enjoy! 😊

                          1 Reply Last reply Reply Quote 0
                          • S
                            sktsec @Domeonline last edited by

                            @Domeonline
                            Indicators using start() are often not working well in EA. start() is quite old and rewrite the code with onCalculate() can help

                            1 Reply Last reply Reply Quote 0
                            • l'andorrà
                              l'andorrà last edited by

                              Please look at those few cases when there are two objects indicating both trends were detected. They happen exactly when trend is changing. I'm afraid your indicator is repainting in those circumstances. Are you ready to live with that?

                              (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                              (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                              (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                              1 Reply Last reply Reply Quote 0
                              • jstap
                                jstap last edited by

                                It is not repainting until it recalculates and finds a change, so when both buffers are 0 it is changing direction, meaning previous candle two has a value so you know which direction it has changed to.

                                Learn fxDreema Without the Wait!

                                My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                                The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                                Don’t miss out

                                Click here➡️ https://mybook.to/fxDreema to get your copy today!

                                Enjoy! 😊

                                1 Reply Last reply Reply Quote 0
                                • D
                                  Domeonline last edited by

                                  Thanks to all of you. This was very helpful and I learned a lot. I had issues with the way the buffer worked and was able to change the source code to use chart objects instead.
                                  I will probably post a follow-up soon 🙂

                                  1 Reply Last reply Reply Quote 1
                                  • l'andorrà
                                    l'andorrà last edited by

                                    You changed the code? 😮 That means you are far beyond most of the user of this forum, including myself. 😉

                                    (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                                    (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                                    (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                                    1 Reply Last reply Reply Quote 0
                                    • D
                                      Domeonline last edited by

                                      You would laugh. But chatGPT did the work perfectly 😂

                                      l'andorrà 1 Reply Last reply Reply Quote 0
                                      • jstap
                                        jstap last edited by

                                        I use chatGPT all the time, if you ask it the right question it can work wonders

                                        Learn fxDreema Without the Wait!

                                        My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                                        The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                                        Don’t miss out

                                        Click here➡️ https://mybook.to/fxDreema to get your copy today!

                                        Enjoy! 😊

                                        1 Reply Last reply Reply Quote 1
                                        • l'andorrà
                                          l'andorrà @Domeonline last edited by

                                          @Domeonline I see. 😁

                                          (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                                          (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                                          (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                                          1 Reply Last reply Reply Quote 0
                                          • 1 / 1
                                          • First post
                                            Last post

                                          Online Users

                                          K
                                          M
                                          T
                                          E
                                          A
                                          P
                                          V
                                          R
                                          M
                                          G

                                          24
                                          Online

                                          146.6k
                                          Users

                                          22.4k
                                          Topics

                                          122.6k
                                          Posts

                                          Powered by NodeBB Forums | Contributors