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

 

Hello,

Looking for an indicator/script that shows in the pair window the profit for that particular pair. I.e., when 3-5 pairs are traded, it is quite difficult to quickly calculate a profit on one of them if there is a build-up or lots.

If anyone has any suggestions, I would be very grateful.

 
Whatever your heart desires.
Equity and balance indicator
 
Thank you! :)
 
PapaYozh:


Probably tweak the signal_MACD() function.

Well, that it would still return something.


I want it to return true instead of false, but I don't know how to do it =( tell me how... I'll remember it once and won't ask again )
 

here's the script... how do I make it return true?

 bool signal_MACD() 
  { 
    bool signal_MACD = false; 
    double tmp = iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,0); 
    for(int i=1;i<=5;i++) 
    { 
       if(NormalizeDouble(iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,0)*tmp,4)<0.0) 
       { 
          signal_MACD = true; 
          break; 
       } 
    } 
  } 
 
CLAIN:

here's the script... how do I make it return true?


bool signal_MACD() 
  { 
    double tmp = iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,0); 
    for(int i=1;i<=5;i++) 
    { 
       if(NormalizeDouble(iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,0)*tmp,4)<0.0) 
       { 
          return(true); 
       } 
    } 
    return (false);
  } 
 
w_ersoc:

Hello,

Looking for an indicator/script that shows in the pair window the profit for that particular pair. I.e., when 3-5 pairs are traded, it is quite difficult to quickly calculate a profit on one of them if there is a build-up or lots.

If anyone has any suggestions, I would be very grateful.

 double CurrentProfit() {  // Функция считает текущий профит/лосс для одной валютной пары
    double Profit=0; 
    for(int i=OrdersTotal()-1; i>=0; i--){
      if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))continue;
      if(OrderSymbol()!=Symbol())continue;
      if(OrderMagicNumber()!=Magic) continue;
      if(OrderType()>1)continue;
      Profit+=OrderProfit();
    } 
 return(Profit);} 

  double Profit(){          // функция считает суммарный профит/лосс закрытых позиций для одной валютной пары
   double Profit=0; 
   for(int i=0; i<OrdersHistoryTotal(); i++){
     if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))continue;
     if(OrderSymbol()!=Symbol())continue;
     if(OrderMagicNumber()!=Magic)continue;
     if(OrderType()>1)continue;
     Profit+=OrderProfit()+OrderSwap()+OrderCommission();
   }      
 return(Profit);} 
 

Insert in the Start function:

    Comment("\n", 
      "\n",     
      "\n", "     Profit                               ", Profit(),
      "\n", "     CurProfit                          ", CurrentProfit(), 
      "\n");   
 
CLAIN:

here's the script... how do I make it return true?


bool signal_MACD() 
  { 
    bool signal_MACD = false; 
    double tmp = iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,0); 
    for(int i=1;i<=5;i++) 
    { 
       if(NormalizeDouble(iMACD(Symbol(),TF,fast_ema,slow_ema,signal_period,PRICE_CLOSE,MODE_MAIN,0)*tmp,4)<0.0) 
       { 
          signal_MACD = true; 
          break; 
       } 
    } 
    return(signal_MACD);
  } 
 
CLAIN:

I want it to return true instead of false, but I don't know how to do it =( tell me... I'll remember it once and won't ask again )


A variable inside a function is just that - a variable.

It doesn't matter what it is called.

So, if function should return a value, this value must be returned explicitly:

return( ... );