[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 145

 

Probably a really stupid question, or rather two.

1) Euro/dollar 1.45... time passes and it becomes 1.30.

It's all over the place, they say the euro is falling.

The crisis in Greece and the like.

But one unit of the euro is worth less dollars, making the euro more expensive? Why do they say it is going down?

2) Crosses are formed from major currencies.

The question is how to guide one currency in the numerator, the other exactly in the denominator (when the dollar is thrown out to form a cross)?

I.e. how to recognize what is in the numerator and what is in the denominator and what to divide into each other?

 
Brainwashing...

Space:

... The euro is starting to fetch less dollars per unit, so the euro is getting more expensive? Why do they say it's going down?

... One kilo of tomatoes is worth less than a rouble, so the tomatoes are getting more expensive? Why do they say they are getting cheaper?
 
iMAG:
To make it clear, try to look at GetLastError() after the assignment operator - it must help with the breakdown. At least, everything works fine in the above example. ;)


int init()
{
//----
// i = 0;
double s[10] = {,,3,4,5,6,7,8,9};
int i = 0;

while(i < 10)
{
s[i] = i + 10;
i++;
Print("s[i]: ", DoubleToStr(s[i], 2), " i: ", i, "GetLastError(): ", GetLastError());

Sleep(5000);
}

//----

return(0);
}

Here is an example: value (i + 10) is not assigned. With this initialization, only through an array of orders - what are the secrets?


 

Stepan2

Works

int init()
  {
//----
double s[11];
// i = 0;
int i = 0;

while(i < 10)
{
s[i] = i*10;
i++;
Print("s[i]: ", DoubleToStr(s[i], 2), " i: ", i, "   GetLastError(): ", GetLastError());

Sleep(5000);
}

   return(0);
  }

 
GaryKa:
Tore my brain ... One kg of tomatoes is worth less than rubles, so tomatoes become more expensive? Why do they say they're getting cheaper?


That is, a dollar, be it in the numerator or denominator, is always MONEY (even in majors), the rest is "Goods".

Is that how it works?

What about crosses? How do you know what to divide by what when forming a cross?

That is, why is one currency necessarily in the numerator and the other in the denominator and not the other way round?

 
r772ra:

Stepan2

Works


what do you mean by that?

THAT terminal depends on a BROKER!

 
Space:


I.e. a dollar whether it's in the numerator or denominator is always MONEY (even in majors), the rest is "TRADE".

Is that how it works?

What about crosses? How do you know what to divide by what when forming a cross?

That is, why is one currency necessarily in the numerator and the other in the denominator, and not the other way round?


The learning process is as follows:

DIVISION - consecutive, but in the opposite direction

RUNNING - Action Script

 
Stepan2:


what do you mean by that?

THAT the terminal depends on the BROKER!

I can't say anything about the broker, it is unlikely there is something wrong with the broker.

And for the code, maybe I'm wrong.

You declared an array and filled it

double s[10] = {,,,3,4,5,6,7,8,9}; 

and you show these numbers, yes if double, then 1.0, 2.0, etc.

In my case

double s[11];

It needs to be a bit bigger to avoid the error (4002).

and it fills in the loop, so, yeah, I don't get it ...... only through an array of orders .....

 

Please advise, I have placed two MACD (Macd1 and Macd2) in the same window and on the same scale. I find max and min of each MACD only among the chart values visible in the indicator window. I put them to Comment(). Everything works, but the signal lines start drawing from the first bar, i.e. I have to wait until they fill the whole window. How to fix this problem? And how can I optimize my awkward code?

  
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Aqua
#property indicator_color4 DarkOrange
#property  indicator_width1  2
#property  indicator_width3  2
//--- buffers
double Macd1Buffer[];
double Signal1Buffer[];
double Macd2Buffer[];
double Signal2Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Macd1Buffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Signal1Buffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,Macd2Buffer);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,Signal2Buffer);
   
   IndicatorDigits(Digits);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   Comment("");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {   
      double max1=-0.01,min1=0.01,
             max2=-0.01,min2=0.01,
             max_M1=-0.01,min_M1=0.01,
             max_M2=-0.01,min_M2=0.01,
             max_S1=-0.01,min_S1=0.01,
             max_S2=-0.01,min_S2=0.01;
             
       
 
   int bars_counted=WindowBarsPerChart()-1,
       limit;  
       limit=bars_counted;       


      
//---- macd counted in the 1-st buffer
   for(int i=0; i<limit; i++)
   

   { 
     Macd1Buffer[i]=iMA(NULL,0,6,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,i);
  
           max_M1=MathMax(Macd1Buffer[i],max_M1);
           min_M1=MathMin(Macd1Buffer[i],min_M1);
  
      Signal1Buffer[i]=iMAOnArray(Macd1Buffer,Bars,5,0,MODE_SMA,i);
 
           max_S1=MathMax(Signal1Buffer[i],max_S1);
           min_S1=MathMin(Signal1Buffer[i],min_S1);         
             
           max1=MathMax(max_M1,max_S1);
           min1=MathMin(min_M1,min_S1);
             
   }          
            
      
//---- done
   //---- macd counted in the 3-st buffer   
   for(i=0; i<limit; i++) 
      
   { 
     
      Macd2Buffer[i]=iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,26,0,MODE_EMA,PRICE_CLOSE,i);
 
          
           max_M2=MathMax(Macd2Buffer[i],max_M2);
           min_M2=MathMin(Macd2Buffer[i],min_M2);
           
   
      Signal2Buffer[i]=iMAOnArray(Macd2Buffer,Bars,9,0,MODE_SMA,i);

           max_S2=MathMax(Signal2Buffer[i],max_S2);
           min_S2=MathMin(Signal2Buffer[i],min_S2);  
         
           max2=MathMax(max_M2,max_S2);
           min2=MathMin(min_M2,min_S2);    
   }      
      
//---- done 
   
 
      Comment( "\n"," Баров = ",WindowBarsPerChart()-1,
               "\n"," max_M1 = ",max_M1,
               "\n"," min_M1 = ",min_M1,
               "\n"," max_S1 = ",max_S1,
               "\n"," min_S1 = ",min_S1,
               "\n"," max_M2 = ",max_M2,
               "\n"," min_M2 = ",min_M2,
               "\n"," max_S2 = ",max_S2,
               "\n"," min_S2 = ",min_S2,
               "\n"," max1 = ",max1,
               "\n"," min1 = ",min1,    
               "\n"," max2 = ",max2,
               "\n"," min2 = ",min2);
         
             
         
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
MK07:

Please advise, I have placed two MACD (Macd1 and Macd2) in the same window and on the same scale. I find max and min of each MACD only among the chart values visible in the indicator window. I paste them to Comment(). Everything works, but the signal lines start drawing from the first bar, i.e. I have to wait until they fill the whole window. How to fix this problem? And how can I optimise my slow code?

Try, each buffer in a separate loop.
Reason: