help on iCustom, error calling 1 buffer - page 2

 
  1. Adebayo Samson Adewuyi #:
    here is one, the sell not working here too IINWMARROWS.mq4  

    You posted an indicator. Indicators can not trade.

  2. Adebayo Samson Adewuyi #:also another with same issue, indicator.mq4 

    Same issue; indicators can not trade.

  3. Where is your EA code referencing either of those indicators?

    Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

    We can't see your broken code.

    Always post all relevant code (using Code button) or attach the source file.

 
William Roeder #:
  1. You posted an indicator. Indicators can not trade.

  2. Same issue; indicators can not trade.

  3. Where is your EA code referencing either of those indicators?

    Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

    We can't see your broken code.

    Always post all relevant code (using Code button) or attach the source file.

I posted my code at the main topic above, I'm sure you can see that. I only added extra indicators if anyone would want to test with others 
 
Adebayo Samson Adewuyi #: I posted my code at the main topic above, I'm sure you can see that. I only added extra indicators if anyone would want to test with others 

No, I can not. You posted code accessing an unknown indicator. Then you posted indicators and not the corresponding EA code.

 
here for the "Indicator" and the code 
void OnTick()
  {
//---
   if(iCustom(Symbol(),0,"indicator",0,1)<Low[1]) // 0 is the buffer that I want a buy order and it works perfetly
      if(OrdersTotal()==0)
         bool k= OrderSend(Symbol(),OP_BUY,0.01,Ask,500,Bid-100*Point,Bid+100*Point,Symbol(),333,0,Blue);



   if(iCustom(Symbol(),0,"indicator",1,1)>High[1])// 1 is the buffer for the sell condition but picks trades on every close of another
      if(OrdersTotal()==0)
         bool k= OrderSend(Symbol(),OP_SELL,0.01,Bid,500,Ask+100*Point,Ask-100*Point,Symbol(),333,0,Red);




/// I ony use one condition at a time because of OrdersTotal()==0

  }
//+------------------------------------------------------------------+
Files:
indicator.mq4  5 kb
 
Here for the "IINWMARROWS" indicator
void OnTick()
  {
//---
   if(iCustom(Symbol(),0,"IINWMARROWS",0,1)<Low[1]) // 0 is the buffer that I want a buy order and it works perfetly
      if(OrdersTotal()==0)
         bool k= OrderSend(Symbol(),OP_BUY,0.01,Ask,500,Bid-100*Point,Bid+100*Point,Symbol(),333,0,Blue);



   if(iCustom(Symbol(),0,"IINWMARROWS",1,1)>High[1])// 1 is the buffer for the sell condition but picks trades on every close of another
      if(OrdersTotal()==0)
         bool k= OrderSend(Symbol(),OP_SELL,0.01,Bid,500,Ask+100*Point,Ask-100*Point,Symbol(),333,0,Red);




/// I ony use one condition at a time because of OrdersTotal()==0

  }
//+------------------------------------------------------------------+
Files:
 
same issue for both indicators and others I have, which was not a problem until of recent
 
  1. Adebayo Samson Adewuyi #: here for the “Indicator” and the code 

    Your indicator “indicator.mq4” is broken.

       int limit = rates_total - prev_calculated;
       ⋮
       for(int i = limit-1; i >= 0; i--)

    After the first run, prev_calculated equals rates_total and the loop never runs.
              How to do your lookbacks correctly #9#14 & #19 (2016)

  2. “IINWMARROWS.mq4” is very old. It also looks at a future bar to paint the current one.  Avoid.

 
William Roeder #:
  1. Your indicator “indicator.mq4” is broken.

    After the first run, prev_calculated equals rates_total and the loop never runs.
              How to do your lookbacks correctly #9#14 & #19 (2016)

  2. “IINWMARROWS.mq4” is very old. It also looks at a future bar to paint the current one.  Avoid.

This can't be the same issue with all my indicators, some that have worked with fine are now giving same issue.

Selling is always the general problem. I think it is of a general problem and not for the indicators

or could it be a malware or something? I just don't knw

 
I am a novice so this may be a wrong advise, but here is my idea. 

RE: your indicator.mq4 that you posted. 
Open your indicator.mq4 in the mql4 editor. You will see this relevent code and returns as listed below. 

You need to Print the returns for your code so you can see what it says in the terminal.  

IE:
      else
        {
         Buffer1[i] = EMPTY_VALUE;
         Print("Buffer1 = ",Buffer1[i]);
        }

         else
        {
         Buffer2[i] = EMPTY_VALUE;
         Print("Buffer2 = ",Buffer2[i]);
        }

Return shows the Buffers are == EMPTY_VALUE which also equals 2147483647.
 
Also the arrays are initialized with EMPTY_VALUE that is also = 2147483647


See my expert terminal return here:
0 10:34:46.343 indicator EURUSD,M5: Buffer1 = 2147483647
0 10:34:46.343 indicator EURUSD,M5: Buffer1 = 2147483647
0 10:34:46.343 indicator EURUSD,M5: Buffer2 = 2147483647
0 10:34:46.343 indicator EURUSD,M5: Buffer1 = 2147483647
0 10:34:46.343 indicator EURUSD,M5: Buffer2 = 2147483647

If this below comparison == true, then it's going to SELL, as will your BUY which is doing the same thing. The Buy = true first this is why it Buys' but then your close trade code that you did NOT post for anyone is likely closing this trade because the SELL is now also true and wants to SELL. 


if(iCustom(Symbol(),0,"indicator",1,1)>High[1])
Code is read from top to bottom so your BUY happens first, and you believe it's working but it's not. That is just a happenstance of the order of the code reading.  
If your return = true it will buy or sell as designed. 

Your close trade code is not shown but I suspect it is doing what is should do when buy or sell condition is true, opening and closing trades as it should because these conditions are true. 

https://www.mql5.com/en/forum/146359
Problem with EMPTY_VALUE - How can I fix a problem with an indicator?
Problem with EMPTY_VALUE - How can I fix a problem with an indicator?
  • 2013.08.15
  • www.mql5.com
Hello, i have a problem with empty_value constant. I have created an indicator which assigns a value to an element in a buffer or it assigns an emppty_value, but when i check the value in expert advisor its value is 2147483647. So what can i use instead of empty_value in indicator
 
Agent86 #:
I am a novice so this may be a wrong advise, but here is my idea. 

RE: your indicator.mq4 that you posted. 
Open your indicator.mq4 in the mql4 editor. You will see this relevent code and returns as listed below. 

You need to Print the returns for your code so you can see what it says in the terminal.  

IE:

Return shows the Buffers are == EMPTY_VALUE which also equals 2147483647.
 
Also the arrays are initialized with EMPTY_VALUE that is also = 2147483647


See my expert terminal return here:
0 10:34:46.343 indicator EURUSD,M5: Buffer1 = 2147483647
0 10:34:46.343 indicator EURUSD,M5: Buffer1 = 2147483647
0 10:34:46.343 indicator EURUSD,M5: Buffer2 = 2147483647
0 10:34:46.343 indicator EURUSD,M5: Buffer1 = 2147483647
0 10:34:46.343 indicator EURUSD,M5: Buffer2 = 2147483647

If this below comparison == true, then it's going to SELL, as will your BUY which is doing the same thing. The Buy = true first this is why it Buys' but then your close trade code that you did NOT post for anyone is likely closing this trade because the SELL is now also true and wants to SELL. 


Code is read from top to bottom so your BUY happens first, and you believe it's working but it's not. That is just a happenstance of the order of the code reading.  
If your return = true it will buy or sell as designed. 

Your close trade code is not shown but I suspect it is doing what is should do when buy or sell condition is true, opening and closing trades as it should because these conditions are true. 

https://www.mql5.com/en/forum/146359
Thanks for your input I appreciate that, firstly I will try and print it out as you have suggested, have tried the Getlasterror function before but it doesn't bring out any error, I will make use of your advice now 
Secondly, even if I removed the Buy conditions totally and I'm left with just the lines for Sell, it will still do the same, and if the Sell lines comes first and the Buy is after, it's still same issue.
Lastly, trades are closed due to Sl or Tp no extra function to close trades 

Thanks once again 
Reason: