Two questions from a rookie

 

1)  I noticed that some automated trades are not initiated.  Is there a way to code the EA to try the trade again or do a market order getting the best possible price?

2)  Is there a way to code the EA to set a variable to the close of a certain time of day?

Thanks!

 
1)  I noticed that some automated trades are not initiated.  Is there a way to code the EA to try the trade again or do a market order getting the best possible price?

Yes.  But first review and understand why the trade was not initiated (for example, did an error occur?)--this will help you make the next decisions: how to fix the problem (if there was one) and when/how to retry the Ordersend sequence.

 2)  Is there a way to code the EA to set a variable to the close of a certain time of day?

Please clarify your question.  Do you mean closing a order at a certain time of day?  If yes, review the expiration variable in the Ordersend() function.  Or do you mean actually setting a variable to a certain time of day?  If so, review the Time and Date Functions.
 

Thanks Thirteen, on the second question.  Time and Date Functions is what I was looking for.

On the first question:  I think everything is fine.  It was working most of the time when I used a LotsOptimized() function but then I replaced it with 0.1 for Lot Size.

Example is like this:

//---- buy conditions
   if(Open[1]<125.62 && Close[1]>125.62) 
     {
//      res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,"",MAGICMA,0,Blue);  Old Line of code that works most of the time
        res=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,0,0,"",MAGICMA,0,Blue);  // New Line of code
      return;

     }

 
apbanf:

1)  I noticed that some automated trades are not initiated.  Is there a way to code the EA ..

2)  Is there a way to code the EA to set a variable to the close of a certain time of day?

  1. ALWAYS a way to code it correctly. Check your return code and find out why.
  2. ALWAYS a way to code it correctly. If you mean to close a open trade, code it.
  3. Since there are no slaves here, you have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt and the nature of your problem.
 
Thanks WHRoeder for your link on number 1.
 
apbanf:

1)  I noticed that some automated trades are not initiated.  Is there a way to code the EA to try the trade again or do a market order getting the best possible price?

2)  Is there a way to code the EA to set a variable to the close of a certain time of day?

1.  What error are you getting ?  are you checking the return values and printing the errors to the log ?  Click me

2.  "close of a certain time of day" ?  do you mean close of a certain Bar ?  

 

Thanks RaptorUK!  WHRoeder sent me your link in his message.  I'm going to try it out later today.

On number 2, Yes, I'm looking to get the close of a certain bar that occurs at a certain time of day.  I think the link from Thirteen will be helpful but once again I won't get a chance to try until later today.

Thanks again!

Reason: