trader781: I wasn't going to read it. It says "to test in the marketplace". My products will never be in the marketplace.
I'm talking about the magazine in the tester
Added: Assemble the code to its normal state, revise it, then run it in the tester and read the errors in the log. You're giving me scraps of code here.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Yes, you're right, it's just that the code is written in such a style that the previous speaker misinterpreted it.
And to check?
//| TestLogics.mq4 |
//| Copyright 2016, Artem A. Trishkin, Skype artmedia70 |
//| https://login.mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, Artem A. Trishkin, Skype artmedia70"
#property link "https://login.mql5.com/ru/users/artmedia70"
#property version "1.00"
#property strict
#property script_show_inputs
//--- input parameters
input int Value=0; // Количество имеющихся ордеров
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
if(Value>0) Alert("1. Количество ордеров=",Value);
else Alert("2. Это код после else");
{
Alert("3. Ордера отсутствуют");
}
}
//+------------------------------------------------------------------+
And check it?
Geez, really, now I've reviewed the original code again, and I was wrong. The writing style is kind of crooked - confused me.
Re-checked, removed the "extra".
division by zero didn't go anywhere
Re-checked, removed the "extra".
division by zero didn't go anywhere
Re-checked, removed the "extra".
The division by zero has not disappeared
Because there is no check if the divisor is different from 0. What is the point of executing further code when there are no orders and 0 lots?
Put a check on it
{
double avg_price=0;
price=0;
bool z=true;
double orderlots=0;
for(i=OrdersTotal()-1; i>=0; i--)
{
if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) && (OrderSymbol()==Symbol())
&& (OrderMagicNumber()==Magic) && (OrderType()==FindLastOType()))
{
price+=OrderOpenPrice()*OrderLots();
orderlots+=OrderLots();
}
}
if(orderlots==0) { return; } // если ничего нет - выходим
avg_price=NormalizeDouble(price / orderlots,Digits);
if(FindLastOType()==OP_BUY) tp=NormalizeDouble(avg_price+TakeProfit*Point(),Digits);
if(FindLastOType()==OP_SELL) tp=NormalizeDouble(avg_price-TakeProfit*Point(),Digits);
for(i=OrdersTotal()-1; i>=0; i--)
{
if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) && (OrderSymbol()==Symbol())
&& (OrderMagicNumber()==Magic) &&(OrderType()==FindLastOType()))
z=OrderModify(OrderTicket(),OrderOpenPrice(),0,tp,0);
if (!z)
Print("Ошибка функции модифицирования");
}
}
Put a check on it
But I missed the lots, thank you.
It's OK to miss it, it's not OK not toread the magazine, it's all there.
I wasn't going to read it. It says 'to check in the market'. My products will never be on the market.
about dividing by zero.
what about the one above? It's supposed to takefrom there.
{
price+=OrderOpenPrice()*OrderLots();
orderlots+=OrderLots();
}
}
if(orderlots==0) {return; }// if there is nothing, exit
avg_price=NormalizeDouble(price / orderslots,Digits);
if(FindLastOType()==OP_BUY) tp=NormalizeDouble(avg_price+TakeProfit*Point(),Digits);
if(FindLastOType()==OP_SELL) tp=NormalizeDouble(avg_price-TakeProfit*Point(),Digits);
I wasn't going to read it. It says "to test in the marketplace". My products will never be in the marketplace.
I'm talking about the magazine in the tester
Added: Assemble the code to its normal state, revise it, then run it in the tester and read the errors in the log. You're giving me scraps of code here.