post your code and the people may help.
yeah sure.. Sergey. This is the DV2 Oscillator after being transformed with a Percent Rank function.
Any help would be appreciated
//+------------------------------------------------------------------+ //| MyDV2.mq4| //| Raimondo Marino| //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Raimondo Marino" #property link "https://www.mql5.com" #property version "1.0" #property strict #property indicator_separate_window //#property indicator_chart_window #property indicator_buffers 4 #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_levelwidth 1 #property indicator_levelstyle 1 #property indicator_levelcolor clrBlack #property indicator_color1 clrBlack #property indicator_width1 2 #property indicator_color2 clrGreen #property indicator_width2 2 #property indicator_color3 clrRed #property indicator_width3 2 // Input Settings sinput string DV2_Settings; extern int SMAperiod=3; //SMA lookback period extern int PRperiod=250; //Percent Rank lookback period input int Overbought=90; //Selling Level Order input int Oversold=20; //Buying Level Order double dv2[]; double uparrow[]; double downarrow[]; double work1[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,dv2); SetIndexStyle(0,DRAW_LINE); SetIndexLabel(0,"DV2"); ArraySetAsSeries(dv2,true); //--- SetIndexBuffer(1,uparrow); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,233); SetIndexLabel(1,"Buy Signal"); //--- SetIndexBuffer(2,downarrow); SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,234); SetIndexLabel(2,"Sell Signal"); //--- SetIndexBuffer(3,work1); SetIndexStyle(3,DRAW_NONE); ArraySetAsSeries(work1,true); SetIndexLabel(3,"work1"); //--- SetLevelValue(1,Overbought); SetLevelValue(2,Oversold); IndicatorShortName("DV2 (SMA lookback: "+(string)SMAperiod+","" PR lookback:"+(string)PRperiod+")"); SetIndexLabel(0,"DV2"); IndicatorDigits(0); 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[]) { int counted_bars,limit; counted_bars=IndicatorCounted(); if(!counted_bars)limit=Bars-SMAperiod+1; else limit=Bars-counted_bars; for(int i=0; i<limit; i++) { double result=0.0; for(int j=0; j<SMAperiod; j++) { result+=(Close[i+j]/(0.5*(High[i+j]+Low[i+j])))-1; } result/=SMAperiod; work1[i]=result; } int limit2=0; if(!counted_bars) limit2=Bars-PRperiod+1; else limit2=limit; //if(limit2>11) limit2=11-PRperiod+1; for(int i=0; i<limit2; i++) { int less=0,greater=0; for(int j=0; j<PRperiod; j++) { if(work1[i]<work1[i+j]) greater+=1; else if(work1[i]>work1[i+j]) less+=1; } dv2[i]=NormalizeDouble((less*100)/(greater+less),0); } int limit3; if(!counted_bars)limit3=Bars-1; else limit3=Bars-counted_bars; for(int i=0; i<limit3; i++) { if(dv2[i+1]<Overbought && dv2[i]>=Overbought) { downarrow[i]=dv2[i]; uparrow[i]=EMPTY_VALUE; } else if(dv2[i+1]>Oversold && dv2[i]<=Oversold) { uparrow[i]=dv2[i]; downarrow[i]=EMPTY_VALUE; } else { uparrow[i]=EMPTY_VALUE; downarrow[i]=EMPTY_VALUE; } } return(rates_total); } //+---
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
Hi,
is there a particular reason why the same code of an indicator shows arrows on a broker (Darwinex) and not on another (IG)?
The signal correctly works on both brokers showing the same values but when it comes to drawing arrows on one broker it doesn't show them (the signal to trade) while on another it does.
Where am I wrong?
thanks in advance
Raimondo