Questions from Beginners MQL5 MT5 MetaTrader 5 - page 354

 
Arsen_Syharev:
Please advise which command to write to open an order at the same time when Sell1 and Sell2 fractals are opened
There is nothing on the forum.
 
Hi friends, could you suggest a simple function, which, if any conditions come true... (SigPF==1 or SigPF==2) and OrdersTotal>0 i.e. only orders that are currently in the market should be processed if one of the SigPF conditions occurs.

This is the external variable that checks the condition inside the function
extern int PF_price_in_pips=70;
The function should:
1.define what kind of orders we are dealing with... if SigPF==1, then it is a Buy order, if SigPF==2, then it is a Sell order
2. check the current price and if
there is a Buy order and SigPF==1 is present in the market, then

the difference between the current price at which the Buy order is to be opened and any of the open prices of the orders already in the market is higher than PF_price_in_pips, the function should return valid_signal=true


there are now Sell orders in the market, and SigPF==2 has been set, then

the difference between any open order price already present in the market and the current price, at which the Sell order will be opened, is higher than PF_price_in_pips, then the function should return the valid_signal=true flag

if the distance between the opening price of the new order at the occurrence of buy/sell signals is lower than PF_price_in_pips, the function should return valid_signal=false

Basically, in a nutshell, the function should check the distance between the open price of the new order at buying and selling signals (SigPF==1, SigPF==2) and any of the order open prices that are already in the market... and if that distance is greater than PF_price_in_pips then the valid_signal=true should be returned. This is to avoid opening orders at prices very close to each other! And another thing... my EA only trades on opening of a new bar... not on all ticks... but I don't think it matters... I have to consider Bid or Ask prices anyway ...

help with this function... ! If something is not clear i will try to explain ... or give pictures! Just help me) Thank you!
 

I'm not sure I got the terms right, but...

   int PF_price_in_pips=70;
   int OrdTotal=OrdersTotal();
   bool valid_signal=false;
   int SigFF;
   
   if(OrdersTotal()>0)
   {
   for(int i=OrdTotal-1; i>=0; i --)
     {
      if(!OrderSelect(i,SELECT_BY_POS))
         continue;

      if(OrderType()==OP_BUY && SigFF==1 && Ask+OrderOpenPrice()>PF_price_in_pips)
         valid_signal=true;
         else
         valid_signal=false;
      if(OrderType()==OP_SELL && SigFF==2 && OrderOpenPrice()-Bid>PF_price_in_pips)
         valid_signal=true;
         else
         valid_signal=false;

     }
     }
 
Arsen_Syharev:
Can you tell me which command to write so that when the fractals Sell1 and Sell2 open at the same time an order
What value of Sell1 and Sell2 would suit you to open an order. //I can't watch your anguish anymore....
 
Arsen_Syharev:
Can you tell me which command to write so that when Sell1 and Sell2 fractals are opened at the same time an order is opened
if (Sell1 !=0 && Sell2 != 0){

/* Если по текущей цене */ 

OrderSend(Symbol1, OP_SELL, Lots, Bid, 1, 0, 0, 0, Magik, 0, Red);

OrderSend(Symbol2, OP_SELL, Lots, Bid, 1, 0,0, 0, Magik, 0, Red); 

/*Если по пробитию фракталов отложенными ордерами */

 OrderSend(Symbol1, OP_SELLSTOP, Lots, Sell1, 1, 0, 0, 0, Magik, 0, Red);

OrderSend(Symbol2, OP_SELLSTOP, Lots, Sell2, 1, 0,0, 0, Magik, 0, Red);  

} 

But this must be a VERY VERY crude example

 
Do you know if it is possible to sign more than one signal on one account?
 

Hello Colleagues, recently joined your ranks :). I'm sick of pending orders and decided to use a script that I have downloaded from the Internet but it was not satisfying: I had errors in one direction only, and the other script only placed one order in each direction. It essentially consists in opening of a certain amount of pending orders in both directions. Question: How can I set a trailing stop on each order? This is a script, not an Expert Advisor. The orders were opened, the trailing stop was attached to them, and that is all, the script has done its job. How can I use the script to trigger a regular trailing stop which is executed by a right-click on an order? 4th MetaTrader Build 765.

 
entitie:

Hello Colleagues, recently joined your ranks :). I'm sick of pending orders and decided to use a script that I have downloaded from the Internet but it was not satisfying: I had errors in one direction only, and the other script only placed one order in each direction. It essentially consists in opening of a certain amount of pending orders in both directions. Question: How can I set a trailing stop on each order? This is a script, not an Expert Advisor. The orders were opened, the trailing stop was attached to them, and that is all, the script has done its job. How can I use the script to trigger a regular trailing stop which is executed by a right-click on an order? 4th MetaTrader Build 765.

Freelance does everything).
 

Hi all!

The task is as follows - I need to open orders after a certain distance Step on EURUSD.m to buy and on EURUSD.m1 to sell. This problem is solved in the code below.

However, if the price has gone against us, we still need to open buy orders for EURUSD.m, provided that the price has gone from the last order to sell at EURUSD.m1 at a distance of Step*2. This condition will work under the condition that this opening price is lower than the price of the last buy order for EURUSD.m.

I cannot figure out how to do it. I would be glad to help.

// бай евро доллар
if (rates[1].open < rates[1].close && !PositionSelect(Symbol1)) 
   {
      LastPriceBuy = OpenBuy(Symbol1,Lot); // если бычья свеча и нет открытой позиции по этому символу
   }
if (GlobalVariableCheck ("bb_1")) GlobalVariableGet("bb_1", bb_1);  // цифровая переменная внутренняя и ее проверка

if (PositionSelect(Symbol1) && LastPriceBuy > 0) //открытие второго и последующих ордеров
  {
   if(LastPriceBuy+Step*_Point < SymbolInfoDouble(Symbol1,SYMBOL_ASK)) 
   {LastPriceBuy = OpenBuy(Symbol1,Lot);} // открытие позиции в бай по евро доллару всех последующих ордеров 
  }    

// сел евро доллар
if (rates[1].open > rates[1].close && !PositionSelect(Symbol3)) {LastPriceSell = OpenSell(Symbol3,Lot);} // если бычья свеча и нет открытой позиции по этому символу
if (GlobalVariableCheck ("ss_1")) GlobalVariableGet("ss1_", ss_1);  // цифровая переменная внутренняя и ее проверка

if (PositionSelect(Symbol3) && LastPriceSell > 0) //открытие второго и последующих ордеров
  {
   if(LastPriceSell-Step*_Point > SymbolInfoDouble(Symbol3,SYMBOL_BID))
   {LastPriceSell = OpenSell(Symbol3,Lot);} // открытие позиции в селл по евро доллару всех последующих ордеров 
  } 
 
zfs:
Freelancers do it all).

A very valuable and informative reply-commentary, I suggest you use it too...

As a matter of fact - there is no simple command that, after opening an order, hangs a standard trailing stop on top of it?