[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 608

 
artmedia70:
How do you think you will decide whether it is a pullback or a reversal? Or will you open two positions on every pullback? It's a bust...

First I would like it to work, and then I would like to run the EA in the tester to find the size of lim parameter.
 
Hi all, I'm trying to make a program and I'm having

I can't figure out why it's not working.

I can explain it :-)

I would like to make a line that changes colour depending on the trend so to speak (primitive indicator)

It seems to change but there are gaps as if he misses a bar in the calculation

what is my mistake



//--------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue // Color of the first line
#property indicator_color2 Red // colour of the second line

double Buf_0[],Buf_1[]; //open indicator arrays
//--------------------------------------------------------------------
int init() // Special function init()
{
//--------------------------------------------------------------------
SetIndexBuffer(0,Buf_0); // Assignment of an array to the buffer
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);// Line style
//--------------------------------------------------------------------
SetIndexBuffer(1,Buf_1);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
//--------------------------------------------------------------------
return;
}
//--------------------------------------------------------------------
int start()
{
int i,counted_bars;
//--------------------------------------------------------------------
Counted_bars=IndicatorCounted(); // Number of calculated bars
i=Bars-Counted_bars-1; // Index of the first one not counted
while(i>=0) // Cycle through the uncounted bars
{
double a=(High[i]+Low[i])/2;
double b=(High[i+1]+Low[i+1])/2;
if (a=>b) Buf_0[i]=a; //change or not change colour
if (a<b) Buf_1[i]=a;
i--;
}
//--------------------------------------------------------------------
return;
}
//--------------------------------------------------------------------
 
Hello!!! Can you please advise how to implement this in code? I should have 3 (Amounts are set separately) unprofitable sl orders to open two buy and sell orders. The distance between them should be set in a separate variable.
 
Hello, I want to calculate the 'historical intraday ATR' (i.e. say average for each hour over the last 30 days ) and would like to believe that something like this should already exist - maybe the indicator is called something else or can the existing ones be adjusted somehow? if anyone knows, please advise!
 
zelek:

I'd like to get it working first, and then run the 'EA' in the tester to size the lim parameter.
And you can attach it to ATR. There will be dynamics and no need to adjust - everything will depend on market volatility
 
Top2n:
Hello!!! Can you please advise how to implement this in code? I should have 3 (Total number is set separately) losing orders sl should open two buy and sell orders. The distance between them should be set in a separate variable.


We set a variable equal to zero and increase it by 1 when the position is losing. Once it reaches the required value, we open the required positions.
That is the logic...
 

Can you tell me which robots work for 15 days and which do not differ in profit from Cheetah 2.5?

Please give me a link or website etc.

Thanks in advance for your time

 
artmedia70:
And you hook it up to ATR. It will be dynamic and there is no need to adjust - it will depend on market volatility


Please take a look at the code, I don't understand why orders are not closed

extern int     lim=20;             // Дистанция возврата курса

/
int init()
  {
 

   return(0);
  }
/
int deinit()
  {
//----
   
//----
   return(0);
  }

int start()
  {
 
  double 
   max, min;                                            
  int b, s;
   if (Bid>max) max=Bid; 
    if (Ask<min) min=Ask;  
       if (OrdersTotal()>0)
       {                                   
           if ((max-Bid)>=lim*Point) 
           {                   
          OrderSelect(b,SELECT_BY_TICKET);                                  
          b=OrderClose(OrderTicket(),0.1,Bid,3,Blue);
          }
          
          
          if ((Ask-min)>=lim*Point)  
          {         
      OrderSelect(s,SELECT_BY_TICKET); 
      s=OrderClose(OrderTicket(),0.1,Ask,3,Red);
         }
}
else
{
  if (OrdersTotal()<1)
  {
 b=OrderSend(Symbol(),OP_BUY,0.1,Ask,5,0,0,"",5,0);
      
 s=OrderSend(Symbol(),OP_SELL,0.1,Bid,5,0,0,"",5,0); 
    }                           
   }
         return;

   return(0);
  }
 
zelek:


Please take a look at the code, I can't understand why orders are not closing

interesting structure:
if (Bid>max) max=Bid;
if (Ask<min) min=Ask;

Are you sure that if the price goes up, then if ((max-Bid)>=lim*Point) will be executed?

I would do the following - in the init() section, for example, I would memorize the price when the EA starts (it may not be in the init) - and then I would dance from this price.

If you have an Expert Advisor, you would memorize the price, but as it seems you will divide your min and max by ticks and then control your orders in this corridor


 
Logically it should work, but why not, can you explain?