Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 11

 
AndEv:
Good afternoon. There are two points with coordinates (x1,y1) and (x2,y2). How can I use these two points to construct a logarithmic function with a logarithm basis other than natural? Seems like I need to use inverse function (), but I don't know how to make it diagonal. If someone has faced the problem, please advise. I am grateful in advance.

Easy, divide by the base of your logarithm. That is, if you want logarithm x of degree two, you divide logarithm x by logarithm two, and you get logarithm x of degree two.
 
gyfto:

Easy, divide by the base of your logarithm. That is, if you want logarithm x of degree two, you divide logarithm x by logarithm two, and you get logarithm x of degree two.
I don't quite get it. What I meant was that the regular logarithm function in MT4 calculates only the natural logarithm of a number. There is no other logarithmic function in MT4. You can use the inverse function, i.e. MathPow, but it needs to be mirrored to the diagonal. I can't think of an easier way to do that.
 
Fox_RM:

Can I clarify what you mean by not at market price? With SELLLIMIT and BUYLIMIT, everything is correct.

Go to the editing area and read what pending orders are... and all questions will go away.
 
hoz:

You should go to edit and read what pending orders are... and all questions will go away.


Sell limit - sell from the upper border, Buy limit - buy from the lower one. All

Right with the pending orders, that's not the point.

 
All your orders in the code are market orders
 
AndEv:
I don't quite get it. What I meant was that the regular logarithmic function in MT4 calculates only the natural logarithm of a number. There is no other logarithmic function in MT4. You can use the inverse function, i.e. MathPow, but it has to be mirrored to the diagonal. I can't think of an easier way to do this.


About this?

The inverse of a power function is a logarithmic function on the same basis. To get a logarithmic function on the desired basis a, you need to divide MathLog(x) by MathLog(a).

 
gyfto:


About this?

The inverse of a power function is a logarithmic function on the same basis. To get a logarithmic function on the desired basis a, divide MathLog(x) by MathLog(a).

Yes, I got it now, thank you.
 
hoz:
It's more or less like this:


Something, I'm doing wrong...

It was like this:

int start()                         
  {
   int i, Counted_bars;  
//--------------------------------------------------------------------
   CurrentPoint1 = 0;
   CurrentPoint2 = 0; 
   kVol1=MarketInfo(Symbol_1, MODE_TICKVALUE)/MarketInfo(Symbol_1, MODE_TICKSIZE);
   kVol2=MarketInfo(Symbol_2, MODE_TICKVALUE)/MarketInfo(Symbol_2, MODE_TICKSIZE);
   Counted_bars=IndicatorCounted(); 
   i=Bars-Counted_bars-1;           
   while(i>=0)                     
     {
      Symbol1_Buf[i] = MACD (Symbol_1, iBarShift(Symbol_1, 0, Time[i], FALSE));
      if(Revers) Symbol2_Buf[i] = -1*MACD (Symbol_2, iBarShift(Symbol_2, 0, Time[i], FALSE));
      else Symbol2_Buf[i] = MACD (Symbol_2, iBarShift(Symbol_2, 0, Time[i], FALSE));
      
      if((Symbol1_Buf[i+1]>Symbol2_Buf[i+1] && Symbol1_Buf[i+2]<=Symbol2_Buf[i+2]) ||
         (Symbol1_Buf[i+1]<Symbol2_Buf[i+1] && Symbol1_Buf[i+2]>=Symbol2_Buf[i+2]))
         {
          CurrentPoint1 = 0;
          CurrentPoint2 = 0;
          ZeroClose1 = iClose(Symbol_1,Period(),iBarShift(Symbol_1,0,Time[i+1]));
          ZeroClose2 = iClose(Symbol_2,Period(),iBarShift(Symbol_2,0,Time[i+1]));         
         }
      
      CurrentPoint1 = iClose(Symbol_1,Period(),iBarShift(Symbol_1,0,Time[i])) - ZeroClose1;
      if(Revers) CurrentPoint2 = -1*(iClose(Symbol_2,Period(),iBarShift(Symbol_2,0,Time[i])) - ZeroClose2);
      else CurrentPoint2 = iClose(Symbol_2,Period(),iBarShift(Symbol_2,0,Time[i])) - ZeroClose2;

      Spread_Buf[i]  = (CurrentPoint1 / MarketInfo(Symbol_1, MODE_POINT) - CurrentPoint2 / MarketInfo(Symbol_2, MODE_POINT));
                              
      Buf_Up[i] = Spread_Buf[i];     
      Buf_Dw[i] = Spread_Buf[i];  
      if(Spread_Buf[i] < Spread_Buf[i+1]) Buf_Up[i] = EMPTY_VALUE;
      if(Spread_Buf[i] > Spread_Buf[i+1]) Buf_Dw[i] = EMPTY_VALUE; 
      i--;                          
     }


It went like this:

int start()                         
  {
    int i, countedBars = IndicatorCounted();
        
    for(i = Bars - countedBars;i > 0;i--)    
//--------------------------------------------------------------------
   CurrentPoint1 = 0; 
   CurrentPoint2 = 0; 
   kVol1=MarketInfo(Symbol_1, MODE_TICKVALUE)/MarketInfo(Symbol_1, MODE_TICKSIZE);
   kVol2=MarketInfo(Symbol_2, MODE_TICKVALUE)/MarketInfo(Symbol_2, MODE_TICKSIZE);
             
   while(i>=0)                 
     {
      Symbol1_Buf[i] = MACD (Symbol_1, iBarShift(Symbol_1, 0, Time[i], FALSE));
      if(Revers) Symbol2_Buf[i] = -1*MACD (Symbol_2, iBarShift(Symbol_2, 0, Time[i], FALSE));
      else Symbol2_Buf[i] = MACD (Symbol_2, iBarShift(Symbol_2, 0, Time[i], FALSE));
      
      if((Symbol1_Buf[i+1]>Symbol2_Buf[i+1] && Symbol1_Buf[i+2]<=Symbol2_Buf[i+2]) ||
         (Symbol1_Buf[i+1]<Symbol2_Buf[i+1] && Symbol1_Buf[i+2]>=Symbol2_Buf[i+2]))
         {
          CurrentPoint1 = 0;
          CurrentPoint2 = 0;
          ZeroClose1 = iClose(Symbol_1,Period(),iBarShift(Symbol_1,0,Time[i+1]));
          ZeroClose2 = iClose(Symbol_2,Period(),iBarShift(Symbol_2,0,Time[i+1]));         
         }
      
      CurrentPoint1 = iClose(Symbol_1,Period(),iBarShift(Symbol_1,0,Time[i])) - ZeroClose1;
      if(Revers) CurrentPoint2 = -1*(iClose(Symbol_2,Period(),iBarShift(Symbol_2,0,Time[i])) - ZeroClose2);
      else CurrentPoint2 = iClose(Symbol_2,Period(),iBarShift(Symbol_2,0,Time[i])) - ZeroClose2;

      Spread_Buf[i]  = (CurrentPoint1 / MarketInfo(Symbol_1, MODE_POINT) - CurrentPoint2 / MarketInfo(Symbol_2, MODE_POINT));
                              
      Buf_Up[i] = Spread_Buf[i];     
      Buf_Dw[i] = Spread_Buf[i];  
      if(Spread_Buf[i] < Spread_Buf[i+1]) Buf_Up[i] = EMPTY_VALUE;
      if(Spread_Buf[i] > Spread_Buf[i+1]) Buf_Dw[i] = EMPTY_VALUE; 
      i--;                          
     }

After compiling, no errors, but the indicator shows only one long bar.

 
Krokus:

After compiling, there are no errors, but the indicator shows only one long bar.


I do not have time to understand the logic of your indicator, but I wrote you how to correctly set the loop.

By the way, it would help to simplify the code and make it more readable. It would be easier to analyze it in this case. This is often the reason for errors. The more readable the code and well thought-out names of variables, the better.

 
hoz:


Well, I don't have time to look into the logic of your indicator yet, but I wrote you how to correctly set the loop.

By the way, it wouldn't hurt to simplify the code and make it more readable. And then it would be easier to analyse it. This is often the reason for errors. The more readable the code, and the better the names of variables, the better.


I will look into it. Thank you.
Reason: