Issue to use iCustom function

 

Hi,

I'm trying to add the "ary-aind-indicator" to my expert using the iCustom function

double  Val=iCustom(Symbol(),0,"ary-aind-indicator",27,0,1);

The indicator is very simple : green bars appears when there is a bullish momentum, and red for bearish momentum. And th indicator returns the bar value which positive for green bars, and negative for red bars. The indicator take one input which the period initially set by default at "27", and have 3 buffers ( for sell and buy, 1 for buy only, and 2 for sell only) from what I understand.

My approach is very simple : if Val > 0 which means green bar the expert should open long position.

           if Val < 0 which means red bar the expert should open short position.

So here my issue, sometimes the expert opens short position when Val > 0 (green bar), or the opposite long position when Val < 0 (red bar). Also sometimes it takes the expert 3 or 4 bars turning to green to open a long position which should not happen because the shift is set to "1", the position must open when the first green bar appears.

below here my code (T1 and T2 are used to open one single trade they both initially set at zero and receive incrementation++ when a position is opened. Also find below the indicator and a back test screen shot that shows how it took the expert 3 green bars to open a long position

   if (T1==0 &&( Val > 0 ))
   {
      PP1=Bid;
      ticket11=OrderSend(Symbol(),OP_BUY,lots1,Ask,0,PP1-(100*10*Point),PP1+(100*10*Point),"Buy",magic,0,Red);
      Alert("Niveau PP atteint");
      SendMail("Buy N1", Symbol()+TimeToStr(TimeLocal(),TIME_SECONDS));
      SendNotification("Buy N1"+ ThePair);
   }
   
   if (T2==0 && ( Val < 0))
   {
      PP1=Bid;
      ticket12=OrderSend(Symbol(),OP_SELL,lots1,Bid,0,(PP1+S)+(100*10*Point),(PP1+S)-(100*10*Point),"SELL",magic+1,0,Red);
      Alert("Niveau PP atteint");
      SendMail("Sell N1", Symbol()+TimeToStr(TimeLocal(),TIME_SECONDS));
      SendNotification("Sell N1"+ ThePair);
   }
Files:
 
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
 
SilentControl77:

Hi,

I'm trying to add the "ary-aind-indicator" to my expert using the iCustom function

The indicator is very simple : green bars appears when there is a bullish momentum, and red for bearish momentum. And th indicator returns the bar value which positive for green bars, and negative for red bars. The indicator take one input which the period initially set by default at "27", and have 3 buffers ( for sell and buy, 1 for buy only, and 2 for sell only) from what I understand.

My approach is very simple : if Val > 0 which means green bar the expert should open long position.

           if Val < 0 which means red bar the expert should open short position.

So here my issue, sometimes the expert opens short position when Val > 0 (green bar), or the opposite long position when Val < 0 (red bar). Also sometimes it takes the expert 3 or 4 bars turning to green to open a long position which should not happen because the shift is set to "1", the position must open when the first green bar appears.

below here my code (T1 and T2 are used to open one single trade they both initially set at zero and receive incrementation++ when a position is opened. Also find below the indicator and a back test screen shot that shows how it took the expert 3 green bars to open a long position

This is a version of yurik indicator, a famous indicator which repaint, it look good, but it do not work.

do some reseach about repainting indicator