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

 
Rustbunch:

Help me find an EA or a script, there must be one ready...

I need an EA to open a deal with a certain loss and profit at a certain time on the market. I do not need anything else from it...

Thank you in advance.

Any Expert Advisor does this in MetaEditor, and the corresponding scripts in MetaEditor!

if(Hour() >= xx) открыть;
 
Because I have order accounting in an array. It's all peeved.
 
if (!PozyProstavleny){ ArrayResize(Buy,Raz);ArrayResize(Sell,Raz);
   
           Price= (Ask+Dist*Point) ; TP_BUY=(Price+TP*Point);  SL_BUY= (Price- SL*Point);
           Price_SELL= (Bid-Dist*Point) ;  TP_SELL=Price_SELL-TP*Point;  SL_SELL=Price_SELL+SL*Point; K=1;
           
   for(int Raz1=0;Raz1<Raz;Raz1++){
   
           Sleep(2000); RefreshRates();  for(int A=25;A>=0;A--){if(IsTradeAllowed())break;if(A==0) Comment(" эксперту не разрешено 
торговать или поток для выполнения торговых операций занят "); }           
  tyccBuy= OrderSend (Symbol( ), OP_BUYSTOP,  Lot ,NormalizeDouble(Price, Digits), 5, NormalizeDouble( SL_BUY,Digits),  
 NormalizeDouble( TP_BUY,Digits), NULL, 450, 0, CLR_NONE);
   Buy[Raz1]= tyccBuy;
           Price= (Price+Dist*Point) ; TP_BUY= (Price+TP*Point); SL_BUY= (Price- SL*Point);
           Error=GetLastError();
     if (Error!=0){ string errorcomment = "Ошибка открытия ордера байстоп  "  + " " + Symbol() +  " " + ErrorDescript(Error); 
           Print (errorcomment);}
           
           Sleep(2000); RefreshRates();  for( A=25;A>=0;A--){if(IsTradeAllowed())break;if(A==0) Comment(" эксперту не разрешено торговать
 или поток для выполнения торговых операций занят "); }        
           Sell[Raz1]=OrderSend (Symbol( ), OP_SELLSTOP,  Lot ,NormalizeDouble(Price_SELL, Digits), 5, NormalizeDouble( SL_SELL,Digits), 
  NormalizeDouble( TP_SELL,Digits), NULL, 450, 0, CLR_NONE);
     Price_SELL= (Price_SELL -Dist*Point) ;TP_SELL=Price_SELL-TP*Point;   SL_SELL=Price_SELL+SL*Point;
            Error=GetLastError();if (Error==0)
            
            {errorcomment = "Ошибка открытия ордера селлстоп  "  + " " + Symbol() +  " " + ErrorDescript(Error); 
        Print (errorcomment);} PozyProstavleny=1; 
                       }
                       }   
                        
 

Good day to you all!

I'm a newbie. This is my first time trying to put an idea into code in the tester.

The idea is simple - to open one order alternately up and down at opening price of each hourly candlestick.

I wrote a simple code .... But the problem is that the program sometimes opens more than 1 order at opening of one candlestick.

As it seems to me it happens when more than 1 tick comes in 1 second.

I tried to put in header of if( ) condition...

OrdersTotal()==0

Only one order really opens.



But this variant does not suit me since the next day the given candle is not opened, since at the moment of opening of this candle

There is already a random number of orders in the trade.

I also tried to interrupt the execution of the OrderSend(Symbol(),OP_BUY,0.1,Price,3,SL,TP) with return; ..... did not help.


I would appreciate if you tell me how to make only 1 order is opened at any tick within 1 second.

int start()

{
double Price=Ask;
double SL=Price-300*Point;
double TP=Price+300*Point;
if( Hour()==10 && Minute()== 00 && Seconds()==00)
OrderSend(Symbol(),OP_BUY,0.1,Price,3,SL,TP);
}

 
And so on.
 
Dimka-novitsek:
Well, I don't know how, but the data should be saved.

//записать

void SaveArray(string File, double &a[])
{
    int h = FileOpen(File, FILE_BIN|FILE_WRITE);
    if(h>0)
    {
      int sz = ArraySize(a); 
      FileWriteArray(h,a,0,sz);
      FileClose(h);
    }
}

//прочитать

void OpenArray(string File, double &a[], int sz)
{
    int h = FileOpen(File, FILE_BIN|FILE_READ);
    if(h>0)
    {
      ArrayResize(a,sz);
      FileReadArray(h,a,0,sz);
      FileClose(h);
    }
}
 
solnce600:

Good day to you all!

I'm a newbie. This is my first time trying to put an idea into code in the tester.

The idea is simple - to open one order alternately up and down at opening price of each hourly candlestick.

I wrote a simple code .... But the problem is that the program sometimes opens more than 1 order at opening of one candlestick.

As it seems to me it happens when more than 1 tick comes in 1 second.

I tried to put in header of if( ) condition...

OrdersTotal( )==0

Only one order really opens.



But this variant does not suit me since the next day the given candle is not opened, since at the moment of opening of this candle

There is already a random number of orders in the trade.

I also tried to interrupt the execution of the OrderSend(Symbol(),OP_BUY,0.1,Price,3,SL,TP) with return; ..... did not help.

I would appreciate if you tell me how to make only 1 order is opened at any tick within 1 second.

int start()

{
double Price=Ask;
double SL=Price-300*Point;
double TP=Price+300*Point;
if( Hour()==10 && Minute()== 00 && Seconds()==00)
OrderSend(Symbol(),OP_BUY,0.1,Price,3,SL,TP);
}

If that's TechZad, you're in the Job!
 
Thank you!!!!!!
 

solnce600:

I would be grateful if you tell me how to make it so that within 1 second, only 1 order is opened on any tick.

int start()
{
...

int ot=OrdersTotal();

bool open_allowed = true;

if(ot>0)
{
   if(OrderSelect(ot-1,SELECT_BY_POS))
   {
      if(TimeCurrent()-OrderOpenTime()<=1) open_allowed=false;  //если разница между текущим временем сервера и временем открытия последнего ордера 1 секунда или меньше, запретить торговлю
   }
}

if(open_allowed)
{
   //открываемся
}
...
}
 
Right... Roughly .Declare some variable before you start, remember the time. After placing an order, it is equal to, say, truth. Before setting it also check for it. I'm not good at time variables. Before the order is placed, check if the time is greater than the true time if it is added to this variable. If it's no longer, then ordersend, and remember the new time again! Yes, that's how it goes. Kinda simple even!!!
Reason: