trouble with price

 

hi, i want set buylimit or selllimit but the price is not run. And sleep it's not run.

How can i do ?

Thanks


//+------------------------------------------------------------------+
//|                                                  MACD Sample.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"

input int buyorsell =1;
input double pricebegin =1937;
input double Lots       =0.01;
input double longstep   =100;
input double TakeProfit =100;
input double StopLoss   =150;



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick(void)
  {
 double my=Point;
 double longstep1=longstep*my;
 double a1=100;
 double b1=Ask+a1*my;
 
     {
      //--- check for long position (BUY) possibility
      if(buyorsell==1)
        {
         OrderSend(Symbol(),OP_BUYLIMIT,Lots,b1,3,b1-StopLoss*my,b1+TakeProfit*my,"kulu",16384,0,Green);
         
         }
      //--- check for short position (SELL) possibility
      if(buyorsell==2)
        {
         OrderSend(Symbol(),OP_SELLLIMIT,Lots,Bid,3,0,Bid-TakeProfit*my,"macd sample",16384,0,Red);
        }
      //--- exit from the "no opened orders" block
      return;
     }
 Sleep(100000);
//---
  }
//+------------------------------------------------------------------+

thanks

 
vuivetinao:

hi, i want set buylimit or selllimit but the price is not run. And sleep it's not run.

How can i do ?

Thanks


thanks

where is this file located? In which directory?

For EAs, they need to be in MQL4/Experts, and compiled there.


 
vuivetinao: How can i do ?
  1. Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
              Code debugging - Developing programs - MetaEditor Help
              Error Handling and Logging in MQL5 - MQL5 Articles (2015)
              Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
              Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)

  2.  double b1=Ask+a1*my;
             OrderSend(Symbol(),OP_BUYLIMIT,Lots,b1,3,b1-StopLoss*my,b1+TakeProfit*my,"kulu",16384,0,Green);

    Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5 / MT4+strict), it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 programming forum (2012)

  3. A Buy Limit must be below current market price
              Example of a buy limit and a buy stop? - General - MQL5 programming forum #1 (2020)

  4. You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.

    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)

      Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
      My GBPJPY shows average spread = 26 points, average maximum spread = 134.
      My EURCHF shows average spread = 18 points, average maximum spread = 106.
      (your broker will be similar).
                Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)