Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1953

 

Hello, I have approached this autotrade algo from different angles, I'm I missing anything? 

it adds ups logically and works in it basic form but does not work when I complete it. I have used the on tick and the start but they only work in it skeletal forms when there's only one trade to execute 


 int start()
{
    while(control01 == control02)
         {        

if(Month() == monthSet &&  Day() == daySelect && Hour() == hourSet && Minute()== minuteSet)
  {
  Print ("Server Time:", TimeCurrent());
      
  if(tradeType == "buy")
                  {
                  
                  sl = Bid-pip50;
                  tp100 =pip100+Bid;
                  OrderSend(Symbol(),OP_BUY,LotSize,Bid,NULL,sl,tp100,commentCheck2,0,404,Blue);

            //Selecting hedge trade and exiting loop if it exists
                  int hstT=OrdersHistoryTotal();
                  hstT= hstT-1;
                  OrderSelect(hstT,SELECT_BY_POS,MODE_HISTORY);

               if(OrderComment() == commentCheck2)
                  control01=control01+3;
                  }
       else if(tradeType == "sell")
                  {
                 
                  sl = Ask+pip50;
                  tp100 =Ask-pip100;
                  OrderSend(Symbol(),OP_SELL,LotSize,Ask,NULL,sl,tp100,commentCheck2,0,404,Blue);

               //Selecting hedge trade and exiting loop if it exists
                  int hstT=OrdersHistoryTotal();
                  hstT= hstT-1;
                  OrderSelect(hstT,SELECT_BY_POS,MODE_HISTORY);

               if(OrderComment() == commentCheck2)
                 control01=control01+3;
                  }
     }}


return (0);
}
 
Hello,who can help me with time filter, it's not functioning properly on strategy tester

 
Healer Qoyman #: who can help me with time filter, it's not functioning properly on strategy tester
  1. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

    We can't see your broken code.

  2. “functioning properly” is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
         How To Ask Questions The Smart Way. (2004)
              When asking about code
              Be precise and informative about your problem

 

I'd like to add a really simple information panel to my chart

I copied some code from somewhere on the internet and it caused my EA to stop trading, even though pressing the compile button did not show any errors. I've since scrapped that code.

Would someone have some very simple code to put into my EA that would show some of the 'extern int' values, like this?

 Info Panel example

Stating where to insert the code parts would also be much appreciated.

As this is not an EA-specific request, I've not included any code. However, I can if you feel it's needed.

 
Can anyone tell me why my position closed despite it not reaching my T/P?
 
EagleWatchAU #: Stating where to insert the code parts would also be much appreciated.

MT4: Learn to code it.
MT5: Begin learning to code it.

If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

 
Junaid Khan #: Can anyone tell me why my position closed despite it not reaching my T/P?

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 to 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, but average maximum spread = 134 (your broker will be similar).

 
Hi, I have an issue with mql4 kind of "caching" values for charts that are newly loaded. If for example I have my ATR Indi on the chart and switch to a 4hr or daily or any other timeframe I had not already loaded the chart will autoscroll to the end and load some 2 or 3 bars and the ATR will calculate only the values for those bars until I manually scroll back when the other bars get loaded, then the ATR value will change. How can I ensure that the chart is fully loaded before I begin calculations on the bars? This is only an issue with MT4, tested on different broker platforms, MT5 loads the bars and thus the calculations okay. Thanks.
 
Dylan Fandel #:

Hello, I've created an EA which sends notifications to telegram whenever an order is opened or closed,
but I've noticed my OrderOpenTime is always different from the time at which the message is actually sent,
the delay is not constant and is always different (from few minutes to about an hour).

However, the notification sent when an order is closed is always instant.

Has anyone experienced this before and know where the issue might come from? Thanks.

If you want help you should post your code.

If you don't want to post your code in a public forum, you could pay someone in Freelance.

It seems wrong to me to ask for free help with something that you are selling in the market.

Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • 2022.07.10
  • www.mql5.com
The largest freelance service with MQL5 application developers
 
Keith Watford #:

If you want help you should post your code.

If you don't want to post your code in a public forum, you could pay someone in Freelance.

It seems wrong to me to ask for free help with something that you are selling in the market.

Okay, i deleted my post and i will check there