Download MetaTrader 5
To add comments, please log in or register
Launch your trading signal and add account monitoring!
s9919
16
s9919 2016.10.11 19:18 

Hi,

Sorry for my poor skills with programming. I have a volume indicator and based on this indicator I would like two arrows to show up. Code for my arrows indicators is shown below which I have taken from this link.

https://www.mql5.com/en/code/7332

#property  indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red


extern bool  ArrowsSignal = true;

int limit=1;int counter;
double CrossUp[];
double CrossDown[];
double prevtime;
double Range, AvgRange;




int init()
{
   SetIndexStyle(0, DRAW_ARROW, EMPTY, 2);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW, EMPTY, 2);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, CrossDown);
   
   return(0);
}

int deinit()
{
   return(0);
}



int start() {

long up=(long)iCustom(NULL,0,"Better_Volume",0,1);
long down=(long)iCustom(NULL,0,"Better_Volume",4,1);
long pinky=(long)iCustom(NULL,0,"Better_Volume",5,1);


for(int i=1;i<=limit;i++){
   
counter=i;
Range=0;
AvgRange=0;
   
for (counter=i ;counter<=i+9;counter++)
     {
      AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
   
Range=AvgRange/10;

if(up > 2500){if(ArrowsSignal == true)CrossUp[i] = Low[i] - Range*0.5;}

if(down > 2500){if(ArrowsSignal == true)CrossDown[i] = High[i] + Range*0.5;}

if ((CrossUp[0] > 2000) && (CrossDown[0] > 2000)) { prevtime = 0; }
if ((CrossUp[0] == Low[0] - Range*0.5) && (prevtime != Time[0]))
    {
     prevtime = Time[0];
}
if ((CrossDown[0] == High[0] + Range*0.5) && (prevtime != Time[0]))
    {
     prevtime = Time[0];
}
}

   return (0);
}

Custom indicator is volume based.

Problem is this code only shows down arrows and only one occurrence for the recently closed candle. How can I see all previous signals ?

Thanks

whroeder1
13644
whroeder1 2016.10.11 19:30  
s9919: only one occurrence for the recently closed candle.
  1. long up=(long)iCustom(NULL,0,"Better_Volume",0,1);
    long down=(long)iCustom(NULL,0,"Better_Volume",4,1);
    long pinky=(long)iCustom(NULL,0,"Better_Volume",5,1);
    
    for(int i=1;i<=limit;i++){
    Perhaps you should use values per bar "i" instead of only bar one.
  2. int limit=1;
    Perhaps you should calculate more than one bar.
s9919
16
s9919 2016.10.11 20:00  
WHRoeder:
s9919: only one occurrence for the recently closed candle.
  1. Perhaps you should use values per bar "i" instead of only bar one.
  2. Perhaps you should calculate more than one bar.

Thanks. It is working for previous bars now. I also fixed it to show blue arrows now.
 But arrows are showing up on each candle instead of proper signal. I have the same checking condition in expert advisor too for same indicator and it works fine with that EA. Somehow it is not working correctly for these arrows.

Files:
vpa.mq4 6 kb
whroeder1
13644
whroeder1 2016.10.12 13:34  
#1
s9919
16
s9919 2016.10.12 17:29  

Thank you for your help.

but I could not understand your answer. I have attached both of the indicators. Arrows are still not working, I tried many times but I do not understand what is wrong with them. The same values work for the EA though.

Files:
arrow.mq4 2 kb
s9919
16
s9919 2016.10.12 17:30  
main indicator
Files:
whroeder1
13644
whroeder1 2016.10.12 18:22  
long up=(long)iCustom(NULL,0,"Better_Volume",0,1);
long down=(long)iCustom(NULL,0,"Better_Volume",4,1);
long pinky=(long)iCustom(NULL,0,"Better_Volume",5,1);

for(int i=1;i<=limit;i++){
What part of "Perhaps you should use values per bar "i" instead of only bar one," is unclear?
s9919
16
s9919 2016.10.12 18:30  
Tried it. does not work still. Thanks
whroeder1
13644
whroeder1 2016.10.12 21:04  
"Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
/
To add comments, please log in or register