help on iCustom, error calling 1 buffer - page 4

 
Agent86 #:

Somehow the Print function is getting suppressed so I can't diagnose this any further. 

Your iCustom comparisons are always true that much I know.
I'm not sure if this is why there is some conflict in milliseconds for the Print function that is not being read by the terminal or something else. 

I can comment/omit your comparisons and Print function calls anything I want as it should, but when inserting your code only a few lines of Print calls can be read, and NO print calls withing the code block comparison are being read not even the GetLastError. 

GetLastError does read in the tester but not the print calls. I'm not sure why. 



when you run the indicator in an expert, did you have the same issues with the sell?

 
There were multiple problems with buy sell and Print function errors. 

One thing for sure is that your iCustom comparison is returning EMPTY_VALUE. 

To work around this you can do something like this perhaps
This will trade both directions, but I'm not sure it's the value your wanting. You have to double check this against the indicator. 

Anyhow this works on the demo and trades both directions as it should. 
IE:
//---
   

   for (int i=0; i<100; i++)
      {
      indicator_low = iCustom(Symbol(),0,"indicator",0,i);
      if (indicator_low != EMPTY_VALUE)
         {
         Print("Low ",indicator_low);
         }
         if(iCustom(Symbol(),0,"indicator",0,i)<Low[1])
            {
            if(OrdersTotal()==0)
               {
               int k= OrderSend(Symbol(),OP_BUY,0.01,Ask,500,Bid-100*Point,Bid+100*Point,Symbol(),333,0,Blue);
               Print("Error opening BUY order : ",GetLastError());
               }
             }
         }

   for (int i=0; i<100; i++)
      {
      indicator_high = iCustom(Symbol(),0,"indicator",1,i);
      if (indicator_high != EMPTY_VALUE)
         {
         Print("High ",indicator_high);
         }
         if(iCustom(Symbol(),0,"indicator",1,i)>High[1])
            {
            if(OrdersTotal()==0)
               {
               int k= OrderSend(Symbol(),OP_SELL,0.01,Bid,500,Ask+100*Point,Ask-100*Point,Symbol(),333,0,Red);
               Print("Error opening SELL order : ",GetLastError());
               }
             }
         }
      
 
Agent86 #:
There were multiple problems with buy sell and Print function errors. 

One thing for sure is that your iCustom comparison is returning EMPTY_VALUE. 

To work around this you can do something like this perhaps
This will trade both directions, but I'm not sure it's the value your wanting. You have to double check this against the indicator. 

Anyhow this works on the demo and trades both directions as it should. 
IE:

I am think that this error is only on the tester, because if it works on Demo then why the problem on tester?

 
Your code was not working on tester or the demo.

The for loops I provided do not produce errors; and trade in both directions for the tester and the demo.

 
I am not exactly sure which part of your code the terminal didn't like since the Print returns were different on the demo and the tester. Some Print returns were surpress as well and I was expecting to get a read of the return.

Reposting your referenced code for reference: 
//---
   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

  }
//+------------------------------------------------------------------+
So here is what I can say about the code you posted regarding indicator.mql4
I can say that iCustom is almost always receiving an EMPTY_VALUE in the buffer for both buffers all the time. 

So in your code when you compare iCustom<Low[1] or iCustom >High[1] here is what your comparing:

EMPTY_VALUE<Low[1] always false except when the buffer gets a value other then EMPTY_VALUE. 
or
EMPTY_VALUE>High[1] always true, except when buffer gets a value other then EMPTY_VALUE


NOTE:
EMPTY_VALUE == 2147483647 it will always be greater then High[1] and never greater then Low[1] generally speaking.

You can use the Print function to see this for yourself. 

This is mostly the problem with your code. 

So the question is:
Why exactly is your posted code giving the results or reaction that we are seeing in the terminal ?  

I am not experienced enough to understand why it's reacting this way but this doesn't change the dysfunction of the code that we can see. 
Why this false condition can BUY while the true condition seems to open and close for reasons I don't completely understand but only see that the code blocks are dysfunctional.

My idea:
I assume this code is confusing the interpreter somehow.
Understanding why it's reacting this way is not as important as understanding the broken code and fixing it. 

Someone might sort the reasoning behind the results later, but for now you can change the code so that your not comparing something with EMPTY_VALUES unless you intend to compare with EMPTY_VALUES. 

I hope this helps for now, 
Perhaps someone can explain why the interpreter is doing what it's doing but for now you should have what you need to fix your codes.  
 
 
Agent86 #:
There were multiple problems with buy sell and Print function errors. 

One thing for sure is that your iCustom comparison is returning EMPTY_VALUE. 

To work around this you can do something like this perhaps
This will trade both directions, but I'm not sure it's the value your wanting. You have to double check this against the indicator. 

Anyhow this works on the demo and trades both directions as it should. 
IE:

I tried you code above, see the results below, it picks trades continuously after each arrow,

is it same as your end


Thanks 

Files:
Capture.PNG  36 kb
 

@Agent86

Please can you help me with one last thing. This thing is making me go nut, help me run this indicator attached into an Ea from your end there and see if all works well. I tried here it was still same issue I'm having with others. Let me know if works well on your tester. it is an up and down arrow indicator

Thank you

Files:
PCount.zip  19 kb
 
Adebayo Samson Adewuyi #:

I tried you code above, see the results below, it picks trades continuously after each arrow,

is it same as your end


Thanks 

Yes that is what your coded does. 
I posted the fix and explained why already. 
Please read previous post with "for loops" 


Also your Pcount.zip folder ONLY contains the .ex4 indicator.  This .ex4 needs to be decompiled so you can get the .mq4 file. 
Unless you have the mq4 file then you can post that instead. 
Without the .mq4 file I can't see the code to determin iCustom requirements. 

Just fyi. 


 
Agent86 #:

Yes that is what your coded does. 
I posted the fix and explained why already. 
Please read previous post with "for loops" 


Also your Pcount.zip folder ONLY contains the .ex4 indicator.  This .ex4 needs to be decompiled so you can get the .mq4 file. 
Unless you have the mq4 file then you can post that instead. 
Without the .mq4 file I can't see the code to determin iCustom requirements. 

Just fyi. 


Hi, thank you so much for you time trying to solve this issue together 
I have some points to clear

1) The for loop solution you posted didn't work at my end here, hence why I attached the screenshot for you to see. Infact it made the buy just like the issue we are having with the sell. That's why I asked if it's working perfectly there and I can see from your post it does. 
Now I'm thinking if this issue is related to my pc or not because every of my arrow custom indicators are having same issue presently 

2) and to know if it's my pc that's why I added the executable file if you could help me test if that works well too( I dont have the source code any longer) but the buffers used are 0 and 1
If you could help me test, I will appreciate that alot,

3) or  if you have any arrow indicators that works well, you can help me send and let me run it here to see how it will turn out to be 

So if point (2) works well on your pc and (3) failed to here, then maybe we can conclude that the issue is from my pc 

Thank you for your assistance 
 

Hi @Agent86 and everyone, thanks for your support

I found let me say a temporary solution to the issue at hand for the iCustom function. I will include the code

#property strict
int Bop, Sop;
datetime bartime;
enum Sig
  {
   blue,
   red,
   none,
  };


string Signal="";
double v1=0, v2=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//
   v1=iCustom(Symbol(),Period(),"indicator",0,1);
   v2=iCustom(Symbol(),Period(),"indicator",1,1);


   if(v1>0.00001 && v1<20000000)
     {
      if(OrdersTotal()==0)
        {
         int k= OrderSend(Symbol(),OP_BUY,0.01,Ask,500,Bid-30*Point,Bid+30*Point,Symbol(),333,0,Blue);
         //Print("Error opening BUY order : ",GetLastError());
        }
     }



   if(v2>0.00001 && v2<20000000)
     {
      if(OrdersTotal()==0)
        {
         int k= OrderSend(Symbol(),OP_SELL,0.01,Bid,500,Ask+30*Point,Ask-30*Point,Symbol(),333,0,Red);
         //Print("Error opening SELL order : ",GetLastError());
        }
     }


  }
//+------------------------------------------------------------------+
 
Adebayo Samson Adewuyi #:

Hi @Agent86 and everyone, thanks for your support

I found let me say a temporary solution to the issue at hand for the iCustom function. I will include the code

This above method works perfectly just the normal way


so what could be the problem for the "High" call not to work perfectly. recently I wrote some mql5 code and sent to someone the person was unable to use it and problem was due to Os 32bit and Os64 bit

My pc is 64 his own was 32, according to his explanation he said he could not update his mt5 to the latest due to the 32bit operating system and the Ea was built with the latest 64 bit mt5 update. now to get the issue solved he updated the system to a 64 bit and this same EA start working


with this now I am thinking as my mt4 version is on 32bit giving me this issue, could that be the problem

can any of the Admins or moderators confirm this just to be sure, because this issue just started all of a sudden and I can say it is not related to code problem or bugs but something more general, either My Pc, Os or the Mt4

Thanks
Reason: