Please correct and compile this simple custom indicator program - S100 AUD payment

 
//+------------------------------------------------------------------+
//|                                                   prvolalert.mq4 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
//+int PlaySound = (0);             // Global variable    ?????
//+
//+------------------------------------------------------------------+
//+                  AUTHOR: Tim Hine - December 2013                | 
//+------------------------------------------------------------------+
//+#property indicator_chart_window
//+int Count=0;                                    

//--------------------------------------------------------------------
//+
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
//+
//+       Alert("curr-pair, volume = " voltotal " ???buy trade???" " buys = " volbuy " - " "sells = " volsell = bsdiff;
//+       Alert("curr-pair, volume = " voltotal " ???buy trade???" " buys = " volbuy " - " "sells = " volsell = bsdiff;
  { 
int init()
   {
int voltotal = 0;
int   volbuy = 0;
int  volsell = 0;
int   bsdiff = 0;
//+
double priceold = 0; 
double    price = 0; 
   return(0);
   }
int deinit ()  
       {                       
       return(0);
       }                       
 //+                           // Exit start()
int start ()
   {
   If voltotal = 0 
       double priceold = Bid:                       {first tick} 
       voltotal = voltotal++
       return:
   If voltotal > 0    
       voltotal = voltotal++    // for second and all subsequent ticks
       priceold = price         // store old/previous price 
       double price = Bid;      // get current price
   If price > priceold
       volbuy = volbuy++       // If price has risen -  increment buy trades volume OR 1st-currency trade volume by 1 (buy volume)
   else
       If price < priceold
           volsell = volsell++     // If price has fallen - increment sell trades volume OR 2nd-currency trade volume by 1 (sell volume)
   priceold = price    
   If volbuy > = 4 
       PlaySound("oops.wav");   
       alert("curr-pair, volume = " voltotal " ???buy trade???" " buys = " volbuy " - " "sells = " volsell = bsdiff;
       return:
   else 
       If volsell > = 4
//+           void PlaySound("oops.wav");  
           PlaySound ("oops.wav"); 
           alert("curr-pair, volume = " voltotal " ???sell trade???" " sells = " volsell " - " " buys = " volbuy = bsdiff; 
           return;     
   }
           
      
          
           
                                             
   

I have a relatively small and simple custom indicator MQL4 program which I am battling to compile error-free. There does not seem to exist one MQL4 tuturial or text that logically and sequentially addresses the entire subject intelligently from the global to the detail. To me, they all jump around and have noticeable gaps in required info. Structure requirements per program type and overall function, globals, functions etc. are in itty bits and are not comprehensive and self-contained.

I feel that it should be a relatively easy task to fix this program for anyone with MQL4 experience.

I will pay $100 AUD to anyone to work on this program and compile it without errors and warnings.

It is 'prvolalert.mq4' in the custom indicator programs on MT4 navigator. My email is timhine@yahoo.com

Many thanks.

 
timhine45:

I have a relatively small and simple custom indicator MQL4 program which I am battling to compile error-free. There does not seem to exist one MQL4 tuturial or text that logically and sequentially addresses the entire subject intelligently from the global to the detail. To me, they all jump around and have noticeable gaps in required info. Structure requirements per program type and overall function, globals, functions etc. are in itty bits and are not comprehensive and self-contained.

I feel that it should be a relatively easy task to fix this program for anyone with MQL4 experience.

I will pay $100 AUD to anyone to work on this program and compile it without errors and warnings.

It is 'prvolalert.mq4' in the custom indicator programs on MT4 navigator. My email is timhine@yahoo.com

Many thanks.

You will need to post the code here for people to see it . . . they cannot see what you have in your MT4 terminal. either attach it as a file or add it using the SRC button, if you post without using the SRC button the code will be removed.
 
RaptorUK:
You will need to post the code here for people to see it . . . they cannot see what you have in your MT4 terminal. either attach it as a file or add it using the SRC button, if you post without using the SRC button the code will be removed.


After searching around for the SRC link, I found it and added my code as you wanted me to do. I hope that my post is now acceptable and I will do it this way in any need in the future.

When I state that I feel that MQL4 is complex and mathematical and therefor quite diffifult to work with, as I have said, this is comapred to my experience with the

several mainframe languages which I have programmed in and which I am quite expert with. Thus my statement id not an absolute one, but is a relative one according to my experience.

 

Your locally declared variables will be reset to zero every tick.

You need to use static or global scope variables if you want to compared them with the last time start() was called.

 
timhine45:


After searching around for the SRC link, I found it and added my code as you wanted me to do. I hope that my post is now acceptable and I will do it this way in any need in the future.

When I state that I feel that MQL4 is complex and mathematical and therefor quite diffifult to work with, as I have said, this is comapred to my experience with the

several mainframe languages which I have programmed in and which I am quite expert with. Thus my statement id not an absolute one, but is a relative one according to my experience.

You really need to start reading the Documentation and the Book . . . you have many fundamental issues with your code. Local vs Global scope variables, conditional statements, basic syntax . . .
 
RaptorUK:
You really need to start reading the Documentation and the Book . . . you have many fundamental issues with your code. Local vs Global scope variables, conditional statements, basic syntax . . .

This code compiles . . .

//+------------------------------------------------------------------+
//|                                                   prvolalert.mq4 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
//+int PlaySound = (0);             // Global variable    ?????
//+
//+------------------------------------------------------------------+
//+                  AUTHOR: Tim Hine - December 2013                | 
//+------------------------------------------------------------------+
//+#property indicator_chart_window
//+int Count=0;                                    

//--------------------------------------------------------------------
//+
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
//+
//+       Alert("curr-pair, volume = " voltotal " ???buy trade???" " buys = " volbuy " - " "sells = " volsell = bsdiff;
//+       Alert("curr-pair, volume = " voltotal " ???buy trade???" " buys = " volbuy " - " "sells = " volsell = bsdiff;

//  {   RaptorUK

int init()
   {
   
   return(0);
   }

int deinit ()  
   {                       
   return(0);
   }                       

 //+                           // Exit start()  RaptorUK  you aren't in start yet . . .

int start ()
   {
   int voltotal = 0;    //  RaptorUK  variable declarations moved from init()
   int   volbuy = 0;
   int  volsell = 0;
   int   bsdiff = 0;
   //+
   double priceold = 0; 
   double    price = 0; 
   
   
   if (voltotal == 0)     // RaptorUK added  ( )  braces
      {                  // RaptorUK added brace 
      priceold = Bid;               //  RaptorUK  : --> ;   variable already declared     {first tick} 
   
      voltotal++;         // RaptorUK  removed  voltotal = 
      return(0);                  // RaptorUK  return;  -->  return(0);
      }                  // RaptorUK added brace
       
   if (voltotal > 0)     // RaptorUK added  ( )  braces
      {                     // RaptorUK added brace    
      voltotal++;    // for second and all subsequent ticks   // RaptorUK  removed  voltotal = 
      priceold = price;         // store old/previous price 
      price = Bid;      // get current price                RaptorUK  variable already declared
      }                         // RaptorUK added brace

   if (price > priceold)     // RaptorUK added  ( )  braces
       volbuy++;       // If price has risen -  increment buy trades volume OR 1st-currency trade volume by 1 (buy volume)  RaptorUK  removed volbuy = 
   else
       if (price < priceold)     // RaptorUK added  ( )  braces
           volsell++;     // If price has fallen - increment sell trades volume OR 2nd-currency trade volume by 1 (sell volume)  RaptorUK removed volsell = 
   priceold = price;    
   if (volbuy >= 4)     // RaptorUK added  ( )  braces 
      {                  // RaptorUK added brace
       PlaySound("oops.wav");   
       Alert("curr-pair, volume = ", voltotal, " ???buy trade???", " buys = ", volbuy, " - ", "sells = ");   // RaptorUK  added  , , , ,
       volsell = bsdiff;
       return(0);
       }                  // RaptorUK added brace
   else 
       if (volsell >= 4)     // RaptorUK added  ( )  braces
          {                  // RaptorUK added brace
//+           void PlaySound("oops.wav");  
           PlaySound ("oops.wav"); 
           Alert("curr-pair, volume = ", voltotal, " ???sell trade???", " sells = ", volsell, " - ", " buys = ");  // RaptorUK  added  , , , ,
           volbuy = bsdiff; 
           return(0);
           }                  // RaptorUK added brace
   }
 
timhine45:

I will pay $100 AUD to anyone to work on this program and compile it without errors and warnings.


How do I claim my $100 AD ?
 
Seems indentation doesn't exist on Mainframe programming languages.
 
angevoyageur:
Seems indentation doesn't exist on Mainframe programming language.
Maybe not . . . but this is mql4 not any Mainframe programming language, so why wouldn't anyone follow the mql4 syntax ?
 
RaptorUK:
How do I claim my $100 AD ?


RaptorUK,

Many thanks and I must say your comments of each and every single change that you made are much appreciated.

Yes indeed, I do need to spend a lot more spend time with the tutorail text.

Obviously I need to run this code you have fixed and be sure that it runs as I wanted it to do when attempting to write the program.

If it does then I will get back to you as I owe you the $100 AUD stated. Parhaps I can transfer it to your bank account or something else which suits you

and if so please let me have whatever details I will need.

 
timhine45:


If it does then I will get back to you as I owe you the $100 AUD stated. Parhaps I can transfer it to your bank account or something else which suits you

and if so please let me have whatever details I will need.

It's OK, I'm not really after your money . . . your code will probably not do what you wanted . . .

GumRai:

Your locally declared variables will be reset to zero every tick.

You need to use static or global scope variables if you want to compared them with the last time start() was called.

. . . GumRai is quite correct.

Take this opportunity to read the advice given and do some learning, none of us is ever too old or too experienced to learn.
Reason: