Scripts not working after build 625 - page 2

 
unash:

Thank you, pro!

Unfortunately, still not working!


What is the StopLevel of your account ??

Why don't you check reason if OrderSend fails ?

GetLastError() .....????

 
qjol:
what error do you get ?


When I launch a script (`Modify_BUY-SL-TP.mq4`, for example), it opens a normal window where i`m introducing my dates, press ' ok ' button, the window closes as usual and then nothing happenes what should hapen: to change my SL or TP of current orders. I waited 5 minutes even without anything happening. But, when I want to open it again or start another script, I see the window that asked if I want to close my first script or not. Now, regardless of the option chosen, the platform is freezing for a few seconds (10-15).
I hope that my explanations are consistent.
 
deVries:


What is the StopLevel of your account ??

Why don't you check reason if OrderSend fails ?

GetLastError() .....????


- Stop level is 5 pips. When entering data incorrectly the script warns me ' SL (or TP) is to close to market or on wrong side '.
- I checked in the ' Journal ', if that's asking me. I see ``10: 53: 56.982 Script Modify_SELL-SL-TP EURUSD M5 loaded successfully`` when I open the script and, then, after entering my data and press ' ok ', i have this ``10: 54: 09.867 Script Modify_SELL-SL-TP EURUSD M5: removed``.
 

first: you using

 bool   result;

supposed to be

 int   result;

second: why did you declared it if you dont intended to use it ? use it as DevRies suggested

   if(Bid > Price)
      {
      ResetLastError();
      result = OrderSend(Symbol(),OP_SELLSTOP,Lots,Price,slippage,stop_loss,take_profit,"",0,0,CLR_NONE);
      if (result < 0)
         Alert("Order didn't succeed Err no. ", GetLastError());
      }
 
qjol:

first: you using

supposed to be

second: you why did you declared it if you dont intended to use it ? use it as DevRies suggested



I`m sorry qjol, but, because i have not programming skills, i dont understand what you`re trying to say.

Thanks anyway.

 
pro_: Remove all the underscore signs "_" in the names of the inputs.
Underscores should be fine
Identifiers - MQL4 Documentation
Characters allowed to be written in an identifier: figures 0-9, the Latin uppercase and lowercase letters a-z and A-Z, recognized as different characters, the underscore character (_).The first character can not be a digit.
What is no longer allowed
Now you can not use a dot in their names. Also, variable names can not use the '@', '$', '?'
 
unash:



I`m sorry qjol, but, because i have not programming skills, i dont understand what you`re trying to say.

Thanks anyway.


When you are writing your code, you can click on any of the standard functions and press F1, this will open the help window and give you some details of the function.

What you should note is that OrderSend returns an integer and that integer will be the ticket number if successful and -1 if it fails.

But, you are not assigning that value to an integer variable, you are passing it to a boolean.

Now, you have to know that a boolean can only have one of two values, false or true. As outputs, false=0 and true=1

This means that

if (result < 0)

can never be true, because result is a boolean variable and the only possible integers are 0 or 1

 
GumRai:


When you are writing your code, you can click on any of the standard functions and press F1, this will open the help window and give you some details of the function.

What you should note is that OrderSend returns an integer and that integer will be the ticket number if successful and -1 if it fails.

But, you are not assigning that value to an integer variable, you are passing it to a boolean.

Now, you have to know that a boolean can only have one of two values, false or true. As outputs, false=0 and true=1

This means that

can never be true, because result is a boolean variable and the only possible integers are 0 or 1



Thank you for your kindness, GumRai. But, i still dont understand what should i do with this informations. The scripts are not working after build 625 and i`m still not working. Thanks again!

 

Just took a few minutes to check one of the scripts you are talking about. It is working just fine! It works as is, but still should be changed as was advised above, namely it should not be bool result, but int result.

Are you aware that in a new version of MT4 all experts,indicators, and scripts should be inside proper folders inside MQL4 folder? Maybe that is a problem. I heard about similar confusions others had. So check that. Other than that there is nothing to advise you since the script IS working!

I made some changes and here it is, place it in the right folder, it works.

#property show_inputs
//#property show_confirm
#include <stdlib.mqh>  

extern double Lots    = 0.1;
extern int Slippage   = 3;
extern int Stop_Loss  = 20;
extern int Take_Profit = 20;
 
//+------------------------------------------------------------------+
//| script "Open a new Buy Order"                                    |
//+------------------------------------------------------------------+
int start()
  {
   double Price = WindowPriceOnDropped();
   int   result,slippage;
   int Error=GetLastError();     

//----
   int NrOfDigits = MarketInfo(Symbol(),MODE_DIGITS);   // Nr. of decimals used by Symbol
   int PipAdjust;                                       // Pips multiplier for value adjustment
      if(NrOfDigits == 5 || NrOfDigits == 3)            // If decimals = 5 or 3
         PipAdjust = 10;                                // Multiply pips by 10
         else
      if(NrOfDigits == 4 || NrOfDigits == 2)            // If digits = 4 or 3 (normal)
         PipAdjust = 1;            
//----   
   
   slippage = Slippage * PipAdjust; 
   
   double stop_loss = Price + Stop_Loss * Point * PipAdjust;
   double take_profit = Price - Take_Profit * Point * PipAdjust; 
   
   if(Bid > Price)
   {
   result = OrderSend(Symbol(),OP_SELLSTOP,Lots,Price,slippage,stop_loss,take_profit,"",0,0,CLR_NONE);
   if(result<0) Print("Error = ", ErrorDescription(Error));
   }
   if(Bid < Price)
   {
   result = OrderSend(Symbol(),OP_SELLLIMIT,Lots,Price,slippage,stop_loss,take_profit,"",0,0,CLR_NONE);
   if(result<0) Print("Error = ", ErrorDescription(Error));
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 

I made the changes and, though, nothing has changed. Even with the above scripts, nor with 15 other scripts. The problem seems to be somewhere else.

Thanks again, pro!

Reason: