[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 557

 
I wanted to firstly delete everything, on this currency pair, and secondly put one order.
 
Dimka-novitsek:
I wanted to first delete everything, second put one order.

Set according to TarasBY' s edits to the code:

At the beginning of the script code

"

#include     <stdlib.mqh>                        // Библиотека расшифровки ошибок


"

 

Of course I did! Even though I didn't realise what it was.

2012.11.30 15:09:07 Buyforum EURUSD,H1: removed
2012.11.30 14:51:56 Buyforum EURUSD,H1: uninit reason 0
2012.11.30 14:51:05 buyforum EURUSD,H1: loaded successfully

 
It's showing off - it won't send, it won't insert. Thinks for 20 seconds at a time.
 
Dimka-novitsek:

Of course I did! Even though I didn't realise what it was.

2012.11.30 15:09:07 BuyForum EURUSD,H1: uninit
2012.11.30 14:51:56 Buyforum EURUSD,H1: uninit reason 0
2012.11.30 14:51:05 buyforum EURUSD,H1: loaded successfully


It's working properly. No errors.

scripts are unloaded from the chart after successful loading (loaded successfully).

 

That's it, it worked!!! Thank you. When I put an EA on a chart, in addition to the fact that the EA window is lit with a green circle, I specifically allow it to trade - the EA asks for variable parameters, and at the same time, the permission to trade.

My script on the chart silently disappears. Expert Advisors are trading next to each other and I am not. I guessed that there is some kind of a mystery here.

I dug around in the settings, tuned everything and it all worked. Thanks a lot!

 
Thanks again, sorry!
 

Can you tell me how to write (or what to write) so that only strictly defined values can be chosen in the external variable parameters?

Say: 5, 10, 20, 40, 60 etc...

If you can't write it down, what's the best way to do this? by comparing with price and rounding? or else?


Thanks in advance!

 
TarasBY:

Maybe this will work:


Try this
//|                                                         0000.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
//+------------------------------------------------------------------+
#include     <stdlib.mqh>                 // Библиотека кодов ошибок
string ErrorDescription(int error_code);
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int start()
   {
   double ld_Price;int N=23,Ticket=-1;
   for (int i=OrdersTotal()-1;i>=0;i--)
      {
      if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))continue;
      if(OrderSymbol()!=Symbol())continue; 
      if(OrderType()>=2)
         {
         if(OrderDelete(OrderTicket())==true)continue;
         else Print("Error: ",ErrorDescription(GetLastError()));
      }
      if(OrderType()==OP_SELL)ld_Price=Ask;
      if(OrderType()==OP_BUY)ld_Price=Bid;
      if(OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(ld_Price,Digits),6,Red)==true)continue;
      else Print("Error: ",ErrorDescription(GetLastError()));
   }
   for(i=0;i<N;i++)
      {
      if(!IsTradeAllowed()){Sleep(2000);continue;}
      RefreshRates();
      Ticket=OrderSend(Symbol(),OP_BUY,0.1,NormalizeDouble(Ask,Digits),6,0.0,0.0,"Skript",98600,0,Blue);
      if(Ticket>=0)break;
      else Print("Error: ",ErrorDescription(GetLastError()));Sleep(2000);
    }
    if(Ticket<0)Alert("Не удалось открыть ордер за ",N," попыток","Error: ",ErrorDescription(GetLastError()),". Скрипт завершил работу.");
    return (0);
}
//+------------------------------------------------------------------+
 
Chiripaha:

Can you tell me how to write (or what to write) so that only strictly defined values can be chosen in the external variable parameters?

Say: 5, 10, 20, 40, 60 etc...

If this cannot be written, what's the best way to do it? by comparing to price and rounding? or something else?


Thanks in advance!


Declare an external variable of type string and initialize it with string with instruction and your set of parameters. It will be visible in properties window .