Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 71

 

I need the indicator to draw arrows on the daily chart. I assume that the problem is in the use of 15 minute EMAs, everything works on the 15 minute EMAs. Is it possible to make an indicator that is calculated from the 15-minute timeframe and draw arrows on the daily chart?

Below is the code itself:

#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 Red

//--- input parameters

//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,217);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,217);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   IndicatorDigits(Digits+1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    int counted_bars=IndicatorCounted(),                      
    limit;
    double
    signal_1,
    signal_2,
    MA_1_t,                                                 
    MA_2_t;
 
   if(counted_bars>0)
      counted_bars--;
   
   limit=Bars-counted_bars;
   
   
   for(int i=0;i<limit;i++)
   {
      MA_1_t=iMA(NULL,PERIOD_M15,3,0,MODE_EMA,PRICE_CLOSE,i+0);  
      MA_2_t=iMA(NULL,PERIOD_M15,3,0,MODE_EMA,PRICE_CLOSE,i+1);  
      signal_1 = (условие);
      signal_2 = (условие);
      if (signal_1 >= определенное число)
      ExtMapBuffer1[i]=High[i]+5*Point;
      else
         ExtMapBuffer1[i]=0.0;
      if(signal_2 >= определенное число)
         ExtMapBuffer2[i]=Low[i]-5*Point;         
      else
         ExtMapBuffer2[i]=0.0; 
   }
   return(0);
  }
//+------------------------------------------------------------------+
 
satorifx:


dist = MathAbs((NormalizeDouble(Bid,Digits)-
NormalizeDouble(ObjectGetValueByShift(TrendLineName,0),Digits))*MathPow(10,Digits));

The code finds the distance from the current price level to the trend by TrendLineName. But there is a problem: apparently the trend is inaccurately transmitted between halves, and therefore the distance to price is quite different for different halves. How to get around this problem? Ideally, even if the trendline is displayed only on H1, at open time frame W1 (in fact at any open time frame) the calculated distance should be the same.


Related to the question in the quote above, another question: how do I simulate a different time frame than the open one on the chart? I.e., for example, with D1 open, should I calculate on M30?
 
I searched the Internet, found something, but I tried it and it just wouldn't work! Help me to add a trailing stop)) should work like this - if price goes up / down (in profit) at "X" points, triggers a trailing stop at "Y" points of that price and moves in profitable direction with increment "Z". Many thanks to whoever helps))))))

//+------------------------------------------------------------------+
//| sobstvennyi_probnyi_sovetnic.mq4 |
//| Antonico |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Antonico"
#property link "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert initialisation function |
//+------------------------------------------------------------------+
double lot=1;
extern double sl=30;
extern double tp=30;
extern double koeff=2;
int pon=1;
int vtor=0;
int sred=3;
int hetver=0;
int patn=0;


int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialisation function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()

{ int otkrord=OrdersTotal();
if (DayOfWeek()==pon || DayOfWeek()==vtor || DayOfWeek()==sred || DayOfWeek()==hetver || DayOfWeek()==patn || DayOfWeek()==6 || DayOfWeek()==0 || otkrord >0) return(0);



if(OrdersHistoryTotal()==0)
{lot=1;}

if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))

{
if (OrderProfit()>0)
{
lot=1;
}
if (OrderProfit()<=0)
{
lot=OrderLots()*koeff; // Multiply by 2
}

}


int h=TimeHour(TimeCurrent());
int m=TimeMinute(TimeCurrent());
int s=TimeSeconds(TimeCurrent());
double zena0=Open[3];
double zena01=Open[2];


if (h==1 && m==00 && s==01 && zena0<zena01 )

{OrderSend(Symbol(), OP_BUY,lot,Ask,3,Bid-sl*Point,Ask+tp*Point,"",0,0,Green);}





if (h==1 && m==00 && s==01 && zena0>zena01)
{OrderSend(Symbol(), OP_SELL,lot,Bid,3,Ask+sl*Point,Bid-tp*Point,"",0,0,Red);}
}


{if(OrdersHistoryTotal()==0)
{lot=1;}

if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))

{
if (OrderProfit()>0)
{
lot=1;
}
if (OrderProfit()<=0)
{
lot=OrderLots()*koeff; // Multiply by 2 after a losing trade
}

}




double zena1=Open[5];
double zena11=Open[4];

if (h==3 && m==00 && s==01 && zena1>zena11)
{



OrderSend(Symbol(), OP_BUY,lot,Ask,3,Bid-sl*Point,Ask+tp*Point,"",0,0,Green);}
if (h==14 && m==00 && s==01 && zena1<zena11)
{OrderSend(Symbol(), OP_SELL,lot,Bid,3,Ask+sl*Point,Bid-tp*Point,"",0,0,Red);}

}
}

return(0);
}

//+------------------------------------------------------------------+
 

Can you please tell me how to translate a character (string) into ASCII code?

Roughly speaking, you need the inverse of CharToStr().

 
Heroix:

Can you please tell me how to translate a character (string) into ASCII code?

Roughly speaking, you need the inverse of CharToStr().


 

Good afternoon.

help me need code

current chart

When a new bar opens, an order must be opened

Exactly the new bar

 
sannin:

Good afternoon.

help me need code

current chart

When a new bar opens, an order must be opened

Exactly the new bar

No problem!

Start writing the code you need. In case of difficulties, ask questions and show pieces of the code you have written, and experienced comrades will show you where you went wrong.

 

Hi all.

I have a question. In the tester, the week starts at 00:00 if we look at the hour chart, for example. It is known that the forex week starts at 20:15 GMT. That is, in order to get from one hour in the tester hour GMT, roughly speaking, prebovlyayut 20 hours and divide modulo by 24, right?

 
why exactly at 8.15pm, for you it will open as your broker opens
 
Good day all. Please advise where to get info. on how to close the EA from prying eyes and what you need so that the EA works for a certain period of time and then ceases to be useful to the moment, well, for example, to introduce a code for continuation of work, like that. Thanks in advance!!!
Reason: