[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 1090

 

Help me create a simple code like this (if you can get a ready-made code right away):

if (Если есть открытый ордер на продажу по нашему фин. инструменту) //
{
Закрыть ордер; //
}
else
{
if (Если нет открытых ордеров на продажу по нашему фин. инструменту) //
{
Открыть ордер на покупку по нашему фин. инструменту; //
}
}

 
kolyango:

Help me create a simple code like this(if you can get a ready-made code right away):

if (Если есть открытый ордер на продажу по нашему фин. инструменту) //
{
Закрыть ордер; //
}
else
{
if (Если нет открытых ордеров на продажу по нашему фин. инструменту) //
{
Открыть ордер на покупку по нашему фин. инструменту; //
}
}


this is a topic for questions from those who want to understand and learn.

your topic is more suited to "freebies", "want" and other nonsense and misunderstandings

 
abolk:


this is a topic for questions from those who want to understand and learn.

your topic is more suited to the topics of "freebies", "want" and other nonsense and misunderstandings


I am not denying that I am learning. If I wasn't, why would I be asking for help.
 

Wouldn't that work for you? Anywhere in the code can be inserted.

while (Volume[0]>1)
{
  Print("Ждём новую свечу");
}
Print("А вот и новая свеча");
Print("Цена открытия предыдущей свечи",iOpen(NULL,0,1));
Print("Цена закрытия предыдущей свечи",iClose(NULL,0,1));
 
kolyango:

Help me create a simple code like this (if you can get a ready-made code right away):

if (Если есть открытый ордер на продажу по нашему фин. инструменту) //
{
Закрыть ордер; //
}
else
{
if (Если нет открытых ордеров на продажу по нашему фин. инструменту) //
{
Открыть ордер на покупку по нашему фин. инструменту; //
}
}


int sells=0;
for (int i=0; i<OrdersTotal(); i++)
   {
      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
      {
         if (OrderSymbol() !=Symbol() || OrderMagicNumber() !=magic || OrderType() !=SELL ) continue;
         OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),3,White);
         sells++;
      }
   }
if (sells==0) OrderSend(Symbol(),OP_BUY, LOT,NormalizeDouble(Ask,Digits),3,StopLoss,TakeProfit,"",magic,0,Green); 
 
evgenii_7:

hello all

I am new to mts programming

I have a good Expert Advisor that makes 14 000 deposits

after that it starts to lose

I changed the maximum drawdown parameter to 14 000 and it does not lose 22 000

Thanks in advance.


It is not losing because it reaches a certain profit, just at that moment the market behavior changes and your Expert Advisor starts to make a mistake.

Watch the schedule of deals in this interval, analyze and add bypassing of such moments to the code.

There are interesting moments, for example, the EA behaves perfectly on one pair, and loses on the other, so after analysis it turns out that the signal to buy or sell on the successful pair, on this pair must simply invert. This is the trick that really works for me :)

 

Happy New Year!!!!!!!!!!!!!!!!!!!!

Sorry, I can't figure out the ObjectCreate function,

This is how ObjectCreate( string Verkhnyayastrelka, OBJ_ARROW, 0, Time[0], Verhnyayaghranytsa, ) writes an error;

Alert(" Verkhnyayastrelka " GetLastError() );

ObjectCreate( string Nizhnyayastrelka, OBJ_ARROW, 0, Time[0], Nyzhnyayaghranytsa, ) ;
Alert(" Nizhnyayastrelka " GetLastError() );


'OBJ_ARROW' - variable expected C:\Osenyaya sochi\experts\mom change.mq4 (117, 42)

***************************************8

So

ObjectCreate( Verkhnyayastrelka, OBJ_ARROW, 0, Time[0], Verhnyayaghranytsa, ) ;

Alert(" Verkhnyayastrelka " GetLastError() );

ObjectCreate( Nizhnyayastrelka, OBJ_ARROW, 0, Time[0], Nyzhnyayaghranytsa, ) ;
Alert(" Nizhnyayastrelka " GetLastError() );

'Verkhnyayastrelka' - variable not defined C:\Fall Sochi\experts\change.mq4 (117, 17)

'Nizhnyayastrelka' - variable not defined C:\Fall Sochi\experts\changing.mq4 (120, 16)


*************************************************************************************************


So, 'Nizhnyayastrelka', Nizhnyayastrelka;

ObjectCreate( Verkhnyayastrelka, OBJ_ARROW, 0, Time[0], Verhnyayaghranytsa, ) ;
Alert(" Verkhnyayastrelka " GetLastError() );

ObjectCreate( Nizhnyayastrelka, OBJ_ARROW, 0, Time[0], Nyzhnyayaghranytsa, ) ;
Alert(" Nizhnyayastrelka " GetLastError() );




')' - parameter expected C:\Osenyaya sochi\experts\mom change.mq4 (117, 79)

'''GetLastError'' - an operator expected C:\Autumnsoy/experts/whatever.mq4 (118, 28)

')' - parameter expected C:\Autumn soju\experts/whatever.mq4 (120, 77)

'GetLastError' - an operator expected C:\Autumn soju/experts/whatever.mq4 (121, 27)


Setver!!!!! works very badly When trying to insert text something works with the twenty-first attempt, then the balloon above the mouse arrow is spinning for a long time, and only after 2-5minutes I see it! Also about suddenly jumps up and down! And sends 3-6 minutes!!!



 
You cannot write the parameter type in line ObjectCreate( string Verkhnyayastrelka, OBJ_ARROW, 0, Time[0], Verhnyayaghranytsa, ) ; - it is specified in help so that user knows exactly what type to insert the parameter. A comma before closing parenthesis is unnecessary.
 
Thank you!!!
 
alexhammer:


Help create such uncomplicated code (if you can get a ready-made code right away):

if (Если есть открытый ордер на продажу по нашему фин. инструменту) //
{
Закрыть ордер; //
}
else
{
if (Если нет открытых ордеров на продажу по нашему фин. инструменту) //
{
Открыть ордер на покупку по нашему фин. инструменту; //
}
}

Something about yours isn't working. Or is something wrong? Help me make the right one!

//+------------------------------------------------------------------+
int start()
{
int
magic,
SELL,
sells=0;
double
LOT,
StopLoss,
TakeProfit;
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if (OrderSymbol() !=Symbol() || OrderMagicNumber() !=magic || OrderType() !=SELL ) continue;
OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),3,White);
sells++;
}
}
if (sells==0) OrderSend(Symbol(),OP_BUY, LOT,NormalizeDouble(Ask,Digits),3,StopLoss,TakeProfit,"",magic,0,Green);
return(0);
}
//+------------------------------------------------------------------+