[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 92

 
Shniperson >> :
Gentlemen. how to make H4 trading take into account H1 bars ? for example if(......&& Close[0](H1 bar)>High[1](H1 bar) ???????????

Use iClose() and iHigh() - you can set an arbitrary timeframe in these functions

 
I don't understand why the assignment of one buffer to another is not correct (the result of Buffer1 is not printed in the indicator window). And the second question, why should the indicator calculate the zero bar and the previous one (limit=2), when it can be limited to the current zero bar only?

#property indicator_separate_window
#property indicator_buffers 1

extern int FastMA=3;
extern int SlowMA=25;

double Buffer1[];


double Buffer2[];

int init()
{
SetIndexBuffer(0,Buffer1);
SetIndexBuffer(1,Buffer2);
return(0);
}

int start()
{
int limit,counted_bars;
counted_bars=IndicatorCounted(); //counted_bars=Bars-1
if(counted_bars>0) counted_bars--; //??? counted_bars=Bars-1-1
limit=Bars-counted_bars; //лимит теперь равен двум
for(int i=0; i<limit; i++){
Buffer2[i]=MathAbs(Close[i]-Open[i]);
}
for(i=0; i<limit; i++){
Buffer1[i]=Buffer2[i]*(-1);
}
}

 
Dear programmers please help me to insert a sound into the indicator that would sound when the indicator crosses zero. Thank you!
Files:
 
C-4 >> :
I can't understand why the assignment of one buffer to another is not correct (the result of Buffer1 doesn't output in the indicator window)...

SetIndexStyle(0,DRAW_LINE); is missing for the drawing buffer, and IndicatorBuffers(2) for the calculation buffer;



 
Bingo! Well of course IndicatorBuffers(2), I thought specifying SetIndexBuffer was enough. By the way, even without SetIndexStyle(0,DRAW_LINE), I get a thin black line - the default settings are engaged.
 

Hello Experts.

I made an EA which only closes open orders!(semi-automatic trading).

Closing rules: The main close goes to the price channel, if it breaks 1 point up close SHELL,

If 1 point down closing BAY. In addition, the insurance breakeven a few points at a certain distance.

I have a question if i have done everything correctly, is the code correct!!!?

extern bool check=false; 
extern int PeriodP=12; 
extern double TrailingStop = 35;// расстояние после которого будем устанавливать безубыток
extern double X=5;//установка в + 5 пунктов! 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   double P_up0, P_down0, P_up1, P_down1;
   int cnt, total;

  P_up0=iCustom(Symbol(),Period(),"Ценовой канал", PeriodP,0,0);
  P_down0=iCustom(Symbol(),Period(),"Ценовой канал", PeriodP,1,0);
  P_up1=iCustom(Symbol(),Period(),"Ценовой канал", PeriodP,0,1);
  P_down1=iCustom(Symbol(),Period(),"Ценовой канал", PeriodP,1,1);

    
   for( cnt=OrdersTotal()-1; cnt>=0; cnt--) {
      OrderSelect( cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&    OrderSymbol()==Symbol())   {
         if(OrderType()==OP_BUY) 
            {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); 
                 return(0); 
                }
            if( TrailingStop>0)  
              {                  
               if(Bid-OrderOpenPrice()>Point* TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point* TrailingStop && OrderStopLoss()!=OrderOpenPrice()+ X*Point)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+ X*Point,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
           }
         else  
         {
            
            if( P_up1< P_up0) 
            {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); 
               return(0); 
              }
            if( TrailingStop>0)  
              {               
               if((OrderOpenPrice()-Ask)>(Point* TrailingStop))
                 {
                  if(NormalizeDouble(OrderStopLoss(),Digits) != NormalizeDouble(OrderOpenPrice()- X*Point,Digits))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()- X*Point,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
            
           }
        }
     
   if ( check) Order_Open();
   return(0);
  }
//+------------------------------------------------------------------+

void Order_Open(){
   if (OrdersTotal()<=1) {
      OrderSend(Symbol(),OP_BUY,0.1,Ask,3,0,0,"",20080421,0);
      OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0,0,"",20080421,0);
   }
}
 
There is no condition to close a long position, now the Buy order will close anyway.
If you have an overshoot of orders, be sure to put RefreshRates() before or after OrderSelect.
 
Roger >> :
No condition to close the long position, now the BUY order will close anyway.

Found the error. really missed the BUY close.

at least the compilation has been completed without errors.

extern bool check=false; 
extern int PeriodP=12; 
extern double TrailingStop = 35;// расстояние после которого будем устанавливать безубыток
extern double X=5;//установка в + 5 пунктов! 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   double P_up0, P_down0, P_up1, P_down1;
   int cnt, total;

  P_up0=iCustom(Symbol(),Period(),"Ценовой канал", PeriodP,0,0);
  P_down0=iCustom(Symbol(),Period(),"Ценовой канал", PeriodP,1,0);
  P_up1=iCustom(Symbol(),Period(),"Ценовой канал", PeriodP,0,1);
  P_down1=iCustom(Symbol(),Period(),"Ценовой канал", PeriodP,1,1);

    
   for( cnt=OrdersTotal()-1; cnt>=0; cnt--) {
      OrderSelect( cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&    OrderSymbol()==Symbol())   {
         if(OrderType()==OP_BUY) {  
            
            if( P_down1> P_down0) {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); 
                 return(0); 
                }
            if( TrailingStop>0)  
              {                  
               if(Bid-OrderOpenPrice()>Point* TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point* TrailingStop && OrderStopLoss()!=OrderOpenPrice()+ X*Point)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+ X*Point,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
           }
            else  
            {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); 
               return(0); 
              }
            if( TrailingStop>0)  
              {               
               if((OrderOpenPrice()-Ask)>(Point* TrailingStop))
                 {
                  if(NormalizeDouble(OrderStopLoss(),Digits) != NormalizeDouble(OrderOpenPrice()- X*Point,Digits))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()- X*Point,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
            
           }
        
     }
   if ( check) Order_Open();
   return(0);
  }
//+------------------------------------------------------------------+

void Order_Open(){
   if (OrdersTotal()<=1) {
      OrderSend(Symbol(),OP_BUY,0.1,Ask,3,0,0,"",20080421,0);
      OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0,0,"",20080421,0);
   }
}
 

a very "simple" question: how do you calculate the price of 1 (one) open index lot in the deposit currency?

Example: yesterday i opened 1 lot nikkei the price at the time of opening was 9400 pips. question: how do i know how much money was 9400 (NOT the deposit! namely the price of the lot) in the deposit currency at the time of opening?

 
jobber писал(а) >>

a very "simple" question: how do you calculate the price of 1 (one) open index lot in the deposit currency?

Example: yesterday i opened 1 lot nikkei the price at the time of opening was 9400 pips. my question is: how do i know how much money 9400 was (NOT the deposit! namely the price of the lot) in the deposit currency at the time of opening?

i>MarketInfo() will not help with this parameter.