Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 113

 
hoz:


Actually, yes. Maybe it's too late, but I don't get it. That's essentially the profit in pps. that's the distance from opening to closing. Why then is the expression wrong?

Because we have to divide by point the result of this expression
 

I'm getting a bit full of myself... :) The problem:

1. There is an open position of 0.1 lot

2. Its TakeProfit value is 50 pips.

3. I calculate its potential profit according to the formula PotentialProfit = Lots*TakeProfit*MarketInfo(Symbol(), MODE_TICKVALUE);

4. from the calculation I get the potential profit of $5.00 (0.1*50*1.0).

The position goes in the red and at some point one more averaging Buy opens, but with 0.2 lot

1. I calculate Breakeven for these two positions. The function has been used for a long time, as required, and I do not have any complaints so far:

//+----------------------------------------------------------------------------+
/*
Расчёт уровня БУ для множества по одному инструменту:
сумма лотов = суммарная позиция (СП)
стоимость тика СП = СТ
профит СП = ПСП
Формула расчёта довольно проста:
КП = ПСП / (СТ * СП)
В которой узнаём количество пипс (КП) до уровня БУ относительно текущей цены (ТЦ) символа.
И подставив КП в формулу БУ = ТЦ - КП * Point получаем уровень цены БУ.
В зависимости от направления СП выбирается прибавлять либо отнимать от ТЦ.
*/
double PriceWL(int op, int m1, int m2, double &ll) {
   double Res, pp, pt, tic, NumPP, Prof=0, SumLot=0.00000001;
   int i;
   
   pt =MarketInfo(sy,MODE_POINT);
   tic=MarketInfo(sy,MODE_TICKVALUE);                          // Стоимость тика СТ
   for (i=0; i<OrdersTotal(); i++) {
      if (OrderSelect(i,SELECT_BY_POS)) {
         if (OrderSymbol()!=sy)        continue;
         if (OrderType()!=op)          continue;
         if (OrderMagicNumber()==m1 || OrderMagicNumber()==m2) {
            Prof+=(OrderProfit()+OrderSwap()+OrderCommission());  // Суммарный профит позиций ПСП
            SumLot+=OrderLots();                                  // Суммарный лот позиций    СП
            }
         }
      }
   SumLot=MathAbs(NormalizeLot(SumLot));
   NumPP=MathAbs(Prof/(tic*SumLot));                           // Количество пунктов до уровня бу КП
   if (op==0) Res=Ask+NumPP*pt;
   if (op==1) Res=Bid-NumPP*pt;
   ll=SumLot;
   return(Res);
}
//+----------------------------------------------------------------------------+

2. Perfect. You have calculated the breakeven level, but... if you put the tokens of those two positions on it, they will close at zero. Okay, I think. Now I need to add to this level of the BU as many points as I need to obtain a total profit, equal to the previously calculated - $5.

3. And here is where I get a blockage in my brain. What I do: I take $ 5, divide by the total lot of these two positions (0.1 + 0.2 = 0.3), multiplied by TICK_VALUE

I have 5/(0.3*1.0) = 16.6666 Then I multiply it by Point (0.00016) and add to Breakeven price.

4. Perfect. Takes are transferred there, but it seems to me that the total profit of two Baisers closing at this level is not equal to $5 - it seems to me less. This can be seen from the testing chart. It clearly shows that when one position closes, the balance increase is much greater than when multiple positions are closed at the calculated total take level (you can see these places on the chart by the appearance of the equity line on them). The chart:


Where am I wrong?

I understand that you can print the total profit, but... I want to understand where I could be wrong in my calculations, not the value of the variables. I have printed them already.

 
semiromid:

I have a price consisting of 5 digits. Example: 1.3221.


It means 4 digits. Meaning 4 or 5 after the decimal point. Of five digits, it would be, for example, 132210.
 

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Gentlemen programmers, please advise how to combine an EA with an indicator?

For example, I took a simple bot mo_bidir.mq4 which trades using its own algorithm and I want it to open trades using its own algorithm but after 3 MA signals

For example on signal - Three Moving Averages:

FastEMA>MediumEMA>SlowEMA (trending up) - bot buys

FastEMA<MediumEMA<SlowEMA (trend down) - bot sells

Inp_Signal_ThreeEMA_FastPeriod = 8;

Inp_Signal_ThreeEMA_MediumPeriod = 38;

Inp_Signal_ThreeEMA_SlowPeriod= 48;

I want my Expert Advisor to trade on 5-minute timeframe and the indicator to give signals from daily or 4hour timeframe, and I want to be able to change timeframes in the settings of bot.

\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

I apologize for the repetition, but at least tell me in which forum thread to apply, or should I create a new thread?

I do not know what to do.

 
This is the place for you : Work
 

Hi all. Can you explain why OrderSend is not opening a position?

if (NormalizeDouble(Open[0],Norm)>ma && NormalizeDouble(Bid,Norm)<=ma)

      {

      if (CheckFiltr()>=Filtr) 

         {

         Print (CheckFiltr()+" Buy"); <= Это в журнале есть, значит должна открыться сделка.

         for (i=0;i>5;i++)

            {

            res=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Bid-Sl*Point,0,"OpenBuy",Magik,0,Green);

            Print ("Проверка Бай "+i); <= Этого в журнале нет.

            if (res>0) break;

            Print (GetLastError()); <= Этого в журнале нет.

            Sleep (5000);

            }

         }

      }   
 
for (i=0;i<5;i++)
 
artmedia70:

I'm getting a bit full of myself... :) The problem:

1. There is an open position of 0.1 lot

2. Its TakeProfit value is 50 pips.

3. I calculate its potential profit according to the formula PotentialProfit = Lots*TakeProfit*MarketInfo(Symbol(), MODE_TICKVALUE);

4. from the calculation I get the potential profit of $5.00 (0.1*50*1.0).

The position goes in the red and at some point one more averaging Buy opens, but with 0.2 lot

1. I calculate Breakeven for these two positions. The function has been used for a long time, as required, and I do not have any complaints so far:

2. Perfect. You have calculated the breakeven level, but... if you put the tokens of those two positions on it, they will close at zero. Okay, I think. Now I need to add to this level of the BU as many points as I need to obtain a total profit, equal to the previously calculated - $5.

3. And here is where I get a blockage in my brain. What I do: I take $ 5, divide by the total lot of these two positions (0.1 + 0.2 = 0.3), multiplied by TICK_VALUE

I have 5/(0.3*1.0) = 16.6666 Then I multiply it by Point (0.00016) and add to Breakeven price.

4. Perfect. Takes are transferred there, but it seems to me that the total profit of two Baisers closing at this level is not equal to $5 - it seems to me less. This can be seen from the testing chart. It clearly shows that when one position closes, the balance increase is much greater than when multiple positions are closed at the calculated total take level (you can see these places on the chart by the appearance of the equity line on them). The chart:


Where am I wrong?

I understand that you can print the total profit, but... I want to understand where I could be wrong in my calculations, not the value of the variables. I have printed them already.

even if the position is Sell ?
Files:
mr01.mq4  6 kb
 
FAQ:

for (i=0;i<5;i++)

I beg your pardon, explain what the mistake is here. I can't figure it out.

 
pako:
even if the position is Sell ?

I'm talking about buy positions. You don't have to be so meticulous. Naturally, for Sell positions I take away.