[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 130

 

Hello. Can you please help me figure this out? The code should display a line at the global TakeProfit level. I can't find the error.

Thank you in advance.

void Drawline_Per_B (int Drawline_Per, double Balans, double Free, double Global_TakeProfit)  {
    Balans=AccountBalance();//Баланс счёта
    Free=AccountEquity();//Текущее количество денег в статье "Средства"
    double q;
    double SchBuyLs=SchBuyLs_b(); сумма лот для баев
    double SchSellLs=SchSellLs_b(); сумма лот для сейлов  
    double ad.QuotePoint   = MarketInfo ( Symbol () , MODE_POINT     );
    double ad.QuoteTick    = MarketInfo ( Symbol () , MODE_TICKSIZE  );
    double ad.NominalTick  = MarketInfo ( Symbol () , MODE_TICKVALUE );
    double ad.NominalPoint = ad.NominalTick  * ad.QuotePoint / ad.QuoteTick ; // Цена 1 пункта для стандартного лота в валюте депозита
    q =  NormalizeDouble(Bid + (Balans-Free+Balans/100*Global_TakeProfit)/ad.NominalPoint*(SchBuyLs-SchSellLs)*Point,Digits);
    Drawline_Per("%_LINE");
    ObjectSet( "%_LINE", OBJPROP_PRICE1, q);
  }
 
I don't know what you're counting there, but the number of points is an integer. Make it an int type and you won't need normalisation.
q =  (Balans-Free+Balans/100*Global_TakeProfit)/PP*(SchBuyLs-SchSellLs);  //число пунктов до наступления условия  Global_TakeProfit
 

Thanks for the advice.

Found the faults, everything works.

 

Please help with fractals

maxF = NormalizeDouble (iFractals(NULL, 0, MODE_UPPER,1),5);
minF = NormalizeDouble (iFractals(NULL, 0, MODE_LOWER,1),5);

Why do I not see
maxF > Bid or minF > Bid executing?

If <, it will be executed.

Without NormalizeDouble, the same thing. Is there something I don't understand about fractals?

 
lia:

Please help with fractals.

maxF = NormalizeDouble (iFractals(NULL, 0, MODE_UPPER,1),5);
minF = NormalizeDouble (iFractals(NULL, 0, MODE_LOWER,1),5);

Why can't I see the execution of
maxF > Bid or minF > Bid?

If <, it is executed.

Without NormalizeDouble it's the same. I don't understand something with fractals?


See this and next page - similarly display your conditions.
 

Could you suggest a function for an EA in MT4 that returns the profit of the last closed order, or if the last order closed at a profit or a loss?

PS I haven't found such a function in Kim.

 
Sancho77:

Can you suggest a function that returns the profit of the last closed order, or if the last order closed at profit or loss?

PS Kim has not found such a function.

Igor Kim has such functions. But his functions are a bit overdone for versatility. I can quickly whip up such a function for you here.
Question: What is the profit in? In points or in the deposit currency?
 
artmedia70:
Igor Kim has such features. However, his functions are a bit excessive for versatility. I can quickly whip up such a function for you here.
Question: What is the profit in? In points or in the deposit currency?
I would be grateful if you tell me! It does not matter whether the profit is in points or in currency, the important fact: a deal was closed in profit or in loss. As far as I'm concerned, it makes no difference whether it is in currency or pips.
 
Sancho77:
I would appreciate it if you could write it! It doesn't matter if the profit is in pips or in currency, the important fact is that the deal was closed in profit or in loss. In my opinion, it makes no difference in currency or pips.
//+----------------------------------------------------------------------------+
bool LossLastPose(string sy, int op, int mn) {
   datetime t;
   int      i, j;
   for (i=0; i<OrdersHistoryTotal(); i++) {
      if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) {
         if (OrderType()!=op)          continue;
         if (OrderSymbol()!=sy)        continue;
         if (OrderMagicNumber()!=mn)   continue;
         if (OrderCloseTime()>t) {
            t=OrderCloseTime();
            j=i;
            }
         }
      }
   if (OrderSelect(j,SELECT_BY_POS,MODE_HISTORY)) 
      if (OrderProfit()<0) return(true);
   return(false);
}
//+----------------------------------------------------------------------------+

We call it like this:

To check the last closed Buy position on the current symbol. The function will return true if at a loss and false if at a profit...

if (LossLastPose(Symbol(), OP_BUY, Magic)) {код, если последняя позиция закрылась с убытком}
else {Код, если последняя позиция закрылась с прибылью}

The Magic variable is an EA magic, it is written in global variables of the EA.

 
artmedia70:

We call it like this:

To check the last closed Buy position on the current symbol. The function will return true if at a loss and false if at a profit...

The Magic variable is the EA's magik, written in the EA's global variables.



Thank you very much!
Reason: