close all trades? - page 2

 

What you have created is a function just like iMA() or iHigh() are functions. It's just this is a custom function and is specific to this EA. As you found out, the code for the function needs to sit outside of start and dropping it at the end of the file is standard. With your function built, you now need to call it in your program. The program executes inside start() so to use the function, you need to call it just as you would any other function. The "Function "Close_All" is not referenced and will be removed from exp-file" just means it has seen the function and confirmed your not using it so removed it because it is superfluous.

So as Ubzen shows with the red highlight, after your logic that confirms to close all, you would call the function by typing Close_All();

If you want to use the close after function... something like this...

   bool OK=CloseAfter(60);  // close after 60 minutes.
   if (OK!=True)
      {
      Alert( "Close After Failed");
      }
   else
      {   
      Alert( "Close After OK");  
      }


hth

V

EDITED

 

I see you figured how to bump your posting.  Ok, lets see, hmmm.

Close_All(); /* Is all you need with-in the start function. I managed to compile as a script without any errors. Copy the entire program from start to finish and put within a script or new EA and you'll see it generates no errors. You don't need the void-Close_All nor the CloseAfter. Just copy the entire code(s) and place it into a new script or EA and Compile. After that Replace the Start() to Return() part of the code with your EA. Then make sure to reference  Close_All() within your EA. And make sure that the function void Close_All is outside the main EA. Try that and get back to me and we'll go from there. */
 
ubzen:

I see you figured how to bump your posting. Ok, lets see, hmmm.


haha, I just noticed I did that. I actually posted something and then I deleted it because I had an idea on how to make it work; then I noticed it got bumped up. Thanks you guys for all your help. I didn't want to keep on asking, but I am really understanding it a lot better and learning a lot more because of it. You guys are a great help and I am going to try out the codes right now. Thanks again.
Reason: