Forums Development Q & A For MQ4 Coding Newbies

This topic has been reported for inappropriate content

Viewing 6 posts - 76 through 81 (of 81 total)
  • Author
    Posts
  • #12646
    Anti
    Participant

      Either I’m stupid or I go nuts. For practicing MQ4 programming I’d like to code an indicator which is based on a usual Donchian Channel (DC):

      However, the channel is separated into two channels, a bull channel as well as a bear channel. The bull channel only repaints its position if the upper DC band goes up, the bear channel only if the lower DC band goes down:

      But I have serious problems to transfer the right value for the bull channel if the upper DC goes down and vice versa. Maybe one of you could post a little code example how to solve it. I assume I have to use an if loop, do I?

      #12647
      simplex
      Moderator

        Hi @Anti,

        I’m really not sure whether I got that right. You’re talking about two channels. Do you mean the upper and lower border of one channel or really two channels?

        A little terminology issue: if is a conditional operator, and usually it is not used to create loops first of all. You can do so, but mostly it does not make sense. MQL standard loop operators are for and while.

        If you post your sample I’ll have a look at it. I think for the purpose of practicing this is better than just downloading a working indicator. If you want to go that way you can find thousands of them by just asking Mr. or Mrs. Google.

        simplex

        A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)

        #12648
        Anti
        Participant

          Hi @simplex,

          I’m really talking about two indicators. It is what I concluded from both pictures posted @ FF.

          I can’t show any code as this is the core question of the whole code. But ok, I’ll ask Mr/Mrs Google. Nevertheless, thank you.

          … And here is the proof that I go nuts … I meant for loop …

          • This reply was modified 9 years, 10 months ago by Anti.
          • This reply was modified 9 years, 10 months ago by Anti.
          #12651
          simplex
          Moderator

            Ok,

            It’s just that the pics are so tiny I hardly can identify the details.

            Good luck!

            s.

            A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)

            #12652
            Anti
            Participant

              Sorry. Either right click on it -> open in new tab or use that links for the usual DC and the “advanced” version.

              • This reply was modified 9 years, 10 months ago by Anti.
              #12662
              Anti
              Participant

                Haven’t thought that it is that simple. Just defined two variables within my while loop and handed the value of the one variable over to the other after each cycle …

              Viewing 6 posts - 76 through 81 (of 81 total)
              • You must be logged in to reply to this topic.
              Scroll to Top