You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
#property copyright "OK"
#property link "http://OK"
#property version "1.00"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_plots 4
//--- plot Longline
#property indicator_label1 "Longline"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrDeepPink
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- indicator buffers
double LonglineBuffer[];
int maHandle1,maHandle2,maHandle3; //
double ma1[],ma2[],ma3[]; //
double AAA[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
maHandle1=iMA(_Symbol,_Period,1,0,MODE_SMA,PRICE_HIGH);
maHandle2=iMA(_Symbol,_Period,1,0,MODE_SMA,PRICE_LOW);
maHandle3=iMA(_Symbol,_Period,1,0,MODE_SMA,PRICE_CLOSE);
PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_LINE);
PlotIndexSetInteger(0,PLOT_LINE_STYLE,STYLE_SOLID);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
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[])
{
ArraySetAsSeries(ma1,true);
ArraySetAsSeries(ma2,true);
if(CopyBuffer(maHandle1,0,0,200, ma1)<0) {Alert("iMA1: " ,GetLastError()); return(-1);}
if(CopyBuffer(maHandle2,0,0,200, ma2)<0) {Alert("iMA2: " ,GetLastError()); return(-1);}
ArraySetAsSeries(ma3,true);
if(CopyBuffer(maHandle3,0,0,200, ma3)<0) {Alert("iMA3: " ,GetLastError()); return(-1);}
double myhigh=ma1[0],mylow=ma2[0];
double aaatatal=0.00000;
for(int i=0;i<rates_total;i++)
{
for(int j=0;j<19;j++) //ima(AAA,19)
{
for(int k=0;k<34;k++) //HighPrice,LowPrice in 34
{
if(ma1[j+k+1]>myhigh) myhigh=ma1[j+k+1];
if(ma1[j+k+1]<mylow) mylow =ma1[j+k+1];
}
AAA[j]=-100*(myhigh-ma3[j])/(myhigh-mylow);
aaatatal=aaatatal+AAA[j];
myhigh=ma1[j];mylow=ma2[j];
}
LonglineBuffer[i]=aaatatal/19+100; //Drawline,but faild.
aaatatal=0.00000;
}
return(rates_total);
}
//I want to draw a line: LonglineBuffer[] ,but faild. ?? error: (EURUSD,M5) array out of range in 'OK.mq5' (127,13)!!!