Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 467

 
haron312:

Hello, please help me with the error that occurs in the tester when I try to modify an order (transfer to Breakeven): I put the OrderOpenPrice() function instead of SL, but the tester shows error1 (according to the documentation it means that there is an attempt to passunchanged values as parameters to the function). I attach the code! Thank you in advance!

void DeleteOrderFunction2() //function that deletes the second order and sets the second order to Breakeven on a certain evening

{

bool flag = false;

if (FlagDeleteSecondOrder2 == true)

{

if(DayOfWeek() == DAYOFWEEK && //if a weekday is selected

Hour() == 22 //if evening

)

{

if(BuyCount() == 1 && if(there is an open Buy order

SellStopCount() == 1 //and there is a sell pending order

)

{

for( int i = 0; i < OrdersTotal(); i++) //create orders

{

OrderSelectX(i, SELECT_BY_POS, MODE_TRADES;)

switch(OrderType())

{

case OP_BUY: if(OrderProfit() > 0 &&

Bid > OrderOpenPrice()

)

{

OrderModifyX(OrderTicket(),OrderOpenPrice(),OrderTakeProfit(),0,Arrow_Color);

flag =true;

}

break;

case OP_SELLSTOP: if(flag==true)

{

OrderDeleteX(OrderTicket(), Arrow_Color);

}

break;

}

}

}

if(SellCount() == 1 && // if there is an open Sell order

BuyStopCount() == 1 //and there is a Buy pending order

)

{ Print("IS!!!!");

for( int i = 0; i < OrdersTotal(); i++) //create orders

{

OrderSelectX(i, SELECT_BY_POS, MODE_TRADES;)

switch(OrderType())

{

case OP_SELL: if (OrderProfit() > 0 &&

Ask < OrderOpenPrice()

)

{

OrderModifyX(OrderTicket(), OrderOpenPrice(),OrderTakeProfit(),0, Arrow_Color);

flag = true;Print("flag =", flag);

}

break;

case OP_BUYSTOP: if(flag == true)

{

Print("flag =", flag);

OrderDeleteX(OrderTicket(), Arrow_Color);

}

break;

}

}

}


}


}

}

assume that OP_BUY is first encountered among the orders, you modify it and set flag =true and when it is encountered the pending order will be deleted. And see what happens if the pending order is first encountered...
 

Help me convert the indicator into a script!

double buf_1[];
double buf_2[];
//+------------------------------------------------------------------+
//| Функция инициализации, запускается один раз                      |
//+------------------------------------------------------------------+
int init() 
  {
   SetIndexBuffer(0,buf_1);
   SetIndexBuffer(1,buf_2);

   SetIndexStyle (0,DRAW_ARROW, STYLE_SOLID, 1);
   SetIndexStyle (1,DRAW_ARROW, STYLE_SOLID, 1);
   SetIndexArrow (0,233);
   SetIndexArrow (1,234);

   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Основная Функция, запускается на каждом тике                     |
//+------------------------------------------------------------------+
int start() 
  {
   if (Bars <= 100) return(0);
   int ExtCountedBars = IndicatorCounted();
   if (ExtCountedBars < 0) return(-1);
   if (ExtCountedBars > 0) ExtCountedBars--;
   for (int i=Bars-ExtCountedBars-1; i>=0; i--)
     { 
      if (High [i+2] == High[i+3])
      bool DOWN   = High[i+1]== High[i+2]; 
                                               
                    
      if (Low [i+2] == Low [i+3])             
     bool UP =  Low[i+1]==Low[i+2] ;
      
       
      if (UP)   buf_1[i+1] = Low[i+1]-3*Point;
      if (DOWN) buf_2[i+1] = High[i+1]+3*Point;
     }
   return(0);
 }
  //  ---- end

If iHigh(NULL,PERIOD_H1,[i+2]) and iLow(NULL,PERIOD_H1,[i+2]) are written instead ofHigh [i+2] andLow[i+1], then you can control the timeframe?

If Hai matched SELL, if Loh BUY!

 
Rewerpool:

Help me convert the indicator into a script!

If iHigh(NULL,PERIOD_H1,[i+2]) and iLow(NULL,PERIOD_H1,[i+2]) are written instead ofHigh [i+2] andLow[i+1], then you can control the timeframe?

If Hai matched SELL, if Loh BUY!

three coincidences will have to wait a long time

 
STARIJ:

three hits will have to wait a long time.

I'm not a scalper, I'll wait. We can normalise on the 4 digits.

 

in mql5 we have open positions, I find all trades in this position and determine whether they were opened by market or pending orders

in mql4, how can i find out if an open position was opened by market or pending orders and its tickers change when a pending order triggers?

 
Rewerpool: I'm not a scalper, I'll wait. We can normalize on the 4 digits.

Yes and the result is weak ...

5 hai's matched and the price is up.

 
Pavel Kolchin:

in mql5 we have open positions, I find all trades in this position and determine whether they were opened by market or pending orders

in mql4, how can i find out if the open orders were opened by market or pending orders and their tickers change when a pending order triggers?

give them different magiks

 
STARIJ:

give them different magiks

Orders are opened by a user, I need to define their type when they are opened

 
The question is what will "load more": at each defined InChartEvent redefine indicator handle or define all possible handles as an array beforehand in OnInit?
 
Roman Sharanov:
The question is what will "load more": at each defined InChartEvent redefine the indicator handle or define all possible handles as an array beforehand in OnInit?
Different.
Reason: