URGENT MT4 CODING HELP

 
void OnTick()
  {
//---
         int   tkt_buy = OrderSend("GBPUSD",       //Pair
                          OP_BUY,                  //Command Type
                          0.01,                    //Lot Size
                          Ask,                     //Market Price
                          10,                      //Max. Slippage
                          NULL,                    //Stop Loss
                          NULL,                    //Take Profit
                          "zzzzzzzzzzzzzzz",       //Comment
                          11111,                   //Magic No.
                          0,                       //Expiration (Only Pending Orders)
                          clrNONE);                //Arrow Color
                          
                          
                          Alert("done");
  }


Hello,

The above code has 0 errors

but it is only opening trades if ea attached to the GBPUSD chart

I want to multi-currency, For hedge issues. so, I would like to trade the GBPUSD (for example) from another pair chart

it should work!

before it was working...

what is going on

 
your code is wrong, replace Ask = MarketInfo("GBPUSD",MODE_ASK)
 
Mohammad Soubra: The above code has 0 errors
  1. The code as zero compile errors. Doesn't mean it hasn't logic errors and will run correctly.
  2. Why did you post your MT4 code in the Root / MT5 General section instead of the MQL4 section (bottom of the Root page?)
  3. You can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, MarketInfo does not. OrderSend does not.

    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.

    Zero is the same as PERIOD_CURRENT which means _Period.

    No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[]

  4. You hard coded "GBPUSD" and used Ask. That fails unless you are on the GBPUSD chart. Either _Symbol/Ask or GBPUSD/MarketInfo

  5. Check your return codes (OrderSend) and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  6. "URGENT MT4 CODING HELP" Don't SHOUT at us. https://www.mql5.com/en/forum/188856#comment_4797524


 

Appreciated

thanks for all