Please help me to build this indicator

 

hi everyone

I use two moving average 20 and 50 and I enter to the trade in the pullbacks. In fact, I enter trading after pullbacks  when the price is above 20 (bullish trend) or below 20(bearish trend).

But it is important for me to know How many pullbacks are we in right now?(After the last MovingsCross )


So my question is:

How can I count the number of previous pullbacks after the last MovingsCross ?

(Please give me the mql4 code, i know i should use iLow and ILowest or somethings like that but i need the full code please so please help me with writing this indicator)

like this : 


thank u so much guys

Moving Average - Trend Indicators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
Moving Average - Trend Indicators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
The Moving Average Technical Indicator shows the mean instrument price value for a certain period of time. When one calculates the moving average...
Files:
 
Mohammad vv: I use two moving average 20 and 50 and I enter to the trade in the pullbacks. In fact, I enter trading after pullbacks  when the price is above 20 (bullish trend) or below 20(bearish trend).

But it is important for me to know How many pullbacks are we in right now?(After the last MovingsCross ). So my question is: How can I count the number of previous pullbacks after the last MovingsCross ?

Your first thing to do, is to ask yourself the question ... How do I define a pull-back?

You have to define it in a very detailed and objective way, so that it can be implemented in code. There must be no subjective or incongruent rules to the definition.

Only then can you, start to count them. It is no use asking for code for something so vague as the word "pullback". We humans know what it is but if not properly defined, how are you going to tell a machine to recognise one and then count them.

 
Fernando Carreiro #:

Your first thing to do, is to ask yourself the question ... How do I define a pull-back?

You have to define it in a very detailed and objective way, so that it can be implemented in code. There must be no subjective or incongruent rules to the definition.

Only then can you, start to count them. It is no use asking for code for something so vague as the word "pullback". We humans know what it is but if not properly defined, how are you going to tell a machine to recognise one and then count them.

It can be said that I agree with you But I believe that nothing is impossible

For almost a week now, I have been thinking about how to count the number of pullbacks after the MovingCross, but I have not gotten anything.

So here I am asking for help (requesting the code) to see if anyone can solve this problem...

I hope someone can write this code and solve my problem...


 
Answer the question; how do you define “pullback”. Until you define it in concrete terms, nobody can code it.
 
William Roeder #:
Answer the question; how do you define “pullback”. Until you define it in concrete terms, nobody can code it.

here your answer dear:

Files:
 
Mohammad vv #: here your answer dear:

You show charts and graphics, but you still have not presented a clear, point-by-point recipe for a "pull-back". The code cannot just look at a graph or chart a "just know" what is a pullback.

You have to define it in very clear simple logical and mathematical rules, so that it can be coded. Sit down, take a pencil and paper and write it down. Break it down into steps, and keep breaking down those steps even further until you have a clear, unambiguous logical and mathematical recipe for recognising a pullback.

PS! Yes, I know it is not easy and that is why coders get so irritated when customers just want something done quick and cheap, yet have no idea how difficult and time consuming it is "convert" human terms into something a machine can identify and do. So, take this time to place yourself in the coder's mindset and break it down into steps that can be coded.

 
Fernando Carreiro #:

You show charts and graphics, but you still have not presented a clear, point-by-point recipe for a "pull-back". The code cannot just look at a graph or chart a "just know" what is a pullback.

You have to define it in very clear simple logical and mathematical rules, so that it can be coded. Sit down, take a pencil and paper and write it down. Break it down into steps, and keep breaking down those steps even further until you have a clear, unambiguous logical and mathematical recipe for recognising a pullback.

PS! Yes, I know it is not easy and that is why coders get so irritated when customers just want something done quick and cheap, yet have no idea how difficult and time consuming it is "convert" human terms into something a machine can identify and do. So, take this time to place yourself in the coder's mindset and break it down into steps that can be coded.

In general, I'm looking for a way to count the number of pullbacks since the crossover of all three Moving averages.

Suppose we have three moving average(5,20,50) and if the moving average(5) was above the moving average(20) and the moving average(20) was above the moving average(50), it means that there is an ascending cross, and we have to wait for a pullback to enter the Long Trade:
(When all three moving averages cross each other upwards, the pullbacks should be counted)

Pullback Terms:
1- Close candle[2] is lower than Moving average(5)
2- Close the candle[1] on top of the Moving average(5).
3- Then we enter the long Trade in candle[0]

This is a pullback condition, but I want to know how many pullbacks are we in when this condition was established?
And if we were in pullback-2 or pullback-3 and the conditions of pullback that I defined above were still valid, enter into a long deal.
This is all I need as code
And there really is no more explanation and I hope you can give me the code of this explanation (mql4)
thank you 

 
Mohammad vv #: Pullback Terms:
1- Close candle[2] is lower than Moving average(5)
2- Close the candle[1] on top of the Moving average(5).

Unfortunately your definition of a pull-back described above does not correspond with your chart. On your chart you count 5 pull backs, but according to your definition that would make it at least 12 pull-backs (possibly more) where a candle closing above the MA(5) and the previous closing below it. In other words, your definition is incomplete.


 
Fernando Carreiro #:

Unfortunately your definition of a pull-back described above does not correspond with your chart. On your chart you count 5 pull backs, but according to your definition that would make it at least 12 pull-backs (possibly more) where a candle closing above the MA(5) and the previous closing below it. In other words, your definition is incomplete.


Yes, you are right, let me correct the conditions a bit:


New Pullback Terms:
1- low candle[2] is lower than Moving average(20)
2- Close the candle[1] on top of the Moving average(5).

3- Then we enter the long Trade in candle[0]


is that ok now?

dude i just need to know how should i count the pullback before the current pullback

So do not be too sensitive to the conditions

..

thanks

 
Mohammad vv #: dude i just need to know how should i count the pullback before the current pullback

With that definition, there is nothing to count. On a new bar, if № 1 and № 2 buy.

 

Mohammad vv #: 

dude i just need to know how should i count the pullback before the current pullbac. So do not be too sensitive to the conditions

Then show us your Indicator's initial code so that we can show you how to add the counting part.
Reason: