Need some help with indicator and ea coding

User avatar
s01
Trader
Posts: 26
Joined: Mon Jul 30, 2012 3:22 pm
Location: Midwest, USA

Need some help with indicator and ea coding

Post by s01 »

Well I knew it would come to this, so might as well get this started.

First off let me say ANY help is greatly appreciated. I am not a coder, I modify just about every indicator and ea that I have. Keeps me busy so I am not watching every damn tick of the charts. I am more of a cut and paste coder, I do occasionally get a working indy or ea that works how I want. But My pile of trashed code is growing. :( I do look at the codesguru lessons for hints, but these is no help guide in it to specifcally solve errors, and google search will come up with 50 posible fixes but none of them seem to work ..... grrrrrrr

Right now I am working on a ea that will implement my thoughts into real live trading results, yep the holy grail. Probably grow old and die before I get it right, but I'll die tryin. :)

Anyway first up is a simple (yea right) piece of code from a ea that you have to set the digits of the broker manually. I thought with all the samples out there how hard could it be? Well after screwing around with 50 variations ( ok slight exageration), but 5 hrs worth, it still wont work or even come out error free.

I submit for you humor, my attempt along with the original code for some help before I take the keyboard and kill the dog. :( Then the wife would come home and kill me. So to prevent mutiple homicides ...... help.........

Original code

Code: Select all

extern int    AccDigits = 5;


int fpc()
{
  if (AccDigits == 5) return (10);
  if (AccDigits == 6) return (100);
  return (1); 
}

double PointEx()
{
  if (AccDigits == 5) return (10*Point);
  if (AccDigits == 6) return (100*Point);
  return (Point); 
}
My febble attempt

Code: Select all

// need to auto adjust for digits               // ---------------------- s01
//extern int     AccDigits = 5;                 // see above ^^^^^^^^^^^

//+-----------------------------------------------------------------------+
//| Auto Adjust for different digit criminals - put in after int section  |
//+-----------------------------------------------------------------------+

//Adapt to x digit criminals

//------------- orig code was at bottom ----------------------------------

  void init()  // copied this from below to get rid of MarketInfo - initialization expected error
{

int AccDigits = MarketInfo, chart, digits;             // added chart, digits; to get rid of error
int DIGITS = MarketInfo (chart, MODE_DIGITS);          // changed symbol to chart to get rid of error
                                                       // will have to test to see if it works
int fpc()                                              // used later down
{
  if (AccDigits == 4) return (1);                       // added a01
  if (AccDigits == 5) return (10);
  if (AccDigits == 6) return (100);                     // for future criminal adjustments
  if (AccDigits == 7) return (1000);                    // added s01 ^^^^^^^^^^^^^^^^^^^^^
  return (1); 
}

double PointEx()
{
  if (AccDigits == 4) return (1*Point);                 // added s01
  if (AccDigits == 5) return (10*Point);
  if (AccDigits == 6) return (100*Point);               // for future criminal adjustments
  if (AccDigits == 7) return (1000*Point);              // added s01 ^^^^^^^^^^^^^^^^^^^^^
  return (Point); 
}
   }
Right now I get a function unexpected error for the double PointEx(), but I'm not sure thats a problem as I have 2/3rds of the lower code disabled right now while I attempt to get these errors out.

But I get a 'AcctDigits' - variable not defined error on only the lower section of the code, below the double PointEx(). and a unbalanced parentheses errror at the end, But that does not show up in the Empty4 editor or the SciTE editor as a problem?

Again help save a few lives, help a suffering soul out ... :(

Thanks again in advance ..... so1 / Steve
Last edited by s01 on Tue Aug 14, 2012 11:22 pm, edited 2 times in total.
There are no bad traders, just bad systems, or rules.
A Quote that I stold from someone else:
Better to wish you were in a trade than wish you were out of a trade
rwb181
Posts: 9
Joined: Tue Jul 24, 2012 7:23 pm

Re: Need some help with indicator and ea coding

Post by rwb181 »

Hi,
I haven't really looked this over closely but, one thing that pops out right off the bat is this;

int DIGITS = MarketInfo (chart, MODE_DIGITS);

DIGITS should be a double type variable not an integer. As an integer, I think it will return zero.

Another is this;

int AccDigits = MarketInfo, chart, digits;

Again, needs to be a double, not an integer. And, no parenthesis.

Ron
Last edited by rwb181 on Tue Aug 14, 2012 4:06 pm, edited 1 time in total.
User avatar
s01
Trader
Posts: 26
Joined: Mon Jul 30, 2012 3:22 pm
Location: Midwest, USA

Re: Need some help with indicator and ea coding

Post by s01 »

Hi,

I tried using int DIGITS = MarketInfo (Symbol, MODE DIGITS):
but it returned a error.

I tried many variables from 5-7 different auto adjust code snippets, but none came back without errors.

Steve
There are no bad traders, just bad systems, or rules.
A Quote that I stold from someone else:
Better to wish you were in a trade than wish you were out of a trade
rwb181
Posts: 9
Joined: Tue Jul 24, 2012 7:23 pm

Re: Need some help with indicator and ea coding

Post by rwb181 »

My mistake, it is supposed to be an integer. I don't have any brain cells that are firing at the moment.

"But I get a 'AcctDigits' - variable not defined error on only the lower section of the code, below the double PointEx(). and a unbalanced parentheses errror at the end"

That could be because of the missing parenthesis I mentioned.
Try

int AccDigits = MarketInfo(chart, MODE_DIGITS);
rwb181
Posts: 9
Joined: Tue Jul 24, 2012 7:23 pm

Re: Need some help with indicator and ea coding

Post by rwb181 »

Code: Select all

    // need to auto adjust for digits               // ---------------------- s01
    // extern int     AccDigits = 5;                 // see above ^^^^^^^^^^^

    //+-----------------------------------------------------------------------+
    //| Auto Adjust for different digit criminals - put in after int section  |
    //+-----------------------------------------------------------------------+

    //Adapt to x digit criminals

    //------------- orig code was at bottom ----------------------------------

      void init()  // copied this from below to get rid of MarketInfo - initialization expected error
{
    int AccDigits = MarketInfo(chart,MODE_DIGITS);             // added chart, digits; to get rid of error
    int DIGITS = MarketInfo (chart, MODE_DIGITS);          // changed symbol to chart to get rid of error
                                                           // will have to test to see if it works
    int fpc()                                              // used later down
    {
      if (AccDigits == 4) return (1);                       // added a01
      if (AccDigits == 5) return (10);
      if (AccDigits == 6) return (100);                     // for future criminal adjustments
      if (AccDigits == 7) return (1000);                    // added s01 ^^^^^^^^^^^^^^^^^^^^^
      return (1);
    }

    double PointEx()
    {
      if (AccDigits == 4) return (1*Point);                 // added s01
      if (AccDigits == 5) return (10*Point);
      if (AccDigits == 6) return (100*Point);               // for future criminal adjustments
      if (AccDigits == 7) return (1000*Point);              // added s01 ^^^^^^^^^^^^^^^^^^^^^
      return (Point);
    }
}
Try that. I don't know if it will give you what you want but, it should eliminate the errors and unbalanced parenthesis.
User avatar
s01
Trader
Posts: 26
Joined: Mon Jul 30, 2012 3:22 pm
Location: Midwest, USA

Re: Need some help with indicator and ea coding

Post by s01 »

ok, well changed it to this.

Code: Select all

//+-----------------------------------------------------------------------+
//| Auto Adjust for different digit criminals - put in after int section  |
//+-----------------------------------------------------------------------+

//Adapt to x digit criminals

//------------- orig code was at bottom ----------------------------------

  void init()  // copied this from below to get rid of MarketInfo - initialization expected error
{

//double AccDigits = MarketInfo, (symbol, digits);             // added chart, digits; to get rid of error
double AccDigits = MarketInfo (SYMBOL, MODE_DIGITS);          // changed symbol to chart to get rid of error // no workie grrrrrrrrrrrrrrrrrrr
                                                       // will have to test to see if it works
int fpc()                                              // used later down
{
  if (AccDigits == 4) return (1);                       // added a01
  if (AccDigits == 5) return (10);
  if (AccDigits == 6) return (100);                     // for future criminal adjustments
  if (AccDigits == 7) return (1000);                    // added s01 ^^^^^^^^^^^^^^^^^^^^^
  return (1); 
}

double PointEx()
{
  if (AccDigits == 4) return (1*Point);                 // added s01
  if (AccDigits == 5) return (10*Point);
  if (AccDigits == 6) return (100*Point);               // for future criminal adjustments
  if (AccDigits == 7) return (1000*Point);              // added s01 ^^^^^^^^^^^^^^^^^^^^^
  return (Point); 
}
   }
And now get this back.

251:32;'SYMBOL' - variable not defined
253:8;'(' - function definition unexpected
264:7;'AccDigits' - variable not defined
265:7;'AccDigits' - variable not defined
266:7;'AccDigits' - variable not defined
267:7;'AccDigits' - variable not defined
270:4;'}' - unbalanced parentheses
>Exit code: 7

Steve / s01
There are no bad traders, just bad systems, or rules.
A Quote that I stold from someone else:
Better to wish you were in a trade than wish you were out of a trade
rwb181
Posts: 9
Joined: Tue Jul 24, 2012 7:23 pm

Re: Need some help with indicator and ea coding

Post by rwb181 »

264:7;'AccDigits' - variable not defined

That is beacause you commented out AccDigits here;

//double AccDigits = MarketInfo, (symbol, digits);

251:32;'SYMBOL' - variable not defined

Is because variables are case sensitive;

symbol and SYMBOL needs to be "Symbol()"
User avatar
s01
Trader
Posts: 26
Joined: Mon Jul 30, 2012 3:22 pm
Location: Midwest, USA

Re: Need some help with indicator and ea coding

Post by s01 »

Tried mine, then saw your post,
Tried yours, and I get this back:

288:32;'chart' - variable not defined
289:30;'chart' - variable not defined
291:12;'(' - function definition unexpected
302:11;'AccDigits' - variable not defined
303:11;'AccDigits' - variable not defined
304:11;'AccDigits' - variable not defined
305:11;'AccDigits' - variable not defined
308:1;'}' - unbalanced parentheses
>Exit code: 8

No joy just yet ...
There are no bad traders, just bad systems, or rules.
A Quote that I stold from someone else:
Better to wish you were in a trade than wish you were out of a trade
User avatar
s01
Trader
Posts: 26
Joined: Mon Jul 30, 2012 3:22 pm
Location: Midwest, USA

Re: Need some help with indicator and ea coding

Post by s01 »

ok, tried the Symbol() thing:

Code: Select all

double AccDigits = MarketInfo, Symbol();             // added Symbol(); 
double AccDigits = MarketInfo, (Symbol(), MODE_DIGITS);          // changed symbol
                                                       // will have to test to see if it works
int fpc()                                              // used later down
{
  if (AccDigits == 4) return (1);                       // added a01
  if (AccDigits == 5) return (10);
  if (AccDigits == 6) return (100);                     // for future criminal adjustments
  if (AccDigits == 7) return (1000);                    // added s01 ^^^^^^^^^^^^^^^^^^^^^
  return (1); 
}

double PointEx()
{
  if (AccDigits == 4) return (1*Point);                 // added s01
  if (AccDigits == 5) return (10*Point);
  if (AccDigits == 6) return (100*Point);               // for future criminal adjustments
  if (AccDigits == 7) return (1000*Point);              // added s01 ^^^^^^^^^^^^^^^^^^^^^
  return (Point); 
}
   }
and get this:

289:9;'AccDigits' - variable already defined
291:12;'(' - function definition unexpected
302:11;'AccDigits' - variable not defined
303:11;'AccDigits' - variable not defined
304:11;'AccDigits' - variable not defined
305:11;'AccDigits' - variable not defined
308:1;'}' - unbalanced parentheses
>Exit code: 7
There are no bad traders, just bad systems, or rules.
A Quote that I stold from someone else:
Better to wish you were in a trade than wish you were out of a trade
rwb181
Posts: 9
Joined: Tue Jul 24, 2012 7:23 pm

Re: Need some help with indicator and ea coding

Post by rwb181 »

I'm at a loss. Sorry I couldn't help (and probably confused you more)
Post Reply

Return to “Coders Hangout”