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

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello.
Please help me figure out what I'm doing wrong.
Conditionally: Ask = 1.3000
PriceAsk = 1.3055 (incl. where Step=50 and Srpead=3)
bool BuyOrder=1 ,
if (Ask-PriceAsk+Step-Spread<=0 && BuyOrder==0) why is this condition true?Immediately before the if statement, print out the values of all variables in the condition
Immediately before the if statement, log the values of all variables in the condition
Check it out, thanks)
And now the conclusion
I want to understand how it works. That is why I asked.
GaryKa:
Immediately before the if statement, log the values of all variables in the condition
ed3sss:
Check it out, thanks)
Thanks, found a logical error in the program, now everything works.
Hello.
How can I display on the chart the inscription on the current instrument Profit/loss of open orders.
It is difficult to check in the Expert Advisor whether it has opened positions or not (terminal on/off) and to pick up the last lot volume before closing the terminal.
Thank you.
I just came across a function here:
I want to understand how it works. That's why I asked.If I'm wrong, I apologize. MathLog(x) is ln(x) (natural logarithm). The conversion formula is log_a(b)=ln(b)/ln(a), in this case we get ln(x)/ln(10)=lg(x)(decimal logarithm). The integer part of the decimal logarithm lg(1...9) is 0, lg(10...99) is 1, lg(100...999) is 2, lg(1000...9999) is 3 and so on, i.e. the logarithm of a number greater than one equals the number of digits in that number(before the decimal point, do not count after) minus one. If x is 0 to one, then the integer part of lg(0.1...0.9) equals -1, lg(0.01...0.09) equals -2, lg(0.001...0.009) equals -3 and so on, that is, if you don't look at the minus, the decimal logarithm of number from 0 to one equals the total number of zeros before the first significant digit. I don't know how MathCeil works, but if it returns the integer part of a number, this function is supposed to return the number of digits in the number before the decimal point minus one if the number is greater than 1, and the number of zeros in the number before the first significant digit if the number is 0 to one. The minimum of this function is in the range x equals 1...9. From 10...99 and 0.1...0.9, the function returns 1, with 100...999 and 0.01...0.09 it returns 2, and so on. The idea is...
Good afternoon, there's a bug in the program, I've already racked my brains, please point the finger at what's wrong. Just want to know why the condition for modifi does not work. Even if the condition is not true, it is still satisfied and, therefore, when modifying errors or 1, or 130. Thank you all.
//--------------- modify orders under TP-------------------
for (i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
if (OrderType() == OP_BUY) {
if (OrderTakeProfit() == 0 || OrderTakeProfit() > OprTPB(TP)){
RefreshRates();
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OprTPB(TP),0,CLR_NONE);
}
}
if ((OrderType() == OP_SELL)) {
if(OrderTakeProfit() == 0 || OrderTakeProfit() < OprTPS(TP)){
RefreshRates();
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OprTPS(TP),0,CLR_NONE);
}
}
}
}
return(0);
}
double LastOpPrBuy(double va=0)
{
for (i = OrdersTotal() - 1; i>= 0; i--)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (va == 0) va = OrderOpenPrice();
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
if (OrderType() == OP_BUY && OrderOpenPrice()<va) va = OrderOpenPrice()
}
return (va);
}
//----------------------------------------------------------------------------------
double LastOpPrSell(double va=0)
{
for (i = OrdersTotal() - 1; i>= 0; i--)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (va == 0) va = OrderOpenPrice();
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
if (OrderType() == OP_SELL && OrderOpenPrice()>va) va = OrderOpenPrice()
}
return (va);
}
//----------------------------------------------------------------------------------
double OprTPB(int TP)
{
int j=0;
double TPB=0;
for (i = OrdersTotal() - 1; i>= 0; i--)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
if (OrderType() == OP_BUY)
{
TPB+=OrderOpenPrice();
j++;
}
}
if (j==0) {
j++;
TPB = Ask;
}
TPB=(TPB/j)+TP*Point;
return (TPB);
}
//----------------------------------------------------------------------------------
double OprTPS(int TP)
{
int j=0;
double TPS=0;
for (i = OrdersTotal() - 1; i>= 0; i--)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
if (OrderType() == OP_SELL)
{
TPS+=OrderOpenPrice();
j++;
}
}
if (j==0) {
j++;
TPS = Bid;
}
TPS=(TPS/j)-TP*Point;
return (TPS);
}
//----------------------------
We are all newbies here! Do not see that we do not know simple things! Where else are we to find out! At least we want to know, not the way some people think that just ask to put in the code and immediately pump the money!
))) From a trader's humour:
- Where can I get a profitable Expert Advisor?
- Look somewhere above in the thread, they posted a robot called @MOZG@v4.12.