call start() function manuell by receiving new courses in another currency?

 
Hello,
I want to call manuell the start() function if in another currency a new course has been received.
I have think to check this with the function ArrayCopyRates(aray,symbol,5); whether new courses are received, is the possible, I dont have tried till now?
 
It is better to use Timeseries access functions. I think that iClose meets.
 
Hello, I dont know, ArrayCopyRates() was ok till know, but god to know.
 

Is this possible:

I put a indicator script on the EURUSD and want to get a message/info when a new Tick received for the GBPUSD currency ????

Or must I open for that a GBPUSD Chart in the Terminal a send a message/info from the GBPUSD Chart to the indicator script which is on the EURUSD Chart, if yes with which functions must I do this, please?

I have a solution know, but by this I can only refresh the GBPUSD Datas if in the EURUSD Chart a new Tick received, because then only the start() function is called and before I dont have a technik how I can get know if somethink happend in the other chart, first the start() function must be call, than all code in this start() function will only be execute.

 

If you write your code as a script you can do an endless loop and avoid the "wait for a tick to run the start function".

int start(){

... one time inititalizations...

while(IsStopped == false){

... run code

Sleep(100);

}

return (0);

}

The Sleep() is very important, without it, your script will take 100% CPU and "lock up" MT4.
The example above runs the code 10 times per second, forever.

To get current prices for other pairs, use MarketInfo()

 

This solution with Slepp() dont work for indicators, because the function Sleep() dont work in Indicators.

But thank you much for the idea.

void Sleep( int milliseconds) 
The Sleep() function suspends execution of the current expert within the specified interval.
The Sleep() function cannot be called from custom indicators since they calculate in the interface thread and may not decelerate it.
The checking of the expert stop flag status every 0.1 second has been built into the function.
 


Correct, Sleep() does not work for code compiled as in indicator.

My suggestion is to rewrite the indicator code to execute as a script to accomplish what you desire, that is,
to run code and/or get values of other pairs without waiting for a "tick" in the chart which the indicator
is attached.

 
phy:


Correct, Sleep() does not work for code compiled as in indicator.

My suggestion is to rewrite the indicator code to execute as a script to accomplish what you desire, that is,
to run code and/or get values of other pairs without waiting for a "tick" in the chart which the indicator
is attached.


Hello phy, I think I dont understand what you mean because of my bad english, but if I have understend you right, dan you say that I build a Script and not a Indicator or somethin like.

I must find a way how I can call the start() function in my Indicator script, for that it is possible for my Indicator to get ervery new Tick from every other curency.

Maybe you can give me a little example if you think that is possible.

I am my self are thinking if there is no posibility to programm anythink that call this start funktion every milisekund or so.

 

Indicator code depends on new tick to run code by executing start() function again and again..

Script code executes start() function one time only. If your indicator code is placed within a loop, it will
run continuously.

Example:

//+------------------------------------------------------------------+
//|                                                         Test.mq4 |
//+------------------------------------------------------------------+
 
double GBPUSD;
double EURUSD;
double AUDUSD;
double USDCAD;
double USDJPY;
 
 
 
double ma[100];
 
bool init = true;
 
 
int start(){
 
 
   while(IsStopped() == false){
      
      // This represents the "indicator", it puts current prices into Comments 5 times/second.
      // and draws a moving average on the base chart
      
      int i;
      for( i = 99; i >= 0; i--){
         ma[i] = iMA(Symbol(), 0, 13, 0, 0, 0, i);
      }
      for( i = 98; i >= 0; i--){
         string name = "ma"+i;
         if(ObjectFind(name) != -1) ObjectDelete(name);
         ObjectCreate(name, OBJ_TREND, 0, Time[i+1], ma[i+1], Time[i], ma[i]);
         ObjectSet(name, OBJPROP_RAY, 0);
         
      }
      
      RefreshRates();
      GBPUSD = MarketInfo("GBPUSD", MODE_BID);
      EURUSD = MarketInfo("EURUSD", MODE_BID);
      AUDUSD = MarketInfo("AUDUSD", MODE_BID);
      USDCAD = MarketInfo("USDCAD", MODE_BID);
      USDJPY = MarketInfo("USDJPY", MODE_BID);
 
      Comment("\n" +
              "Time is "+ TimeToStr(TimeLocal(), TIME_DATE|TIME_SECONDS) + "  TickTime = " + GetTickCount() + "\n" +
              "GBPUSD = " + GBPUSD + "\n" +
              "EURUSD = " + EURUSD + "\n" +
              "AUDUSD = " + AUDUSD + "\n" +
              "USDCAD = " + USDCAD + "\n" +
              "USDJPY = " + USDJPY + "\n");
      Sleep(200);
   }
   Comment("Script is stopped");
   return(0);
}

You will have to wait until market opens to see the prices change, so I included Localtime() and GetTickCount() to show it is running without chart ticks being received.

 

Now I understand what you mean.

For my seaching solution it unfortunately dont help me, because I need to drow a indicator in extra window and need all this aktuell curency courses there, that´s just whit a indicator script possible to drawing in a extra window, and of corse other little problems are not happend if one can using a indicator script with Arraybuffers for lines or somethink else I think.

I think that I must use my aktuell solution which must wait for a new tick to can controll if new ticks are happend in the other currencys.

A exaple same is by building homepages whith php, without javascript you dont can do a querry to the server whitout the complete site reload, here ist the problem that one must wait for a received Tickcours till the start() function will be called.

Is is not possible to build a programm that calls the start() function automatic in a indicator script or outside after passing 1 milisekund for example the function GetTickcound() is god for something else? Maybe one can use the Time from this function as Replacement for Sleep()?

 

Sending an update message to the window is another possibility. I've used that before, from a script external to the indicator.

Reason: