Multicurrency advisor question - page 2

 

alexjou, I looked at the help and found:

"The extern memory class defines an external variable. The extern modifier is specified before the data type. Extern variables define the input parameters of a program, they are accessible from the program properties window. Arrays cannot act as external variables. "

Here is all code of custom indicator.

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_minimum 0
#property indicator_maximum 100
//---- input parameters
//extern string    st="---Параметры Stochastic---";
extern int       KPeriod =12;
extern int       DPeriod =3;
extern int       Slowing =2;
//extern string    en="---Параметры Envelopes---";
extern int       EnvPeriod=17;
extern int       Deviation=15;
extern int       Shift=1;
//---- buffers
double Stochastic[];
double UP[];
double LOW[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Stochastic);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,UP);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,LOW);
//----
   return(0);
  }
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
     int limit;
     int counted_bars=IndicatorCounted();
  //---- последний посчитанный бар будет пересчитан
     if(counted_bars>0) counted_bars--;
     limit=Bars-counted_bars;
  //---- основной цикл
     for(int i=0; i<limit; i++)
 
{
Stochastic[i]=iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MODE_SMA,0,MODE_MAIN,i);
}
     for( i=0; i<limit; i++)
{
UP[i] =iMAOnArray(Stochastic,0, EnvPeriod, Shift,MODE_SMA,i)+Deviation;
LOW[i]=iMAOnArray(Stochastic,0, EnvPeriod, Shift,MODE_SMA,i)-Deviation;
)
 
  return(0);
  }

As external variables of the EA I set

extern int     K__period        =6;
extern int     Env_period      =10; 
extern double  Env_deviation    =12;
 
//---------------------------------------------
int start()
  {
 
... ...
double Env_low[2];
//
double Stochastic[2];
 
Env_low[0]    = iCustom("USDJPY",0,"i-StochEnv",K__period,3,3,Env_period, Env_deviation,1,2,0);
Stochastic[0] = iCustom("USDJPY",0,"i-StochEnv",K__period,3,3,Env_period, Env_deviation,1,0,0);
Stochastic[1] = iCustom("USDJPY",0,"i-StochEnv",K__period,3,3,Env_period, Env_deviation,1,0,1);
In the tester, this pair works. What may be the error here?

 
Thank you very much, I won't say no. :-) I'll write you my email address in ICQ, give me the number.
I'll tell you this: I just responded first, others came to see the answer and did not add anything. So do not think that everyone here is so angry and do not want to share knowledge.
 
Эксперт: iCustom("USDJPY", ...


А индикатор откуда об этом знает? Лучше добавить в секцию extern индикатора строковую переменную вроде


extern string SymbolName = "USDJPY"; // инструмент по умолчанию 

и вызывать стохастик так 

Stochastic[i]=iStochastic(SymbolName, 0, ...

(Опять какие-то глюки форума. В Лисе стрелки не работают, оттго и пишу не по-людски) 
 
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_minimum 0
#property indicator_maximum 100
//---- input parameters
//extern string    st="---Параметры Stochastic---";
extern string    SymbolName = "USDJPY"; 
extern int       TimeFrame = 0; 
extern int       KPeriod =12;
extern int       DPeriod =3;
extern int       Slowing =2;
//extern string    en="---Параметры Envelopes---";
extern int       EnvPeriod=17;
extern int       Deviation=15;
extern int       Shift=1;
//---- buffers
double Stochastic[];
double UP[];
double LOW[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Stochastic);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,UP);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,LOW);
//----
   return(0);
  }
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
     int limit;
     int counted_bars=IndicatorCounted();
  //---- последний посчитанный бар будет пересчитан
     if(counted_bars>0) counted_bars--;
     limit=Bars-counted_bars;
  //---- основной цикл
     for(int i=limit-1; i>=0; i--) // индикаторы лучше рассчитывать слева направо
 
{
Stochastic[i]=iStochastic(SymbolName, TimeFrame,KPeriod,DPeriod,Slowing,MODE_SMA,0,MODE_MAIN,i);
}
     for(i=limit-1; i>=0; i--) // см. примечание
{
UP[i] =iMAOnArray(Stochastic,0, EnvPeriod, Shift,MODE_SMA,i)+Deviation;
LOW[i]=iMAOnArray(Stochastic,0, EnvPeriod, Shift,MODE_SMA,i)-Deviation;
)
 
  return(0);
  }


Вызов из эксперта:

iCustom("USDJPY", 0, ...

С iMAOnArray вообще надо обращаться аккуратно. Например, поэкспериментировать с порядком ее расчета. 
А лучше всего такие вещи делать самому. Кстати, для мультивалютного эксперта может потребоваться везде 
явно задавать имя символа и рабочий тайм-фрейм, чтобы избежать умолчательных сюрпризов вроде этого.
 

alexjou !

Did I understand you correctly??????????

In a multi-currency EA when calling the iCustom indicator for a specific symbol, it is better to provide the following in the indicator itself

extern string SymbolName = "USDJPY"; // default symbol

This is besides setting in the Expert Advisor :

iCustom("USDJPY", 60, ... for this pair!

But if I call this custom indicator for one more pair with other external parameters, it means that for this other pair I must enter a copy of the custom indicator with another name and set the symbol of another pair there too!

But then it really is easier to calculate iMAOnArray inside the Expert Advisor by yourself without any custom indukes!

 
That's right. Although, it is an amateurish business. My practice, for example, is the use of custom indicators for testing an idea and then transferring the indicator code to the Expert Advisor if the idea proves to be working. This approach virtually guarantees against the pitfalls of "empty" indicator values, which are difficult to detect and can be very annoying if programmed carelessly.
 

Thank you for the explanations! I'll get right on it...

klerk, I'm having trouble with my email at the weekends.

Here's my email address for the advisor.

rid200549@ya.ru

 
alexjou:
(Опять какие-то глюки форума. В Лисе стрелки не работают, оттго и пишу не по-людски) 
The glitches were in my keyboard connector on the motherboard. The forum had absolutely nothing to do with it. Sorry for the false alarm.
 

klerk, please confirm here or in the mail if you have received my message.

And another question for the experts (sorry if it's too silly):

In multicurrency Expert Advisor -

double bid_GBP = MarketInfo("GBPUSD", MODE_BID);
 double ask_GBP = MarketInfo("GBPUSD", MODE_ASK);
 double point_GBP =MarketInfo("GBPUSD",MODE_POINT);

And in the trailing curves of each pair, do you also have to enter and substitute these values?

.... ...
if (OrderType()==OP_BUY)                                            {
       if (!Profit_Trailing || (Bid-OrderOpenPrice())>Trailing_Stop*Point) {
        if (OrderStopLoss()<Bid-(Trailing_Stop+Trailing_Step-1)*Point)      {
.... ....
or can it be left as it is?
 
rid:

And in the trailing pairs, do these values need to be entered and replaced as well?

Of course.
Reason: