https://www.mql5.com/en/code
MQL5 Code Base
- www.mql5.com
This is the trading signal of PullBack and Candle. The expert code for this strategy is automatically generated by the MQL 5 wizard. This is a re-write of the nonLagMA found elsewhere and includes several uncommonly shown coding options, including a simple control dashboard.
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 I am trying to add 2SD 2 Standard deviation for the price ratio of two correlated pairs for example AUDUSD/NSDUSD , but getting zero result since it is not taking into array as the same way as it does in expert adviser. Please guide me where I am wrong.
These are the lines I am trying to get the standard deviation. Full working code mentioned below. I had found the code in one of the forums and modified it to add the average line successfully. I am now stuck with trying to add 2SD + and minus so that the trade could be taken at 2SD and at 3SD take the SL. Any help will be deeply appreciated.
#property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Yellow #property indicator_color2 Red #property indicator_color3 Blue extern string sym1 = "AUDUSD"; extern string sym2 = "NZDUSD"; extern int barcount = 5; //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; //Global Variables int ArrayIndex; double ArraySum; double a = 0; double b=0; double c=0; double d[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE,EMPTY,2,clrYellow); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_LINE,EMPTY,2,clrRed); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(2,DRAW_LINE,EMPTY,2,clrGreen); SetIndexBuffer(2,ExtMapBuffer3); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- for(int z=0;z<barcount;z++) { //Alert(z); a=iClose(sym1,0,z)+a; // Alert(d[0]); b=iClose(sym2,0,z)+b; d[z] = iClose(sym1,0,z)/iClose(sym2,0,z); c = iStdDevOnArray(d,0,z,0,0,z); //Alert(d[0]); } for(int i=0;i<barcount;i++) { ExtMapBuffer1[i] = iClose(sym1,0,i)/iClose(sym2,0,i); ExtMapBuffer2[i] = (a/b); // ExtMapBuffer3[i] = (a/b)+(10*c); } //---- return(0); }