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

 
Trendy:

Thank you very much! I needed it to compare candle characteristics (more, less, etc.) I screwed it on - it works. Only can not understand how it compares the data type string? Or double to string does not translate number to string? :-D


PS. It doesn't work in indicator - only in script... When I call High[i] - I get only 4 decimal places in it.

I'm writing:

Alert ("doubletostr High = ", DoubleToStr(High[1],5));
if (DoubleToStr(High[2],5)>(DoubleToStr(High[3],5))
{
Alert ("More");
}
if (DoubleToStr(High[2],5)<(DoubleToStr(High[3],5))
{
Alert ("Smaller");

}

Works, it writes the result with five digits, over/under counts. The problem is that in the indicator the string array doesn't show up on the chart. Therefore...

...writing:

Alert ("Normalized Double High = ", NormalizeDouble(High[1],5));

Doesn't work - the result is > 1,1234

I do not understand the developers - why did they have to complicate things so much? Why, if it shows so many digits on the chart, it won't scratch the called function with five digits? Maybe there is a simple solution?


It gets even more interesting:

translate

Alert ("iFractals doubletostr= ", DoubleToStr(iFractals(0,0,MODE_UPPER,2),Digits));

Writes: 1,32169 - OK.

Convert back to a numeric value using StrToDouble:

Alert ("iFractals StrToDoubledoubletostr= ", StrToDouble(DoubleToStr(iFractals(0,0,MODE_UPPER,2),Digits));

Result: 1.3217

There should be a meme with Jackie Chan where he doesn't understand the chip).

 
hoz:

And what does Alert actually output?

It says 0.01 but it's actually 0...0100.
 
Trendy:

It gets even more interesting:

translate

Alert ("iFractals doubletostr= ", DoubleToStr(iFractals(0,0,MODE_UPPER,2),Digits));

Writes: 1,32169 - OK.

Convert back to a numeric value using StrToDouble:

Alert ("iFractals StrToDoubledoubletostr= ", StrToDouble(DoubleToStr(iFractals(0,0,MODE_UPPER,2),Digits));

Result: 1.3217

There should be a meme with Jackie Chan where he misunderstands the chip).


DoubleToStr() is used to output messages with the accuracy you want. Standard Print(), Alert(), etc., print in 4 digits.

When you want to see a number with the accuracy you want, use DoubleToStr() then, not in calculations.

You don't need to translate anything back and forth ... ;)

 
semiromid:

It says 0.01 But the actual value is 0...0100.


Output then 100 * point = 100 * 0.00001 = 0.001pp (if for five digits)

The value of lBUY has been changed above. Therefore, as I see it, the condition:

if(lBUY==0.01)

Will not be met. And therefore the value of lBUY will remain the same.

 
artmedia70:
The j variable must be explicitly initialised at the beginning of the function with a negative value. Try it. I haven't looked any further yet.


Hmm. So far the same thing. Here we have:

//+-------------------------------------------------------------------------------------+
//| Получаем состояние последней позиции (Открыта или закрыта)                          |
//+-------------------------------------------------------------------------------------+
bool isCloseByTakeLastOpenPos(int delta)
{
   datetime lastOrderCloseTime = 0,               // Время закрытия последнего открытого ордера
            lastOOTHist = -1;                     // Время открытия последнего открытого ордера из истории
   int j = -1;
   
   for (int i=OrdersHistoryTotal()-1; i>=0; i--)
   {
      if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
      if (OrderMagicNumber() != i_magic) continue;
      if (OrderSymbol() != Symbol()) continue;
      if (OrderType() > 1) continue;               // Все удалённые отложки нас не интересуют..
  
      if (lastOrderCloseTime < OrderCloseTime())   // Находим время закрытия..
      {
         lastOrderCloseTime = OrderCloseTime();   // ..последней закрытой позиции в истории
         j = i;
      }
   }
  if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY))
   {
      if (OrderProfit() + OrderCommission() + OrderSwap() <= 0) return (false);
      if (MathAbs(OrderProfit() - OrderClosePrice()) > delta * pt) return (false);
      else
      {
         lastOOTHist = OrderOpenTime();
         Comment("FUNC isCloseByTakeLastOpenPos : lastOOTHist = ", lastOOTHist);
      }
   }
   else
   {
      Comment("FUNC isCloseByTakeLastOpenPos : не удалось выбрать ордер в истории");
      Print("FUNC isCloseByTakeLastOpenPos : не удалось выбрать ордер в истории");
      return(false);
   }
  
   for(int h=OrdersTotal()-1; h>=0; h--)
   {
      if (OrderSelect(h, SELECT_BY_POS, MODE_TRADES))
      {
         if (OrderMagicNumber() != i_magic)   continue;
         if (OrderSymbol() != Symbol())       continue;
         if (OrderType() > 1)                 continue;
         if (lastOOTHist < OrderOpenTime()) return(false);  // Выбранная рыночная позиция открыта позже закрытой по тейку
      }
      else {Print("FUNC isCloseByTakeLastOpenPos : не удалось выбрать рыночный ордер");return(false);}
   }
   
   return (true);
}
 
artmedia70:

DoubleToStr() is used to output messages with the accuracy you want. Standard Print(), Alert(), etc. will print 4 digits.

When you want to see a number with the accuracy you want, that's when you use DoubleToStr(), not in calculations.

You don't need to translate anything back and forth ... ;)


It's understandable... now...) But the whole point is that I need to somehow dig out a fifth digit for calculations(

If DoubleToStr() is not good for it, then this language has no such feature? Didn't the developers foresee this?

 
hoz:


Hmm. So far, so good. Here we are:

Shouldn't it be the same? ;)
 
Trendy:

It's understandable... now...) But the whole point is that I need to somehow dig out a fifth digit for calculations(

If DoubleToStr() is not good for it, then this language has no such feature? Didn't the developers foresee this?


The calculations use even more digits than you think. If you want to see with the accuracy you want, use DoubleToStr(). You won't see it any other way.
 

Gentlemen programmers! Please advise how to combine an EA with an indicator?

For example, I took a simple bot mo_bidir.mq4 that trades using its own algorithm and I want it to continue opening trades using its own algorithm but after the signal of 3 МА.

For example on a signal - Three Moving Averages:

FastEMA>MediumEMA>SlowEMA (trend up) - bot buys

FastEMA<MediumEMA<SlowEMA (trend down) - bot sells

Inp_Signal_ThreeEMA_FastPeriod = 8;

Inp_Signal_ThreeEMA_MediumPeriod = 38;

Inp_Signal_ThreeEMA_SlowPeriod = 48;

What I need is for the Expert Advisor to continue trading on 5 minutes and the indicator to give signals from the daily or 4hour timeframe, and I want to be able to change timeframes in the bot settings.

 
Good day to all traders. Maybe this question has already been discussed, but some EAs from codebase are not compiling in new builds, the compiler swears it is a decompiled version. But this seems to be nonsense, versions have never been decompiled
Reason: