[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 387

 
Dimka-novitsek:
Sorry, I can't follow the link, it's not working for me.
int OrdersHistoryTotal( )
Returns the number of closed positions and deleted orders in the history of the current account, loaded in the client terminal. The size of history list depends on current settings of "Account history" tab of the terminal.
Example:
  // retrieving info from trade history int i,accTotal=OrdersHistoryTotal(); for(i=0;i<accTotal;i++) { //---- check selection result if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error accessing the history base (",GetLastError(),")"); break; } // work with order ... }
 
Thank you!!!
 

Can you tell me how to correctly specify in the condition the name of the instrument of the already open order? If an order EURUSD_bay is open, then EURJPY_sell should be opened. I think we have something wrong here. If we remove OrderSymbol()=="EURUSD", the order will open, but to open the third order, we still have to solve this problem.

if((OrdersTotal()==1)&&(OrderType()==OP_BUY && OrderSymbol()=="EURUSD"))
     {
     TimeBar=Time[0];
     OPENORDER2("Sell");
     }
 

Can someone please advise me how to write a code that would make deals at a certain time. I looked at the FAQ and did not understand anything. I am a programmer, but I am in direct conflict with this language.

I want to show in details what I should do every day at 8:00 am to grab an hour bar and open pending orders from it. To close the pending orders it is necessary either by expiry of time or by TP. and again at 8-00 to take a bar, etc. The code below. This is a problem with the first deal that works clearly according to the criteria, and then I get something for nothing. If it is not difficult please help....

//Учет закрытых ордеров-----------------------------------------------
  if (OrderSelect(Ticket,SELECT_BY_TICKET,MODE_HISTORY)==true) or_cl=OrderCloseTime();
   else or_cl=StrToTime(TimeToStr((TimeCurrent()+24*60*60), TIME_DATE)+" "+17+":"+59);
     
   // Предварит.обработка
  
  time_op=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+8+":"+0);
  time_bar=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+7+":"+0);
  Cur_time=StrToTime(TimeToStr(TimeCurrent(), TIME_SECONDS));
 
 if (Cur_time>or_cl)
   {time_op+=24*60*60;
      time_bar+=24*60*60;}
    else {time_op-=24*60*60;
          time_bar-=24*60*60;}  
  
  if (Cur_time<=time_op && Total==0)return;
  // Определяем часовой квадрат--------------------------------------------------------------
   Hit=NormalizeDouble(High[iBarShift(NULL,PERIOD_H1,time_bar)],5);
   Lo=NormalizeDouble(Low[iBarShift(NULL,PERIOD_H1,time_bar)],5); 


 
coolon:

Can someone please advise me how to write a code that would make deals at a certain time. I looked at the FAQ and did not understand anything. I am a programmer, but I am in direct conflict with the language.

I want to show in details what I should do every day at 8:00 am to grab an hour bar and open pending orders from it. To close the pending orders it is necessary either by expiry of time or by TP. and again at 8-00 to take a bar, etc. The code below. This is a problem with the first deal that works clearly according to the criteria, and then I get something for nothing. If it is not difficult please help....



h ttps://www.mql5.com/ru/forum/130550

 

I'm sorry, I've written some nonsense here, if you could show me where I'm completely sheepish.

The poses don't seem to open at all, nothing happens.

//+------------------------------------------------------------------+
//| for avalanche.mq4 |
//| Copyright © 2011, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
extern double stoploss=0; extern double takeprofit=20; extern int otstup=20; extern datetime expiration=0;

//+------------------------------------------------------------------+
//| expert initialisation function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialisation function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int tiket,tikett;double volume=0.1;int i=0,R1,R2,A=1 ;double price=PRICE_OPEN;
R1=((PRICE_OPEN- stoploss*Point)*stoploss)/stoploss;R2=((PRICE_OPEN+ stoploss*Point)*stoploss)/stoploss;


int start()
{
//----

OrderSelect()tiket,SELECT_BY_TICKET, MODE_TRADES );
if(OrderSymbol()==Symbol()){
if(OrderMagicNumber( )==1000||OrderMagicNumber( )==2000 ){i=OrdersTotal() ;
if (i<2){
tiket= OrderSend( Symbol(), OP_BUYSTOP, volume*A, price+otstup*Point, Point*3, R1, PRICE_OPEN+takeprofit*Point+otstup, "OP_BUYSTOP", 1000, expiration, Red);
Alert ("OP_BUYSTOP", GetLastError( );
tikett= OrderSend( Symbol(), OP_SELLSTOP, volume*A, price -otstup*Point, Point* 3,R2, PRICE_OPEN-takeprofit*Point-otstup, "OP_SELLSTOP", 2000, expiration,C'0,128,255' );
Alert ("OP_SELLSTOP", GetLastError( );
i=OrdersTotal() ; } } }

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

 
double stoploss=0
You cannot divide by zero.
 
Good people help!!!!!! Need a script to close positions any on Bollinger middle line!!!!! Please!!!!
 
alexr7:
Good people help!!!!!! Need a script to close positions any on Bollinger middle line!!!!! Please!!!!
And what is your criterion for a position to be on the bollinger midline?
 
artmedia70:
And what is the criterion for you that a position is on the Bollinger midline?
Thank you very much for your quick response!!!!!!!!!!!!!! The criterion is a standard Bollinger Bands indicator with parameters: period 20, shift 0, deviation 2, Weighted Close(HLCC/4)!!!!!!!