Can I modify an external variable as my expert is running? I have an extern variable takeprofit = 400; but Id like to change it to 450 when I have a total of 5 orders in the market, but when I count the orders with a for statement, and ask that takeprofit=takeprofit+50; but it doesnt add my takeprofit value, any ideas on how I should do it?
- Update value in EA input panel after some condition
- Custom Indicator Variables from an EA
- Can we modify extern variables during execution ?
nduru22: Can I modify an external variable as my expert is running?
You can but remember they are reset only when the EA is loaded. If you do a EV = EV + x in init(), every TF change etc results in a deinit/init cycle and it grows continuously. Don't do it.
external EVtp=400; : int tp = EVtp; if (total >= 5) tp += 50; : // use tp not the external.
nduru22:
Can I modify an external variable as my expert is running? I have an extern variable takeprofit = 400; but Id like to change it to 450 when I have a total of 5 orders in the market, but when I count the orders with a for statement, and ask that takeprofit=takeprofit+50; but it doesnt add my takeprofit value, any ideas on how I should do it?
Are you trying to modify the TP for each Order ? if you are you are doing an OrderModify() for each Order with the new TP ?
Can I modify an external variable as my expert is running? I have an extern variable takeprofit = 400; but Id like to change it to 450 when I have a total of 5 orders in the market, but when I count the orders with a for statement, and ask that takeprofit=takeprofit+50; but it doesnt add my takeprofit value, any ideas on how I should do it?
WHRoeder:
You can but remember they are reset only when the EA is loaded. If you do a EV = EV + x in init(), every TF change etc results in a deinit/init cycle and it grows continuously. Don't do it.
thanks for this, il do it and give feedback
RaptorUK:
Are you trying to modify the TP for each Order ? if you are you are doing an OrderModify() for each Order with the new TP ?
Are you trying to modify the TP for each Order ? if you are you are doing an OrderModify() for each Order with the new TP ?
Well it is for every order though I am using a counter trending factor in my e.a so when a new order is made, the OrderModify() changes the tp and sl for every order to look like that of the most recent order as long as they are of the same type. So in essence id be changing the tp for every order. I already have an order modify doing the first modification i have mentioned.
nduru22:
Well it is for every order though I am using a counter trending factor in my e.a so when a new order is made, the OrderModify() changes the tp and sl for every order to look like that of the most recent order as long as they are of the same type. So in essence id be changing the tp for every order. I already have an order modify doing the first modification i have mentioned.
If you want the TP to reflect the change when you change the extern variable holding the takeprofit offset then you need to do a new OrderModify() in response to the change in the extern variable . . .
Well it is for every order though I am using a counter trending factor in my e.a so when a new order is made, the OrderModify() changes the tp and sl for every order to look like that of the most recent order as long as they are of the same type. So in essence id be changing the tp for every order. I already have an order modify doing the first modification i have mentioned.
RaptorUK and WHRoeder
thank you for your help, I used WHRoeder's advice and directed my advisor to open orders with a takeprofit, 5 pips greater than the external value, once the condition total>5 is met.
i feel it looks abit redundant but as I go on im sure I will find a better way of doing it.
thanks
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register