[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 1095

 
I did not write right away an EA without indicators, there are no indicators, just orders to buy and sell and so on--- and then the periods that have changed in the tester and the end result is still nothing I do not understand
 
5drakon:
I did not write right away an EA without indicators, there are no indicators, just orders to buy and sell and so on--- and then the periods that have changed in the tester and the end result is still nothing I do not understand

You cannot say anything without the Expert Advisor itself. I am just guessing.
 

What should I do with Ilan6 to make him start trading? How much money does it start to work and does it work on a cent at all?

 
5drakon:
I did not write right away an EA without indicators, there are no indicators, just orders to buy and sell and so on--- and then the periods that have changed in the tester and the end result is still nothing I do not understand

Yes, we should look at the code itself. Doesn't it have some kind of strategy, on the basis of which calculations it opens and closes orders?
 

Can you tell me where the mistake is? If there is a market order to sell our financial instrument, then close it and if there is no order to buy, then open one order to buy. Everything is normal here with closing, but it opens them not once, but with every tick.

//--------------------------------------------------------------------------------------------

extern double LOT = 0.01;
//--------------------------------------------------------------------------------------------
int start()
{
int sells=0;
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if (OrderSymbol() !=Symbol() || OrderType() !=OP_SELL ) continue;
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,White);
Alert (GetLastError()); // Выводит сообщение об ошибке
sells++;
}
}
if (sells==0)
{
OrderSend(Symbol(),OP_BUY,LOT,Ask,1,Bid-400*Point,Bid+400*Point,0,Green);
Alert (GetLastError()); // Выводит сообщение об ошибке
return(0);
}
}
//--------------------------------------------------------------------------------------------

 
kolyango:

Can you tell me where the mistake is? If there is a market order to sell our financial instrument, then close it and if there is no order to buy, then open one order to buy. Everything is normal here with closing, but it opens them not once but with every tick.

//--------------------------------------------------------------------------------------------

extern double LOT = 0.01;
//--------------------------------------------------------------------------------------------
int start()
{
int sells=0;
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if (OrderSymbol() !=Symbol() || OrderType() !=OP_SELL ) continue;
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,White);
Alert (GetLastError()); // Выводит сообщение об ошибке
sells++;
}
}
if (sells==0)
{
OrderSend(Symbol(),OP_BUY,LOT,Ask,1,Bid-400*Point,Bid+400*Point,0,Green);
Alert (GetLastError()); // Выводит сообщение об ошибке
return(0);
}
}
//--------------------------------------------------------------------------------------------


Or is it better to do so? If there are no sell orders, we will not open a buy order.

extern double LOT = 0.01;
//--------------------------------------------------------------------------------------------
int start()
{
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if (OrderSymbol() !=Symbol() || OrderType() !=OP_SELL ) continue;
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,White);
Alert (GetLastError()); // Выводит сообщение об ошибке
OrderSend(Symbol(),OP_BUY,LOT,Ask,1,Bid-400*Point,Bid+400*Point,0,Green);
Alert (GetLastError()); // Выводит сообщение об ошибке
return(0);
}
}
}
//--------------------------------------------------------------------------------------------

 

Rule for the execution of the for statement


When passing control to for statement, execute Expression_1. While the Condition of for statement is true: pass control to the first statement of the loop body, and after all statements of the loop body have been executed, execute Expression_2 and pass control to the header to check if the Condition is true. If the Condition of the for statement is false: pass control to the statement that follows the for statement.

Tell me: a tick has come, Condition of for operator is true, control is passed further - all this will happen during one tick, i.e. all these operators will be executed during 1 tick or not.

extern double LOT = 0.01;
//--------------------------------------------------------------------------------------------
int start()
{
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if (OrderSymbol() !=Symbol() || OrderType() !=OP_SELL ) continue;
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,White);
Alert (GetLastError()); // Выводит сообщение об ошибке
OrderSend(Symbol(),OP_BUY,LOT,Ask,1,Bid-400*Point,Bid+400*Point,0,Green);
Alert (GetLastError()); // Выводит сообщение об ошибке
return(0);
}
}
}
//--------------------------------------------------------------------------------------------

Or exactly which operators will be executed during this tick? All of the above or which ones will be executed during the next tick? Explain...

 
kolyango:

Rule for the execution of the for statement


When passing control to for statement, execute Expression_1. While the Condition of for statement is true: pass control to the first statement of the loop body, and after all statements of the loop body have been executed, execute Expression_2 and pass control to the header to check if the Condition is true. If the Condition of the for statement is false: pass control to the statement that follows the for statement.

Tell me: a tick has come, Condition of for operator is true, control is passed further - all this will happen during one tick, i.e. all these operators will be executed during 1 tick or not.

Or exactly which operators will be executed during this tick? All of the above or which ones will be executed during the next tick? Explain...


The start() function is executed when the first tick arrives. If other ticks arrive while the function is running, they will be skipped.

The start function will be executed completely according to its logic

 
kolyango:

Rule of for statement execution


When passing control to for statement, execute Expression_1. While the Condition of for statement is true: pass control to the first statement of the loop body, and after all statements of the loop body have been executed, execute Expression_2 and pass control to the header to check if the Condition is true. If the Condition of the for statement is false: pass control to the statement that follows the for statement.

Tell me: a tick has come, Condition of for operator is true, control is passed further - all this will happen during one tick, i.e. all these operators will be executed during 1 tick or not.

extern double LOT = 0.01;
//--------------------------------------------------------------------------------------------
int start()
{
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if (OrderSymbol() !=Symbol() || OrderType() !=OP_SELL ) continue;
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,White);
Alert (GetLastError()); // Выводит сообщение об ошибке
OrderSend(Symbol(),OP_BUY,LOT,Ask,1,Bid-400*Point,Bid+400*Point,0,Green);
Alert (GetLastError()); // Выводит сообщение об ошибке
return(0);
}
}
}
//--------------------------------------------------------------------------------------------

Or exactly which operators will be executed during this tick? All of the above or which ones will be executed during the next tick? Explain...


Got it figured out. All operators will be executed if the condition is depleted.
 
How do I make this code check whether we already have a buy order or not before buying. If there are no market buy orders, then only then execute the buy?