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

 
Forallf:
The middle one is for me as an example. There will be a different, calculated level.

any level can be set there, and in any quantity

 
Andrey Sokolov:

Hello. Could you please tell me how to calculate the Bid price.

How do I calculate a Bid price which several BUY positions will have a total zero profit for currency pairs, where the base (first) currency is the dollar, and the pip value is not constant and depends on prices?

For pairs where the dollar is the quoted (second) currency and the pip value is constant I have derived this function,

This will help you)
 
DanilaMactep:
Thank you very much for noticing and telling me, I fixed it and in 2 years of testing there were 26 errors 130. At the same time 115 trades opened normally

if the pending orders are placed at a distance from the current price less than the STOPLEVEL, there will be an error 130

that's why you were given this code

or if you have to take it into account in some other way

MarketInfo(_Symbol, MODE_STOPLEVEL);
 
Hello! Need code to close market orders after a certain time after opening (24 hours, 48 hours). The time should be adjustable.
 
Max330:
Hello, I need code to close market orders a certain time after they open (24 hours, 48 hours). The time should be adjustable.

like this

for(int pos=OrdersTotal()-1;pos>=0;pos--)
    if(OrderSelect(pos,SELECT_BY_POS)==true)
       if(OrderSymbol()==_Symbol)
         if(TimeCurrent()-(определенное время в секундах) >= OrderOpenTime()) 
            OrderClose(order_id,1,Ask,3,Red);
 
MakarFX:
This will help you)

Unfortunately it didn't help. This one is generally guided by opening prices

 
Andrey Sokolov:

Unfortunately it didn't help. This one is generally oriented towards opening prices.

Then I do not understand what you need.

Andrey Sokolov:

How to calculate the Bid price at which several BUY positions have a total zero profit

i.e. Breakeven?

 
MakarFX:

Then I don't understand what you want.

I.e. break-even?

To calculate a closing price for one or more unidirectional orders (bid for buy) at which their total profit+savings+commissions == 0.

This problem occurs in pairs where the base currency is dollar and the point value changes.

 
Forallf:
The middle is for me as an example. There will be another, calculated level.

The indicator draws the middle for any number of trend lines:

#property version   "1.00"
#property strict
#property indicator_chart_window

string symbol;
ENUM_TIMEFRAMES frame;
int digits;

long ChartId;
int Window;

datetime time1, time2;
double price;

int OnInit()
   {
   //идентификатор графика и номер окна индикатора
   ChartId=ChartID();
   Window=0;
   symbol=Symbol();
   frame=(ENUM_TIMEFRAMES)Period();
   digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
   ChartSetInteger(ChartId,CHART_EVENT_OBJECT_CREATE,true);
   return(INIT_SUCCEEDED);
   }

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
   {

   return(rates_total);
   }

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
   {
   if((id==CHARTEVENT_OBJECT_CREATE || id==CHARTEVENT_OBJECT_DRAG) && ObjectGet(sparam,OBJPROP_TYPE)==OBJ_TREND && StringFind(sparam,"Middle")==-1)
      {
      price=(ObjectGet(sparam,OBJPROP_PRICE1)+ObjectGet(sparam,OBJPROP_PRICE2))/2;
      time1=GetPointTimeOnStraight((datetime)ObjectGet(sparam,OBJPROP_TIME1),ObjectGet(sparam,OBJPROP_PRICE1),(datetime)ObjectGet(sparam,OBJPROP_TIME2),ObjectGet(sparam,OBJPROP_PRICE2),price,symbol,frame);
      time2=time1+PeriodSeconds(frame)*10;
      RedrawLine(ChartId,Window,sparam+"_Middle",time1,price,time2,price,(color)ObjectGet(sparam,OBJPROP_COLOR),(int)ObjectGet(sparam,OBJPROP_WIDTH),(string)ObjectGet(sparam,OBJPROP_TOOLTIP),digits);
      }
   }
      
//находит дату точки (координату X) на прямой, на заданную цену (координата Y)
datetime GetPointTimeOnStraight(datetime eTime1, double ePrice1, datetime eTime2, double ePrice2, double ePrice3, string eSymbol, int eTimeFrame)
   {
   if(ePrice2-ePrice1==0) return(0.0);
   //индекс бара соответствующий заданному времени, возможно задавать будующее время
   int eIndex1=(eTime1>iTime(eSymbol,eTimeFrame,0))?(int)((iTime(eSymbol,eTimeFrame,0)-eTime1)/PeriodSeconds(eTimeFrame)):iBarShift(eSymbol,eTimeFrame,eTime1);
   int eIndex2=(eTime2>iTime(eSymbol,eTimeFrame,0))?(int)((iTime(eSymbol,eTimeFrame,0)-eTime2)/PeriodSeconds(eTimeFrame)):iBarShift(eSymbol,eTimeFrame,eTime2);
   int eIndex3=eIndex1+(int)((eIndex2-eIndex1)*(ePrice3-ePrice1)/(ePrice2-ePrice1));
   if(eIndex3>=0)
      {
      return(iTime(eSymbol,eTimeFrame,eIndex3));
      }
   else
      {
      return(iTime(eSymbol,eTimeFrame,0)-eIndex3*PeriodSeconds(eTimeFrame));
      }
   }

//перерисовывает линию по новым координатам, если её нет, то создаёт
void RedrawLine(long eChartId, int eWindow, string eName, datetime eTime1, double ePrice1, datetime eTime2, double ePrice2, color eColor, int eWidth, string eTooltip, int eDigits)
   {
   if(ObjectFind(eChartId,eName)==-1)
      {
      if(!ObjectCreate(eChartId,eName,OBJ_TREND,eWindow,0,0)) return;
      ObjectSetInteger(eChartId,eName,OBJPROP_STYLE,STYLE_SOLID);
      ObjectSetInteger(eChartId,eName,OBJPROP_WIDTH,eWidth);
      ObjectSetInteger(eChartId,eName,OBJPROP_BACK,false);
      ObjectSetInteger(eChartId,eName,OBJPROP_SELECTABLE,false);
      ObjectSetInteger(eChartId,eName,OBJPROP_SELECTED,false);
      ObjectSetInteger(eChartId,eName,OBJPROP_RAY_RIGHT,false);
      ObjectSetInteger(eChartId,eName,OBJPROP_HIDDEN,true);
      }
   if(ObjectFind(eChartId,eName)==-1) return;   
   if(ObjectGetInteger(eChartId,eName,OBJPROP_TIME)!=eTime1) ObjectSetInteger(eChartId,eName,OBJPROP_TIME,eTime1);
   if(NormalizeDouble(ObjectGetDouble(eChartId,eName,OBJPROP_PRICE)-ePrice1,eDigits)!=0) ObjectSetDouble(eChartId,eName,OBJPROP_PRICE,ePrice1);
   if(ObjectGetInteger(eChartId,eName,OBJPROP_TIME,1)!=eTime2) ObjectSetInteger(eChartId,eName,OBJPROP_TIME,1,eTime2);
   if(NormalizeDouble(ObjectGetDouble(eChartId,eName,OBJPROP_PRICE,1)-ePrice2,eDigits)!=0) ObjectSetDouble(eChartId,eName,OBJPROP_PRICE,1,ePrice2);
   if(ObjectGetInteger(eChartId,eName,OBJPROP_COLOR)!=eColor) ObjectSetInteger(eChartId,eName,OBJPROP_COLOR,eColor);
   if(ObjectGetString(eChartId,eName,OBJPROP_TOOLTIP)!=eTooltip) ObjectSetString(eChartId,eName,OBJPROP_TOOLTIP,eTooltip);
   }
 
Hi all. Question: I can only select Just2Trade from the list of brokers. When searching for other brokers nothing happens. I tried reinstalling, cleared all the folders and files (including hidden ones). Has anybody had such a problem?
Files:
Reason: