Scripts: buysell+sl+tp - page 2

 

thanks for your useful tool. just a problem: i cannot modify the  LOTS (double Lots = 0.01;      // Lots (in pips)). 

I get always 0.01 when i open a position. I`m not a programmer.

Thanks for your time.

 
emmapeel #:

thanks for your useful tool. just a problem: i cannot modify the  LOTS (double Lots = 0.01;      // Lots (in pips)). 

I get always 0.01 when i open a position. I`m not a programmer.

Thanks for your time.

"Scripts, like other programs, can have input variables. However, for scripts, the parameter input dialog is not shown by default, even if the script defines inputs. To ensure that the properties dialog opens before running the script, the #property script_show_inputs directive should be applied. It takes precedence over script_show_confirm, that is, the output of the dialog disables the confirmation request (since the dialog itself acts in a similar role). The directive calls a dialog even if there are no input variables. It can be used to show the product description and version (they are displayed on the Common tab) to the user." (Scripts - Creating application programs - MQL5 Programming for Traders).

Replace:

double Lots = 0.01;

with:

#property script_show_inputs

input double Lots = 0.20;
This will give you an adjustable setting upon attachment of the Script to a chart.
MQL5 Book: Input variables / Programming fundamentals
MQL5 Book: Input variables / Programming fundamentals
  • www.mql5.com
When launched, all programs in MQL5 can inquire parameters from the user. The only exception is libraries that are not executed independently, but...
 
Use the CODE button (Alt-S) when inserting code.

A moderator corrected the formatting this time. Please format code properly in future; posts with improperly formatted code may be removed.

Thanks for your reply.

i changed the code:

#property script_show_inputs

input double Lots = 0.20;      // Lots (in pips)
double StopLoss = 200;   // stop loss (in pips)
double TakeProfit = 400; // take profit (in pips)

but

error: 'Lots' - constant cannot be modified buy+sl+tp --------.mq5 53 4

Files:
 
emmapeel #:

Thanks for your reply.

i changed the code:

but

error: 'Lots' - constant cannot be modified buy+sl+tp --------.mq5 53 4

The OP's code is convoluted with GlobalVariables (GV's). With the show inputs directive, there's no need for GV's. Additionally, there is no point multiplier to convert points to pips. In the code attached to this post, I added SL and TP inputs, re-commented the SL and TP inputs to points, and deleted the GV's. This code compiles but is not tested.

Files: