Very rookie question...

 

I'm just learning to code.  I'm learning with a course I found on Udemy.  So far it's a great course.  I've been following along using the code I learn and making sure that I'm writing properly.

Well, I just learned how to send an order for the first time.  Below is the code I'm trying.  I've copied the instructor's code almost exactly.  The only thing I changed was the prices because the actual live prices are different then when the video was recorded.  When I try to run this script, nothing happens.  If I add an alert to say, "Test" or whatever... that works.  It pops up.  But no order is sent.  I've tried it on a demo from two separate brokers.  

He said that there is more information that could go into those brackets and explained all the things I could add but pointed out that they were required to send this order.  This is as far as he filled it out in the lesson and his worked fine.  I could see the entry line on the chart as well as the SL and TP lines.  When I run mine, which is practically identical, there is nothing.  No sound or anything.  In the log it says the following:

---------------------------------------------------------------

Script Test EURUSD,M1: loaded successfully

Test EURUSD,M1: initialized

Test EURUSD,M1: uninit reason 0

Script Test EURUSD,M1: removed

---------------------------------------------------------------

The code: 

void OnStart()

{

   OrderSend(NULL,OP_BUYLIMIT,1.00,1.08471,10,1.08460,1.08600);

}

---------------------------------------------------------------

I feel like everyone in this forum will look at this and know what I did wrong immediately.  I don't understand how I could have made a mistake with such a short code.

Would deeply appreciate your help.  Thank you in advance!

Jay

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
The provided robot is a result of several years of trading and research on thousands of strategies, various indicators of forecasting, aimed at creating the science of online trading engineering. By combining several strategies and algorithms in this robot, at changing each tick price, with the utmost precision and speed,  whatever a trader...
 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. OrderSend(NULL,OP_BUYLIMIT,1.00,1.08471,10,1.08460,1.08600);
    You would know why, if you had checked your return codes for errors, and report them including GLE/LE, your variable values, and the market. That way we would know that at least you are calling your code.

    Don't look at GLE/LE unless you have an error. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.

  3. Don't use NULL.
    1. You can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not. OrderSend does not.
    2. Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
    3. Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
    4. MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
Reason: