[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 50

 
Zhunko:
The German mark, the ecu and the euro were taken into account. Thought everyone knew that.

Turns out not everybody... :(

It's strange... A brand is a brand - it's not a euro... Well, forget it... We'll take that fact into account...

 
Notter:

Good afternoon to all good people,

Question on trading with strong movements. The OrderSend function has the slippage parameter - the maximum slippage from the order price. Are there any limitations on its value? Or can we set it to 1000 points? Does "0" value mean zero slippage or this parameter is not considered when opening the order?

Besides, in case of a strong move, will my market order sent from my client terminal reach the server and wait for the execution of pending orders that are located on the server regardless of their prices or will it be executed immediately at the market price at the moment of its receipt? In other words, can I expect the order to be executed before the break or it will be opened only at the correction start?

Slippage is the difference in points between the order price in your terminal and the price returned by the server. While they are thinking about it, the price can also move away. When there is a strong movement, the server usually slows down. The more it broods, the less chance you have of opening at the posted price, and therefore at a better price for you. If you set a slippage of 1000 pips, you will open... at the end of the move. This is profitable for the brokerage companies. And the more "kitchen :)", the longer the server will "think", overloading you with requotes and so on.

By setting the slippage parameter to 0, you will open only if the order price and the price returned by the server are identical.

 

Happy New Year!

I've written some code that is supposed to find the maximum and minimum of the specified time frame within a day. But in fact something doesn't work. Please take a look at it.

//+------------------------------------------------------------------+
//|                                                     +Session.mq4 |
//|                                       Copyright 2012, silhouette |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, silhouette"
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#include <+ChartTrendLineCreate.mqh>

string OpenTime="00:00"; // время открытия сессии
string CloseTime="09:00"; // время закрытия сессии
int Days=100; // количество расчитываемых дней

//+------------------------------------------------------------------+
string Symb;
int i;
bool Ans;
//+------------------------------------------------------------------+
int init()
  {
   Symb=Symbol();
   return(0);
  }

int deinit()
  {

   return(0);
  }

int start()
  {
   //+------------------------------------------------------------------+
   datetime Time_OD, H1_OS, H1_CS; 
   int H1_OpenDayShift, H1_OpenSessionShift, H1_CloseSessionShift, Hst, Lst;
   string H1_OD;
   double Maximum, Minimum;
   //+------------------------------------------------------------------+
   for(i=0; i<100; i++) // перебираем дни
    {
     Time_OD=iTime(Symb,PERIOD_D1,i); // находим дату открытия выбранного бара
     H1_OpenDayShift=iBarShift(Symb,PERIOD_H1,Time_OD,false); // ...его индекс
     
     H1_OD=TimeToStr(Time_OD,TIME_DATE); 
     
     H1_OS=StrToTime(H1_OD+" "+OpenTime);
     H1_OpenSessionShift=iBarShift(Symb,PERIOD_H1,H1_OS,false); // ...индекс бара открытия сессии
     H1_CS=StrToTime(H1_OD+" "+CloseTime);
     H1_CloseSessionShift=iBarShift(Symb,PERIOD_H1,H1_CS,false); // ...индекс бара закрытия сессии
     
     // ... максимум и минимум
     Hst=iHighest(Symb,PERIOD_H1,MODE_HIGH,(H1_OpenSessionShift-H1_CloseSessionShift),H1_CloseSessionShift);
     Lst=iLowest(Symb,PERIOD_H1,MODE_LOW,(H1_OpenSessionShift-H1_CloseSessionShift),H1_CloseSessionShift);
     Maximum=iHigh(Symb,PERIOD_H1,Hst);
     Minimum=iLow(Symb,PERIOD_H1,Lst);
     
     ChartTrendLineCreate(H1_OS, Maximum, H1_CS, Maximum, Red);
     ChartTrendLineCreate(H1_OS, Minimum, H1_CS, Minimum, Red);
     
     
    }

   return(0);
  }

 
silhouette:

Happy New Year!

I've written some code which is supposed to find the maximum and minimum of the specified time period within the day. But in fact something doesn't work. Please take a look at it.

Try H1_OpenSessionShift-H1_CloseSessionShift +1
 
Mislaid:
Try H1_OpenSessionShift-H1_CloseSessionShift +1
Thanks, now it finds everything as it should.
 
Can you please tell me how to make an EA to place orders every 4 hours on TF D1? Now I have to manually switch to small TF and set an order if indicator signals coincide with D1. It is tiresome and inconvenient.
 
sultonov:
If I wanted to ask how I could set an EA on TF D1 to place orders every 4 hours, for example? If my indicator signal is the same as on D1, then I have to manually go to small TF and place the order. It is tiresome and inconvenient.

Happy New Year, Yusuf!!!

To do this you need to explicitly prescribe conditions in your EA, including time tracking for setting orders, you can control a new bar on TF H4 to enable it to work.

In your case, what prevents the EA from being attached to the symbol chart on H4 and getting signals to open orders using D1 and explicitly setting them in the expa code?

P.S. What about you? Don't you drink alcohol or something?

It's January 2 here - drink and drink! :-)

 

I have written a function that should find the TP by Fibo:

//+-------------------------------------------------------------------------------------+
//| Вычисление ТП по Фибе                                                               |
//+-------------------------------------------------------------------------------------+
double GetProfitByFibo()
{
  double minValue, maxValue;
  
 // if(GetStateMa() == MA_TALKING_LONG)
    if(OrderType() == OP_BUYSTOP)
    {
      maxValue = iHigh(Symbol(),i_ExtremumLookingTF,i_maxValueShiftB);
      minValue = iLow(Symbol(),i_ExtremumLookingTF,i_minValueShiftB);
     
      if((maxValue - minValue) >= 7*pt)
      {
      double fibo1618 = NormalizeDouble((minValue + (maxValue - minValue)*1.618),Digits);
      }
   
    }
  
 // if(GetStateMa() == MA_TALKING_SHORT)
    if(OrderType() == OP_SELLSTOP)
    {
      maxValue = iHigh(Symbol(),i_ExtremumLookingTF,i_maxValueShiftS);
      minValue = iLow(Symbol(),i_ExtremumLookingTF,i_minValueShiftS);
 
      if((maxValue - minValue) >= 7*pt)
      {
      fibo1618 = NormalizeDouble((maxValue - (maxValue - minValue)*1.618),Digits);
      }
          
  }
  return(fibo1618);
}

External variables for this function are here:

extern string ___H2 = "_____  Параметры для функции Fibo_TP _____";
extern int i_ExtremumLookingTF = 5,
           i_maxValueShiftB = 8,
           i_minValueShiftB = 3,
           i_maxValueShiftS = 3,
           i_minValueShiftS = 8;

I insert this function instead of a fixed Take Profit in a working EA and the EA starts to stall. What may be wrong?

Periodically, when modifying an order, the TP is not set at all.

This is a function for buying, for example (I commented out the previous modification function):

//+-------------------------------------------------------------------------------------+
//| Открытие длинной позиции                                                            |
//+-------------------------------------------------------------------------------------+
bool OpenBuy()
{
  int ticket = -1;
  string myNote = "Сов баянул";
  
  double price = High[1] + i_thresholdFromInput*pt;
  double SL = Low[1] - i_thresholdFromBasedSL*pt ;

  if(price > Ask)
  {
    ticket = OrderSend(Symbol(),OP_BUYSTOP,0.1,NormalizeDouble(price,Digits),i_slippage,0,0,myNote,i_myMagic,0,Navy);
  }
  
  if(ticket > 0 && OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES) == true)
  //  if(!OrderModify(ticket,OrderOpenPrice(),NormalizeDouble(SL,Digits),NormalizeDouble(High[1] + i_tp*pt,Digits),0,Navy))
//  Print("GetProfitByFibo() = ", GetProfitByFibo());
      if(!OrderModify(ticket,OrderOpenPrice(),NormalizeDouble(SL,Digits),GetProfitByFibo(),0,Navy))
    return(false);
  
  return(true);
}
 
double GetOrderOpenPrice(string sy="NULL", int op=-1, int mn=-1)
{
datetime t;
double r=0;
int i, k=OrdersTotal();

if (sy=="0") sy=Symbol();
for (i=0; i<k; i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol()==sy || sy=="")
{
if (OrderType()==OP_BUY || OrderType()==OP_SELL)
{
if (op<0 || OrderType()==op)
{
if (mn<0 || OrderMagicNumber()==mn)
{
if (t<OrderOpenTime())
{
t=OrderOpenTime();
r=OrderOpenPrice();
}
}
}
}
}
}
}
return(r);

}


This function checks the opening price of the last order.

How to write this condition in the function call: If the price has moved up or down by 75 pips from the last order open price, we will continue working.

 

Hello!

The attached file contains an EA from Voldemar. Unfortunately, he is not answering in private and I would like to correct it as soon as possible.

How can I change the order opening conditions? At the moment, the EA is set to the rollback price. We want it to open based on the last bar. If the close price is lower than the open one, it will open a sell and vice versa.

Thank you

Files:
Reason: