stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

A little help probably very simple but cant work it out
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5187
Page 1 of 1
Author:  skillmatch [ Thu Jun 01, 2017 1:16 pm ]
Post subject:  A little help probably very simple but cant work it out

Hi hope you can help.

Trying to do an ea have an idea trying to test it , I have got stuck with why stoch value is not writing to screen, hope you can help using icustom function as you can see bb values show fine. Thank you

Code: Select all

 double band1_up = iCustom(_Symbol,_Period,"Triple Bollinger Bands", period, deviation1, deviation2, deviation3, appliedPrice, shift, 0, 1);
   double band1_lo = iCustom(_Symbol,_Period,"Triple Bollinger Bands", period, deviation1, deviation2, deviation3, appliedPrice, shift, 1, 1);
   
   double band_main = iCustom(_Symbol,_Period,"Triple Bollinger Bands", period, deviation1, deviation2, deviation3, appliedPrice, shift, 6, 1);
   
   double stoch= iCustom(NULL, 0, "#MTF Stochastic v2.0", 14, 1, 5, 1, 1) ;
   
   // prepare the comment
   string comment = 
    "Stoch value - "+(string)NormalizeDouble(stoch,1)+"\n"+
   "Band Upper 1 - "+(string)NormalizeDouble(band1_up,0)+"\n"+
   "Band Lower 1 - "+(string)NormalizeDouble(band1_lo,1)+"\n"+
   "Stoch value - "+(string)NormalizeDouble(stoch,1)+"\n"+
   
   "Band Main - "+(string)NormalizeDouble(band_main,4);
   
   // print the comment to the chart
   Comment(comment);
Author:  alecsa72 [ Thu Jun 01, 2017 6:45 pm ]
Post subject:  A little help probably very simple but cant work it out

Use Print() function first to print the output to Terminal journal to check if the value is actually being calculated properly from ICustom function

like this

Code: Select all

Print("My stoch Var=",stoch);
Author:  skillmatch [ Thu Jun 01, 2017 7:08 pm ]
Post subject:  A little help probably very simple but cant work it out

Hi nothing printing at all!
Author:  SteveHopwood [ Thu Jun 01, 2017 7:11 pm ]
Post subject:  A little help probably very simple but cant work it out

The first thing you do when coding an EA is junk any Crap Custom Abortions you may have on your chart.

You might have a mtfStochastic, or a mtfBands, or a mtfMovingAverage etc. All they do is interrogate the standard indis shipped with Empty4 and present the information in a pretty way. The attached 'The problem with custom indis' explains why they are a waste of time when it comes to coding an EA.

Instead, you create your own reusable code to read the indi you already have on your crapform. Here is the documentation for calling the Stochastic indi:
double iStochastic(
string symbol, // symbol
int timeframe, // timeframe
int Kperiod, // K line period
int Dperiod, // D line period
int slowing, // slowing
int method, // averaging method
int price_field, // price (Low/High or Close/Close)
int mode, // line index
int shift // shift
);

So, you create your own function to read Stochastic under a wide range of circumstances. Here is one:

Code: Select all

double GetStochastic(string symbol, int tf, int k, int d, int s, int method, int pf, int mode, int shift)
{
   return(iStochastic(symbol, tf, k, d, s, method, pf, mode, shift) );
}//End double GetStochastic(string symbol, int tf, int d, int s, int method, int mode, int shift)
Then, whenever you want your EA to read Stochastic, you send a call to your function with the relevant parameters. These can be hard coded or extern inputs.

The point is you are avoiding the bollocks of the Crap Custom Abortion that was probably coded by a cretin and have a function you can copy/paste time and time and time again.

Indicators coded by members of SHF are not Crap Custom Abortions and you can trust them. The SHF no-bollocks-allowed policy has weeded out the dimwits long before you got here.

:xm:
All times are UTC Page 1 of 1