It fails because the values from stoch are double and not int.
still cant,
is there another way to get the stos.prev/sto.prev values aka from previous bars.
the icustom shift just makes things crazy.
i modified it a little.. help?
//-------------------------------------------------------------------- // tradingexpert.mq4 // The code should be used for educational purpose only. //-------------------------------------------------------------------- #define MainBuffer 1 #define SignalBuffer 2 #define HighesBuffer 3 #define LowesBuffer 4 #define Price MODE_CLOSE // Choose one #property copyright "Copyright © Book, 2007" #property link "http://AutoGraf.dp.ua" //--------------------------------------------------------------- 1 -- // Numeric values for M15 extern int Period_1= 200; // Period of MA 1 extern int KPeriod=200; extern int DPeriod=100; extern int Slowing=100; double stos[2]; double stos2[2]; bool Work=true; // EA will work. //--------------------------------------------------------------- 2 -- int start() { int counted_bars=IndicatorCounted(); double sto; double stos; bool Ans =false; // Server response after closing //--------------------------------------------------------------- 3 -- // Preliminary processing if(Bars < 50 ) // Not enough bars { Alert("Not enough bars in the window. EA doesn't work."); return; // Exit start() } if(Work==false) // Critical error { Alert("Critical error. EA doesn't work."); return; // Exit start() } //--------------------------------------------------------------- 4 -- // Trading criteria sto[0]=iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,0); sto[1]=iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,1); stos[0]=iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,0); stos[1]=iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,1); if ( (stos[1] > sto[1]) && (stos[0] <= sto[0] ) ) { //0.2 Alert("test1a"); } if ( (stos[1] < sto[1]) && (stos[0] >= sto[0] ) ) { //0.2 Alert("test2a"); } //--------------------------------------------------------------- 9 -- return; // Exit start() }
Latest that compiles
/*Alerts when stochastic crosses the lower or upper threshold.*/ extern int KPeriod=200; extern int DPeriod=100; extern int Slowing=100; double sto[2]; double stos[2]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { sto[0] = iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,0); sto[1] = iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,1); stos[0] = iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,0); stos[1] = iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,1); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); sto[0] = iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,0); sto[1] = iCustom(NULL,0,"Stochastic",KPeriod,DPeriod,Slowing,2,1); stos[0] = iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,0); stos[1] = iCustom(NULL, 0, "Stochastic",KPeriod,DPeriod,Slowing,1,1); if ( (stos[1] > sto[1]) && (stos[0] <= sto[0] ) ) { //0.2 Alert("test1a"); } if ( (stos[1] < sto[1]) && (stos[0] >= sto[0] ) ) { //0.2 Alert("test2a"); } return(0); } //+------------------------------------------------------------------+
??

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