A little help probably very simple but cant work it out

Post Reply
skillmatch
Posts: 2
Joined: Thu Jun 01, 2017 1:08 pm

A little help probably very simple but cant work it out

Post by skillmatch »

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);
alecsa72
Trader
Posts: 50
Joined: Wed Nov 09, 2016 7:50 pm
Location: South Africa

A little help probably very simple but cant work it out

Post by alecsa72 »

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);
skillmatch
Posts: 2
Joined: Thu Jun 01, 2017 1:08 pm

A little help probably very simple but cant work it out

Post by skillmatch »

Hi nothing printing at all!
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

A little help probably very simple but cant work it out

Post by SteveHopwood »

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:
You do not have the required permissions to view the files attached to this post.
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
Post Reply

Return to “Coders Hangout”