Multicurrency advisor question - page 7

 
Okay! I will look into it now. But the tester doesn't know what instrument the EA is attached to.
 

datetime iTime( string symbol, int timeframe, int shift)

Returns time value of the bar opened from the corresponding chart (symbol, timeframe). In the case of error the function returns 0. For more information about the error call GetLastError(). The information about the open time of each bar for the current chart is located in the predefined array Time[]. Parameters: symbol - symbol name of the instrument. NULL means current symbol. timeframe - Period. Can be one of the chart's periods. 0 means period of the current chart. shift - Index of timeframe value (shift relative to current bar by specified number of periods back).

---------------------------------------------------------------------------------------------------------------------

As far as I understand it, you should first set, for example:

static int prevtimeEURUSD = 0;

then insert it into the code of the needed pair

double TTTTTT=iTime("EURUSD",60,0); 
if(TTTTTT == prevtimeEURUSD) 
       return(0);
   prevtimeEURUSD = TTTTTT
 
rid:

...

As far as I understand it, you have to first set, for example:

static int prevtimeEURUSD = 0;

then insert it into code of the pair we need

double TTTTTT=iTime("EURUSD",60,0); 
if(TTTTTT == prevtimeEURUSD) 
       return(0);
   prevtimeEURUSD = TTTTTT

Yes. See how it's done in ProtoType (Rosh). Tried to insert a link, something didn't go through (find it by searching in CodeBase). The isNewBar() function has a two-dimensional array for this - order is great power!
 
Thank you! I have this expert. I'll have a look at it now.
 
Dear Klerk!
I want to make a multi-currency indicator, e.g. two pairs. First, the quotes of these pairs should be brought to a single form (for example, to convert them to percentage change, i.e. (Close[i]-Close[i+1])/100% - is it right?), and then, if I want to see the dynamics of the difference between them, I should introduce them in the indicator. How to do it???
 

If you want the dynamics of the difference, you don't need to convert it to a percentage, you can do it like this:

int start(){
 
 double Point1 = MarketInfo("GBPUSD",MODE_POINT);
 double Point2 = MarketInfo("USDJPY",MODE_POINT);
 
 
 MacdBuffer[0] = iMACD("GBPUSD",0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)/Point1
              + iMACD("USDJPY",0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)/Point2;
     Comment("MACD "+MacdBuffer[0]);         
 
return(0);
}
 
Thank you so much, Xeon!!!! I'll give it a try!
 
Xeon! If you don't mind dropping what you need on top from start.... Because, I'm still a dummy!!!
 
nido:
Xeon! If you're not hard, drop what you need from the top of the start... Because I'm still a dummy!!!


Actually this was written in a couple of minutes in a test script (to test blocks of code)

Had to sketch an indicator for you :-)

//+------------------------------------------------------------------+
//|                                                    MultyMACD.mq4 |
//|                                           Copyright © 2007, xeon |
//|                                                       xeon@nm.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, xeon"
#property link      "xeon@nm.ru"
 
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_width1  2
//---- buffers
double MacdBuffer[];
double SignalBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init(){
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,MacdBuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,SignalBuffer);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexLabel(0,"MACD");
   SetIndexLabel(1,"Signal");
   IndicatorShortName("MultyMACD");
     
 
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start(){
 
   if(IsOptimization()==true || IsTesting()==true){Comment("В тестере будет ошибка деления на 0. описано - в справке по MarketInfo");return(0);}
//----
 double Point1 = MarketInfo("GBPUSD",MODE_POINT);
 double Point2 = MarketInfo("USDJPY",MODE_POINT);
 
 
 MacdBuffer[0] = iMACD("GBPUSD",0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)/Point1
              + iMACD("USDJPY",0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)/Point2;
 
 for(int i=9;i>=0;i--){
     SignalBuffer[0]=iMAOnArray(MacdBuffer,0,9,0,MODE_SMA,i);
 }
  
//----
   return(0);
  }
//+------------------------------------------------------------------+

I hope you will figure it out

p.s. keep in mind that this indicator will only work online, on the history you will need to create a loop

 
xeon:
nido:
Xeon! If you're not hard, drop what you need from the top of the start... Because I'm still a dummy!!!


Actually this was written in a couple of minutes in a test script (to test blocks of code)

Had to sketch an indicator for you :-)

//+------------------------------------------------------------------+
//|                                                    MultyMACD.mq4 |
//|                                           Copyright © 2007, xeon |
//|                                                       xeon@nm.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, xeon"
#property link      "xeon@nm.ru"
 
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_width1  2
//---- buffers
double MacdBuffer[];
double SignalBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init(){
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,MacdBuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,SignalBuffer);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexLabel(0,"MACD");
   SetIndexLabel(1,"Signal");
   IndicatorShortName("MultyMACD");
     
 
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start(){
 
   if(IsOptimization()==true || IsTesting()==true){Comment("В тестере будет ошибка деления на 0. описано - в справке по MarketInfo");return(0);}
//----
 double Point1 = MarketInfo("GBPUSD",MODE_POINT);
 double Point2 = MarketInfo("USDJPY",MODE_POINT);
 
 
 MacdBuffer[0] = iMACD("GBPUSD",0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)/Point1
              + iMACD("USDJPY",0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)/Point2;
 
 for(int i=9;i>=0;i--){
     SignalBuffer[0]=iMAOnArray(MacdBuffer,0,9,0,MODE_SMA,i);
 }
  
//----
   return(0);
  }
//+------------------------------------------------------------------+

I hope you will figure it out

p.s. keep in mind this indicator will only work online, on the history you will need to create a loop

THANK YOU, Xeon!!! May I write you a private message regarding the idea of an EA? My E-mail: ni_do@mail.ru
Reason: