Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 85

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
1) compiler will complain if the second dimension is not set, "specify class type, unknown parameters" will pop up immediately
2) then the bot will die immediately at startup with "critical error array out of range".
3) setint count1=-1; then go through the loop. What's wrong here?
Look through the answers once in a while: 1 and 2 and 3 and ...
You have been doing the same thing for more than a week and it gets worse with each time, although you have already been given an answer and pointed out the error. So, the compiler didn't complain about the absence of the second dimension in the first code, but it starts complaining in the subsequent ones? Has the compiler gone bad? You can also open any code with arrays and see how they are created and do the same.
There is no such thing. The MAs have already been so much trawled over, by so many people, that one has only to wait for fresh thinking from a freshly minted ambitious trader. Just kidding.
The truth is that I am tired of poking around with a MA bottle for so many years. They lag behind. They should probably be used in another area, but not for catching trend-flows.
There are all sorts of mashkas.
By and large, there are only pushers everywhere.
There are all kinds of mash-ups.
By and large, it's all mushrooms being used everywhere
Artyom Trishkin:
How about this?
struct myorder
{
int Ticket;
double orderopenprice;
int ordertype;
double profit;
double stoploss;
double lot;
};
myorder orders[];
int i;
int Magic=444;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
CalcOrders();
}
//+------------------------------------------------------------------+
void CalcOrders()
{
int count1=0;
for(i=OrdersTotal()-1; i>=0; i--)
{
if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) && (OrderSymbol()==Symbol())
&& (OrderMagicNumber()==Magic) && (OrderType()<2))
{
count1++;
ArrayResize(orders,count1);
orders[count1-1].Ticket=OrderTicket();
orders[count1-1].lot=OrderLots();
orders[count1-1].orderopenprice=OrderOpenPrice();
orders[count1-1].ordertype=OrderType();
orders[count1-1].profit=OrderProfit();
orders[count1-1].stoploss=OrderStopLoss();
}
}
ArraySort(orders,WHOLE_ARRAY,0,MODE_ASCEND);
}
until I do. I wouldn't be writing here if I'd found a similar one with others.
until I do. I wouldn't have written here if I'd found the same thing with others. I think you understand yourself that number series and list of structures are not the same, otherwise you'll get another equation with an infinite number of unknowns.
struct myorder
{
int Ticket;
double orderopenprice;
int ordertype;
double profit;
double stoploss;
double lot;
};
myorder orders[];
int i;
int Magic=444;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
CalcOrders();
}
//+------------------------------------------------------------------+
void CalcOrders()
{
int count1=-1;
for(i=OrdersTotal()-1; i>=0; i--)
{
if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) && (OrderSymbol()==Symbol())
&& (OrderMagicNumber()==Magic) && (OrderType()<2))
{
count1++;
ArrayResize(orders,count1,10);
orders[count1].Ticket=OrderTicket();
orders[count1].lot=OrderLots();
orders[count1].orderopenprice=OrderOpenPrice();
orders[count1].ordertype=OrderType();
orders[count1].profit=OrderProfit();
orders[count1].stoploss=OrderStopLoss();
}
}
ArraySort(orders,WHOLE_ARRAY,0,MODE_ASCEND);
}
Wrong. Trace from your code what size your array will be.
You have to think, at least a little. You don't have to guess. Think. Every step of the program. Or are you waiting for someone to write it for you? This is a freelance service - they sometimes order you to write functions.
Wrong. Trace from your code what size your array will be.
You should think it over at least a little. You should not try to guess. Just think. Every step of the program. Or are you waiting for someone to write it for you? This is a freelance service - they sometimes order you to write functions.
The way I see it
1) add to zero if order is found
2) change the size to 0, reserve 10
3) Write 0 as the first order number, 1 as the second one, etc.
As for freelancing, I'm not disputing that they will write anything, but you still have to rewrite it yourself. You don't have to go there non-stop.until I do. I would not have written here if I had found the same with others. I think you yourself understand that the numeric sequence and the list of structures is not the same, otherwise it will be another equation with an infinite number of unknowns.
for(i=OrdersTotal()-1; i>=0; i--)
{
if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) && (OrderSymbol()==Symbol())
&& (OrderMagicNumber()==Magic) && (OrderType()<2))
{
count1++;
ArrayResize(orders,count1,10);
orders[count1].Ticket=OrderTicket();
}
}
ArraySort(orders,WHOLE_ARRAY,0,MODE_ASCEND);
}
I didn't write too much, just recorded a little video response.
Artem certainly helps as much as he can, but he doesn't give me a fish, just a rod)
trader781, look through documentation sometimes, it is now full at every turn.the way I see it
1) add to zero if an order is found
2) change the size to 0, reserve 10
3) Write 0 as the first order number, 1 as the second order number, etc.
As for the freelance agency, I'm not disputing that they will write anything, but you still have to rewrite it yourself. Do not go there non-stop.And how do you want to write something into an array with a zero size?
Put money in a wallet you don't have...
And how do you want to write something into an array with a zero size?
Put money in a wallet that doesn't exist ...
revised post 844, so I don't have to write code here again.
As for the zero sized array - 0 can be an integer, it can be the equivalent of a boolean fals, it can be a void, and it can be a starting point.