[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 80

 
drknn:
Maybe the value there ends with a zero and this last zero is simply discarded in the normalisation process? Discarded because the entry 0.1 is equivalent to 0.10 and zero is better discarded?

unlikely, by hand I looked at the line value at the point of the last bar, there was no zero... and in some cases the value was exactly converted to the 4th digit, sometimes to the 3rd. as the trailing digit was >5
 
drknn:


It doesn't work( it returns a correct value to the string, but the variable is full of crap, 3 digits or 4.

is there any way to get this value out of the string correctly?

 
NameLess:


It doesn't work(( the string returns a correct value but the variable is full of crap, 3 digits or 4.

Is there any way to get the value from the string correctly?


You can make a dll-case and round off in it. I had to do such a thing to simply discard the fractional part of a number. What's not clear here - is the indicator code designed for five digits? This question probably can only be answered by a developer. Or just make your own indicator.
 
drknn:

You can make a dll and round in it. I had to do this to simply discard the fractional part of a number. What's not clear here - is the indicator code designed for five digits? This question probably can only be answered by a developer. Or just make your own indicator.

I've checked iMA and it seems to be ok. To be honest i don't know what causes it.
 
NameLess:

I have seen iMA and it seems to be ok. to be honest i don't understand why it happens. but it does. i have no idea what to do with dlls, could you at least send me a link to read?


I have no idea where to get the link to read the contents of the dll-case. Or try to use MQL4 to put value in string and make a function that will take only X characters from the string. For example, price = 1.25254130 - this value was introduced into the string. The function should go through the first 7 characters and return exactly those - i.e. 1.2525254. We just loop this value into a new string, string by string, like a bead. Then convert it to a double and return it from the subroutine.

About the dll - look something like this on this forum https://www.mql5.com/ru/forum/124088

 
drknn:


This is already a problem - you need at least a superficial knowledge of a programming language. Or try to take the value in the string and make a function that takes out only x characters from the string. For example, price = 1.25254130 - this value was entered into the string. The function should go through the first 7 characters and return exactly those - i.e. 1.2525254. We just loop this value into a new string, string by string, like a bead. Then convert it to a double and return it from the subroutine.

About the dll - see something like this on this forum https://www.mql5.com/ru/forum/124088


i know, not in depth, but not in any language at all)))) yes the method is familiar. thanks for the advice. i've just never dealt with dlls, as i've never done programming professionally.

To be honest I'm confused, because the problem is not logical at all, I can't get a value out of the indicator, or rather I can, but only to a string.

 

Please advise how to allow a single execution of a condition in an EA (e.g. opening an order), rather than repeating it with every tick. In this case, when closing a position, the EA should not open a new one. I've tried to picture it, but it doesn't work as intended.

extern bool    BUY         = true;
extern int     Magic       = 0;
extern double  Lot         = 0.1;
extern int     takeprofit  = 0;
extern int     stoploss    = 0;
extern int     slippage    = 3; 
double SL,TP;
int init(){
    return(0);
  }
int start()
{
   if (BUY)
   {
      if (takeprofit!=0) TP  = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL  = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;     
      OPENORDER ("Buy");
   }

return(0);
}
void OPENORDER(string ord)
{
int error;
 while (true)
 { error=true;
 if (ord=="Buy") error=OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,"",Magic,0){BUY = false;}
}
return;
}
I thank you in advance.


 
nemo811:

Please advise how to allow a single execution of a condition in an EA (e.g. opening an order), rather than repeating it with every tick. In this case, when closing a position, the EA should not open a new one. I've tried to picture it, but it doesn't work as intended.

I thank you in advance.



I solved this problem by putting a flag in the condition before any action (opening in this case); inside the condition, after opening an order, the flag changes its value and, respectively, on the next tick the program won't enter this condition with the order opening. If the process is automated, then you can put a function that would clear all flags when there are no open positions, otherwise the EA will only open the order once and fade out, because the flag will not change its value
 
NameLess:

I solved this problem by placing a flag in the condition before any action (in this case, opening), inside the condition after opening an order the flag changes the value and, respectively, on the next tick the program will not enter this condition with the opening of an order. If the process is automated, then you can use a function that would clear all flags at the moment of absence of open positions, otherwise the EA will only open the order once and then fade out, because the flag will not change the value

Please give me an example. I'm just learning, and haven't faced the task of setting a flag yet. )
 
nemo811:

Please give me an example. I'm just learning, and haven't faced the task of setting up a flag yet. )

I'm not a pro myself, I'm just telling you how I solved the problem. It's not a small code and it will take you longer to figure it out than to get the idea from scratch)))
Reason: