Reference to an Indicator - page 3

 
Paul Anscombe #:
and you are insisting on complicating it with includes

I don't know any other way to write more than 100 function and use them by others indicators, is there any way? (Is it ok to you to write 100 functions in every indicator and if you need change you have to change all of them...)

(I'm sorry for my English, I'm not very good at it)

 
Asa Sh #: if I need a data of A.ex5 in OnInit() part of B.ex5 what should I do?

When in doubt, think!

bool isFirstTick;
int OnInit(){ isFirstTick=true; 
   // get handle of A.ex5
   ⋮
}
void OnTick(){
   if(isFirstTick){ 
      isFirstTick=false; 
     // get data of A.ex5 in OnInit()
   }
 
William Roeder #:
When in doubt, think!

Thanks, but I have tried it, it doesn't work because it takes time to call Indicator A, so by this 

William Roeder #:
if(isFirstTick){

it can't call and get data and so it gets back to error code 4806

 
Asa Sh #:

Thanks, but I have tried it, it doesn't work because it takes time to call Indicator A, so by this 

it can't call and get data and so it gets back to error code 4806

If you implement it correctly then it will not request indicator data until the indicator is ready, then you will not get an error.

 
Paul Anscombe #:
If you implement it correctly then it will not request indicator data until the indicator is ready, then you will not get an error.

would you pls tell me how to say "indicator A is ready or not" or "implement it correctly"?

I tried :

while(GetLastError() == 4806)

but it just made it worst.

 
Paul Anscombe #:

If you implement it correctly then it will not request indicator data until the indicator is ready, then you will not get an error.

I get a, b, c, d points in indicator A (based on MN), then I use them in indicator B (based on D1)

I use a, d, c, d to draw Main Trend then based on them I draw minor trend,

for example in candle 100 D1 I have to know b and c first then I draw minor trend up or down by functions. 

so before I start to count bars in D1, I need MN data and its corresponding bars in D1, after that I start to count bars in D1 and draw minor trend

I don't want to calculate  a, d, c, d in every ticket or every candle of D1
Files:
Untitled.png  51 kb
 
Asa Sh #:
put B.mq5 in the chart, it should print the data of A.mq5 in candle but it refers error.

for iCustom to work correctly, it's imperative that you place your indicators in the correct directory


For example I made my own directory called "Custom" which is inside "[data folder]\MQL5\Indicators" where I place the ex5 indicator runnables, and then I use iCustom like this without fail:

iCustom(Symbol(), Period(), "Custom\\iStochastic_with_shift", per1, 45, 50, 14, MODE_EMA, StoPrice_field, shift); 
 
Conor Mcnamara #:

for iCustom to work correctly, it's imperative that you place your indicators in the correct directory


For example I made my own directory called "Custom" which is inside "[data folder]\MQL5\Indicators" where I place the ex5 indicator runnables, and then I use iCustom like this without fail:

thanks, this part of the code was solved by Paul Anscombe,

now the problem is how to get A data in OnInit() part instead of OnCalculate() or how to get data in OnCalculate() just once.

Reference to an Indicator
Reference to an Indicator
  • 2024.05.09
  • Asa Sh
  • www.mql5.com
Hi I have an indicator(A.ex5) and I want to reference it in an include file (C.mqh) or another indicator (B...
 
Asa Sh #:

thanks, this part of the code was solved by Paul Anscombe,

now the problem is how to get A data in OnInit() part instead of OnCalculate() or how to get data in OnCalculate() just once.

The problem is in your design.  You are insisting on getting data during oninit. When have told you that will not work 
 
Paul Anscombe #:
The problem is in your design.  You are insisting on getting data during oninit. When have told you that will not work 

I'm not insisting on any thing :)

I have wrote it in MQL4 and it works fine, so I thought it's similar in MT5 but it's not.

would you pls tell me how to get A data in OnCalculate() just once and not on every ticket?