Got my code going, but not like I was hoping. - page 2

 
Vladimir Karputov #:This is the worst advice you can give to a beginner! If you are just starting to learn the MQL5 language, you are simply FORBIDDEN (as it will only harm you) to learn 'C/C++'!

That my be your opinion, but it is not mine. Nor am I alone. There many others that have the same opinion as me, and in the same way there are others who have the same opinion as you.

Saying it is FORBIDDEN is arrogance. I gave my advice, and you give your advice. The OP is sufficiently intelligent to make his own decision. There is no such thing as "forbidden"!

 
Fernando Carreiro #:

Yes, you can use iCustom() within another custom indicator, so ignore that comment, please.

Oh yes, I got that wrong... my bad. Thanks for clarifying.


Fernando Carreiro #:

So, I suggest the following. Throw away this code for now. Start by coding the simplest of indicators. The task is basically so that you can learn the basics of how a custom indicator needs to be constructed. How to use the OnCalculate() event handler; how to declare and use buffers, how to use the "rates_total" and "prev_calculated", etc.

As you do this, you can come here and ask questions about what you don't understand, and slowly add more and more functionality to it, until you have reached a level good enough to start coding what you really need for your trading. In the beginning, code only with the aim of learning. Code only the simplest of tasks, even if they are useless. Then progress to more difficult stuff.

The soundest advice!


//From your code:
  
SetIndexBuffer(0, arrowBuffer, INDICATOR_DATA);
   //SetIndexBuffer(1, waeValueBuffer, INDICATOR_DATA);
   //SetIndexBuffer(2, waeDZBuffer, INDICATOR_DATA);
   //SetIndexBuffer(3, waeColorBuffer, INDICATOR_DATA);
To have the color buffer change the color of an indicator diagram it is necessary to declare it as INDICATOR_COLOR in SetIndexBuffer. You have cut the SetIndexBuffer part out. That way the indicator might compile without errors, but you will not have the functionality you wish for.

Do you really need to add Arrows to the Waddah Attar Explosion? Because you could use the color change as your signal right away.
 

Result:



Add: Attention: the indicator should be in the /Indicators folder and its name should be 'Waddah Attar Explosion.mq5'

 
Fernando Carreiro #:

It's not complicated, but it is "complicated" for you at your current skill level. I say this because one can clearly see that there are several basic level things that you don't quite comprehend yet.

That is where I believe you are may misjudging the situation.

That is absolutely true. The reason being that most that are learning MQL, are being driven mostly by greed. And those teaching it in videos and books, are exploiting that greed.

I would recommend you follow resources aimed at learning C and C++. Start by first learning the basics of C/C++ without looking at MQL. Then once you understand the basics, then continue learning C/C++ at the same time as MQL.

What do you mean by "basics?" I mean, I know how datatypes, variables, arrays, loops, and conditional logic works. (Please feel free to correct me if I have made some mistake that shows a lack of knowledge in some area.)

The things that have given me the most confusion are some of the mql specific things. Like how SetIndexBuffer alters the values I get from the buffer, working with rates_total and prev_calculated, etc. Even after reading the documentation, which is often times written in a way that isn't very user friendly to a beginner.

So, I'm not really sure where I should start learning.

I am currently learning Python as well.
 
Vladimir Karputov #:

Result:



Add: Attention: the indicator should be in the /Indicators folder and its name should be 'Waddah Attar Explosion.mq5'


Yes, that is about what it looks like when I put it on a chart, without the colors of course. As you can see, it doesn't plot the trends the way I intended. It's giving Long signals on Short waebars and changing randomly even on bars that don't come above the dz.

My assumption initially was that it had to do with SetIndexBuffer altering the output of the Value and DZ buffers, which is why I commented them out. And after that they seemed to return the correct values, but it still plots incorrectly. So, there must be something wrong with my logic for setting the trend.

Also, I thank you for taking an interest and putting time and effort into helping me. I'm doing my best to learn, but it's a slow process because I find that there is a general lack of quality information for beginners.


Tobias Johannes Zimmer:

My commenting out the SetIndexBuffer sections didn't have to do with preventing compiler errors. It compiled fine, but they altered the values that I was getting from the buffer and making it so I couldn't compare the values properly.

 
Tristen Shaw #: What do you mean by "basics?"

With "there are several basic level things that you don't quite comprehend yet", I am referring to the general functionality of MQL custom indicators and the use of OnCalculate() event handler.

However, I now intend to distance myself from this thread, because I generally clash with Vladimir on a personal level, and would prefer not to have any further confrontations with him (now that he has taken an interest).

In his post #13, he has generously provided you with source code for a complete implementation, which you can study to help you with your learning.

I sincerely wish you all the best with your learning of MQL and your trading!

 
Tristen Shaw # :


Yes, that is about what it looks like when I put it on a chart, without the colors of course. As you can see, it doesn't plot the trends the way I intended. It's giving Long signals on Short waebars and changing randomly even on bars that don't come above the dz.

***

I will give you a template (base, blank). You can add additional conditions and improve the indicator.

 
Vladimir Karputov #:

I will give you a template (base, blank). You can add additional conditions and improve the indicator.

I do thank you for the time you have taken. I'm currently looking over the code and trying to learn from it. I'm starting to understand parts of it already, others will take me a little more time.

I plan on writing it out with my own hands to try and get it into my head.