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

 
palesandr:

The point is to average open-close over n candles

it just draws a downward pointing line

what is wrong ?

1) correct the inner loop

k not from 1 but from i

2) in the very first steps, go beyond the story

 
granit77:
I would also like to see an example, how to do it correctly.

What could be more complicated than that?

#property copyright "Bicus"
#property link      "Bicus"


double aPrices [5];

void PutStack (double p_Price)
{
  int nCounter;
  
  for (nCounter = 4; nCounter > 0; nCounter--)
    aPrices [nCounter] = aPrices [nCounter - 1];
    
  aPrices [0] = p_Price;
}

int start()
{
  int nCounter;
  
  PutStack (Bid);
  
  for (nCounter = 0; nCounter < 5; nCounter++)
    Print (nCounter, "-й тик: ", DoubleToStr (aPrices [nCounter], Digits));
}

The 0-th element of the array will have the price of the last tick, the 1st element will have the price 1 tick ago, the 2nd element will have the price 2 ticks ago etc.

Or maybe I misunderstood something and meant something else?

 
palesandr:

The point is to average open-close over n candles

it just draws a downward pointing line

what is wrong ?


#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red 

extern double n = 50;
double Buf_0[];

int init()
  {
 SetIndexBuffer(0,Buf_0);
 SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);    
    
   return(0);
  }

int start()
  {
   int    Counted_bars=IndicatorCounted();
      
   double v;
  int i=Bars-Counted_bars-1;
 
  while(i>=0)  
  {  v=0; 
          for(int k=i;k<i+n;k++)
        {
      
        v=v+MathAbs(Open[k]-Close[k]);
       
        
      }
       Buf_0[i] = v/n;
       
       i--;
       }
 return;
 }
 
Bicus:

What could be more complicated than that?

The 0-th element of the array will have the price of the last tick, the 1st element will have the price 1 tick ago, the 2nd element will have the price 2 ticks ago etc.

Or did I misunderstand something and meant something else?

Thank you, that's exactly what I need. It doesn't seem complicated, but people who don't know the basics of programming sometimes take a long time to do simple things. They have to come up with everything from scratch.
For example, for you "bubble sorting" is an element of the alphabet, while I've only heard of it, and not having an example in front of me, would write it all over again :))
 
Does anyone have a ready-made "Skip Next Bar" function? :)
 
Hello all and profit. I wanted to ask if anyone has an indicator like RSI, but which would never diverge. Thank you.
 
ikatsko:
Anyone have a ready-made skip next bar function? :)

if(iTime(Symbol(),period_bar,number_of_ bars_to_skip)>OrderOpenTime()

Skip_bar_to_skip

0 - skip current one, 1 - current one and next one etc.

 

yosuf:
I recently read on this forum that if we open 2 differently directed orders with the same SL at the same time, then after one of them closes, we can try to end up with a profit. Has anybody checked this idea or not? Maybe there is a similar EA?
160777:

Expert Grid v.2.

"Copyright©2008 EAfactory.com and Expert-4x.com - "Revision: 264".

Opens positions both ways and closes both if the difference is on the plus side.

Enlighten me, how is it possible to be on the plus side if the orders are equal in terms of lot size? The total position will always be minus the double spread.

Another thing is if the orders have different lots: then the stop loss of the smaller one is not the same, but the stop loss of the bigger one is equal to the take profit. Then their simultaneous closing leads, if you know how to calculate, to a profit.

 

Hi all, how do I save a Statement.htm report using MQL? Does anyone know?

 

I can't figure out how to make the lines display, either by this script or by pushing away from this script, or maybe I'm wrong:

   //---------------------------------
  
        double PriceBid = Bid;
        double PriceAsk = Ask;
        double be = GetWeightedBELevel();

        if(be != -1)
        {
                double BuyLots = GetBuyLotsSum();
                double SellLots = GetSellLotsSum();
                
                double Swap = GetSwap();
                //string str = be + " ";
                if(Swap < 0)
                {
                        double diff = BuyLots - SellLots;
                        //str = str + MarketInfo(Symbol(), MODE_TICKVALUE) * diff + " " + (-Swap / (MarketInfo(Symbol(), MODE_TICKVALUE) * diff) * Point) + " ";
                        be += ND(-Swap / (MarketInfo(Symbol(), MODE_TICKVALUE) * diff) * Point + diff / MathAbs(diff) * 1 * Point);
                }
                //str = str + Swap + " " + be;
                //Comment(str);
                        
                if((BuyLots > SellLots && ND(PrevPriceBid) < ND(be + TakeProfitBuy * Point) && ND(PriceBid) >= ND(be + TakeProfitBuy * Point)) ||
                        (BuyLots < SellLots && ND(PrevPriceAsk) > ND(be - TakeProfitSell * Point) && ND(PriceAsk) <= ND(be - TakeProfitSell * Point)))
                {
                        CloseAllBuy();
                        CloseAllSell();
                }               
                
        }
        //---------------------

that is, when this price reaches this level, the orders are closed, and I want to see this price on the chart as a line or a small record in a square and with a dash.

guide me in the right direction
Reason: