Different Value From iCousom() and Data Windows

 

HI

can someone help me ? I have a problem.

When i use iCousom() for a indicator . in MT4 Data Windows , i can see the indicator values. That changes correctly .

BUT

when i use iCoustom() for use it to return Value in EA . 

the Value id Different in Data Windows and iCoustom() Function .

my indicator has EMPTY_VALUE and Numerical Value  when found signal .

Why does this happen?

I tried a lot but I don't get it

Please Help ME .

Thanks

 
Difficult to judge but it could be for several reasons:
1. Maybe you are loading indicator with different input setting than used in your EA.
2. Maybe you are hovering mouse around the wrong index or accessing the wrong index in EA.
There are many more possibilities and most probably this is due to lack of experience working with the platform.

 
Yashar Seyyedin #:
Difficult to judge but it could be for several reasons:
1. Maybe you are loading indicator with different input setting than used in your EA.
2. Maybe you are hovering mouse around the wrong index or accessing the wrong index in EA.
There are many more possibilities and most probably this is due to lack of experience working with the platform.

Thanks For Reply

About number one : I put the default settings in ICoustom() . Nothing Write in Parameter in ICustom() . this is Defult is true ?

About number Two : This indicator has 2 Buffer and 2 Lable in Data Windows . when i write in iCustom() . i selected 0 and 1 for Address .

I do the same for other indicators and it gives correct information .

 i use for Test Strategy Tester . in Strategy  Tester  in wrong .

 
Moh Roc:

HI

can someone help me ? I have a problem.

When i use iCousom() for a indicator . in MT4 Data Windows , i can see the indicator values. That changes correctly .

BUT

when i use iCoustom() for use it to return Value in EA . 

the Value id Different in Data Windows and iCoustom() Function .

my indicator has EMPTY_VALUE and Numerical Value  when found signal .

Why does this happen?

I tried a lot but I don't get it

Please Help ME .

Thanks

The values in the data window update every tick.  Depending on your use of icustom you maybe comparing with an every bar value
 
Paul Anscombe #:
The values in the data window update every tick.  Depending on your use of icustom you maybe comparing with an every bar value

thanks Paul

yes when  tick is  update ,  my code is in OnTick() Function and The result is checked .

i have 2 Result . 1- nothing show in Labe Data Windows and this is 0.0 or Empty_Value .

                         2- Numerical Value .

when compare Numerical in EA and Data Windows . it is incorrect and EA has Wrong Calculate .

 i use for Test Strategy Tester . in Strategy  Tester  in wrong .

 
Moh Roc #: About number one : I put the default settings in ICoustom() . Nothing Write in Parameter in ICustom() . this is Defult is true ?
You think you did, but since you haven't shown us any of your code, we can't help you.
 
William Roeder #:
You think you did, but since you haven't shown us any of your code, we can't help you.
void OnTick()
  {
//---
   double DefineBuy = iCustom(Symbol(),PERIOD_CURRENT,"SA",0,1);
   if(DefineBuy != EMPTY_VALUE)
     {
      Print("This is Buy Value : ",DefineBuy);
      int BuyPosition = OrderSend(Symbol(),OP_BUY,0.01,Ask,20,0,0,"TEST IDICATOR",0,0,clrBlue);
     }
   double DefineSell = iCustom(Symbol(),PERIOD_CURRENT,"SA",1,1);
   if(DefineSell != EMPTY_VALUE)
     {
      Print("This is Sell Value : ",DefineSell);
      int BuyPosition = OrderSend(Symbol(),OP_SELL,0.01,Bid,20,0,0,"TEST IDICATOR",0,0,clrBlue);
     }
  }


ok I send this simple Code and image Attached. i selected error by red color .

Thanks

Files:
xauusd-m1.png  33 kb
 
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Moh Roc: my indicator has EMPTY_VALUE and Numerical Value  when found signal .

    How do you know it uses EMPTY_VALUE for no signal, as opposed to, say, zero? You haven't shown us any of your indicator code.

  3. Your image show many open orders on one candle. So your code works, as written. Either wait for a new bar, and/or a change of signal.

    1. For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
                MT4: New candle - MQL4 programming forum #3 (2014)
                MT5: Accessing variables - MQL4 programming forum #3 (2022)

      I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
                Running EA once at the start of each bar - MQL4 programming forum (2011)

    2. You are looking at a signal (opening one order per tick). Act on a change of signal.
                Too many orders - MQL4 programming forum #1 (2017)

Reason: