Cool... even not a one reply... so here you have .mq4 file. It is the ind. I have told you about. Now can you tell me why there are some single dots not lines?
After putting this ind. wait some time to see that it has counted all the vaules (some lines will be cut) or put it on the chart and restart MT4.
Files:
Give it sometime as we are in the holidays at the moment, you will probably get a reply later this week.
It should be PKlibrary.ex4 file for this indicator.
ok. just remeber... this topic is like samsung: everyone invited!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hiho all forex traders and fellow MT4 programmers,
lately I was working on an indicator which should show me consolidation lines. Here is how it *should* work:
1.There is a cross of 2 MA's (any type i.e. SMA, EMA, etc.);
2.Right after ther cross we start to draw line.
3.When the price (I am using Close) crosses the line we stop drawing the line.
Here is the code I came up with *BUT* it is working strane however. Sometimes only one dot occurs and the ind. stops to draw more (the line I am talking about is made of dots). Can you tell me what is wrong with my code (Corss func. which is imported from my library is excactly the same as one in developing course in this forum, btw. thanks for this course) ?
{
int counted_bars=IndicatorCounted();
//----
time=Bars;
ArrayResize(tempUPL, time);
for(i=time;i>0;i--){
MA1=NormalizeDouble(iCustom(NULL,0,"Moving_Average",MA1Period,MA1Price,MA1Type,0,i),4);
MA2=NormalizeDouble(iCustom(NULL,0,"Moving_Average",MA2Period,MA2Price,MA2Type,0,i),4);
ConsEntry=Cross1(MA1,MA2);
if(ConsEntry!=0){
ConsPrice=iClose(NULL,0,i);
ConsCond=1;
ConsExit = 0;
tempUPL=ConsPrice+(Consolidation/2)*Point;
}
if(ConsCond==1){
if(Cross2(UPL,iClose(NULL,0,i))!=0){
ConsExit=1;
ConsCond=0;
}
}
if(ConsCond==1 || ConsExit==1){
tempUPL=ConsPrice+(Consolidation/2)*Point;
}
if(ConsCond!=0 || ConsExit!=0){
UPL=tempUPL;
} else if (ConsCond==0 && ConsExit==0) {
UPL=0;
}
ConsEntry=0;
ConsExit=0;
}
where Moving_Average is my own version of MA and I know that it is working 100% correctly.
Please help me if you can. Thank you in advance!