[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 505

 
eugggy:
bar is the shift of the current bar relative to the time set in the external settings(Start_Point).

bar = ?? at the time of deleting what?
 
ask: Do you have to be rude?

You are being rude now: there is still no problem statement, and what you have scribbled is nothing, not even pseudo-code.

And you think I sent you to the telepaths incorrectly?

 
sergeev:

bar = ?? at the moment of deleting what?
Hopefully to its previous value. I.e. if I don't need the document when the bar expires I have to delete it.
 
eugggy:
I hope that its previous value

Well, just hope it works out.

 
sergeev:

Well, you just hope it works out.



:-) Can't you just point out the mistake?
 
eugggy:
:-) Can't you just point out the mistake?

:) but to answer the question what bar=??, you can't do that?
 
sergeev:

:) but you can't answer the question what bar=??, can you do that ?
Well, the topic is for newbies, and if I was sure what the bar is at the moment of deletion, then maybe the EA would work. I think so: when the document is closed, i.e. a new bar appears, the variable bar increases its value by 1. In the delete function, I put bar-1, i.e. the number of already closed document and if the previous bar does not meet the specified criteria, the document, in whose value the number = the current value of the variable bar minus 1, is deleted. Could the error be because I am deleting an already deleted document?
 

no one noticed the mistake, so once again.

Could you tell me the error in the code? thanks.

//+------------------------------------------------------------------+
//| line.mq4 |
//| |
||
//+------------------------------------------------------------------+
//--- input parameters
extern bool sell = 1; // permission to sell
extern bool buy = 1;
extern double lots = 0.1;
extern int sl = 50;
extern int tp = 150;

extern int order = 10; //

extern double bez = 15;
extern double tral_step = 15;
extern double tral_start = 10;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
string sell_stop ="ss"; //name the line manually
string buy_stop ="bs";

//buy------------------------------------------------------------------------------------------------

// find the line and place an order when price touches
if (ObjectFind (buy_stop) > 0 ) // if there is line buy_stop
if ( ObjectGet (buy_stop, OBJPROP_PRICE1=Ask )// touch the line
{
OrderSend (Symbol(),OP_BUYSTOP, lots, Ask+Point*order,3, Bid-sl*Point, Bid+tp*Point );// send order
ObjectDelete (buy_stop); // line is removed
}


return(0);
}
//+-------------------------

 
TESKATLIPOKA:

No one's noticed the mistake, so once again.

can you tell me the error in the code? thanks.


Here they are (there are much more errors in your code but these ones won't even make it through the compiler):

.
if ( ObjectGet (buy_stop, OBJPROP_PRICE1=Ask )// касание линии
And even if you change the code to something more sane from the compiler's point of view:

if ( ObjectGet (buy_stop, OBJPROP_PRICE1) == Ask )// касание линии

If you don't know the error, it will still be theoretically wrong without prior normalization of real values before the comparison. Even worse, normalization may fail if price changes by more than one pip in one tick and your condition slips through.

It's more correct to find the crossing condition in the following way:

if (ObjectGet (buy_stop, OBJPROP_PRICE1) <= High[0]) && (ObjectGet (buy_stop, OBJPROP_PRICE1) >= Low[0]))//  на текущей свече касание линии уже имело место


P.S. In MetaTrader, finding the error spot after compilation is quite easy:

1. In the "Toolbox" tab, in the "File" field, specify the line number and the number of the symbol in which the compiler has detected an error, separated by commas.

2. If you double-click on the error message in the "Description" column of the same tab, the cursor in the editor will jump to the place where the compiler detected the error.

 
eugggy:
Well this is a beginner's topic, and if I was sure what the bar was at the time of deletion, maybe the EA would work.
So ask me how to find out what the bar is.
Reason: