Skocz do zawartości

Automaty w MQL5


Rekomendowane odpowiedzi

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 2
#property indicator_label1 "ArrowUp"
#property indicator_type1 DRAW_ARROW
#property indicator_color1 clrGreen
#property indicator_style1 STYLE_SOLID
#property indicator_width1 5
#property indicator_label2 "ArrowDown"
#property indicator_type2 DRAW_ARROW
#property indicator_color2 clrRed
#property indicator_style2 STYLE_SOLID
#property indicator_width2 5
input string _____1_____ = "Indicator settings";
input ENUM_TIMEFRAMES Inp_Timeframe = PERIOD_CURRENT; // Timeframe for indicator
input int Inp_Period = 7; // Rsi period
input ENUM_MA_METHOD Inp_MA_Method = MODE_EMA;
input ENUM_APPLIED_PRICE Inp_Applied_price = PRICE_CLOSE;
int min_rates_total=90;
double Up[],Down[];
int rsi,ma_fast,ma_slow;
double MaFast[],MaSlow[],Rsi[];
int OnInit(){
SetIndexBuffer(0,Up,INDICATOR_DATA);
SetIndexBuffer(1,Down,INDICATOR_DATA);
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total);
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetInteger(0,PLOT_ARROW,233);
PlotIndexSetInteger(1,PLOT_ARROW,234);
return(INIT_SUCCEEDED);
}
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[]){
rsi=iRSI(_Symbol,Inp_Timeframe,Inp_Period,Inp_Applied_price);
ma_fast=iMA(_Symbol,Inp_Timeframe,49,0,Inp_MA_Method,Inp_Applied_price);
ma_slow=iMA(_Symbol,Inp_Timeframe,89,0,Inp_MA_Method,Inp_Applied_price);
if(rates_total < min_rates_total) return(0);
if(BarsCalculated(ma_fast) < rates_total ||
BarsCalculated(ma_slow) < rates_total){
Print("Not all data is calculated. Error ", GetLastError());
return 0;}
if(IsStopped()) return(0);
if(CopyBuffer(ma_fast, 0, 0, rates_total, MaFast) <= 0 ||
CopyBuffer(ma_slow, 0, 0, rates_total, MaSlow) <= 0 ||
CopyBuffer(rsi, 0, 0, rates_total, Rsi) <= 0){
Print("CopyBuffer failed! Error ", GetLastError());
return(0);}
int limit=prev_calculated-1;
if(prev_calculated==0) limit=0;
for(int i=limit;i<rates_total;i++){
if(i>0&&Rsi>30&&Rsi[i-1]<=30&&MaFast>MaSlow){
Up=high+50*_Point;
Down=EMPTY_VALUE;}
else if(i>0&&Rsi<70&&Rsi[i-1]>=70&&MaFast<MaSlow){
Down=high[i]+50*_Point;
Up[i]=EMPTY_VALUE;}
else{
Up[i]=EMPTY_VALUE;
Down[i]=EMPTY_VALUE;}}
return(rates_total);
}

 

Odnośnik do komentarza
Udostępnij na innych stronach

Dołącz do dyskusji

Możesz dodać zawartość już teraz a zarejestrować się później. Jeśli posiadasz już konto, zaloguj się aby dodać zawartość za jego pomocą.
Uwaga: Twój wpis zanim będzie widoczny, będzie wymagał zatwierdzenia moderatora.

Gość
Dodaj odpowiedź do tematu...

×   Wklejono zawartość z formatowaniem.   Przywróć formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Odnośnik został automatycznie osadzony.   Przywróć wyświetlanie jako odnośnik

×   Przywrócono poprzednią zawartość.   Wyczyść edytor

×   Nie możesz bezpośrednio wkleić grafiki. Dodaj lub załącz grafiki z adresu URL.

Ładowanie
 Udostępnij

×
×
  • Dodaj nową pozycję...