マジックナンバー
9件の返信
こんにちは,
Does anyone know if there is a way to create a variable that produces a random number every time it is triggered? Then we can set the variable as the magic number in the strategy parameters. If possible, this would fix the issue if you have multiple trades on a single currency pair.
Thanks for any feedback.
よろしくお願いいたします。,
ジェームズ
0
こんにちは,
1) define ‘RandNumber’ variable type INT in EA Wizard
2) choose trigger to when you want to generate random value for this varible. It can be trading signal condition itself as well.
3) add ‘Custom Action’ and type this command: ‘RandNumber = MathRand();
This way anytime the condition is met, RandNumber will be assigned with a pseudorandom integer within the range of 0 to 32767.
それが役に立つことを願っています。
0
Thanks tomas262. That will help a lot with a system I’m working on.
よろしくお願いいたします。,
ジェームズ
0
Hey Tomas262,
I’ve been messing around with the ‘RandNumber’. I’m having a problem trying to figure out how to reference the current trades SL and Entry Price because I don’t understand how to reference the random magic number.
例:
There is currently a Buy in the market and I want to place a pending order to Sell at the Buy’s SL and the SL of the Pending Sell order at the Entry of the current Buy trade.
Do you know of a way to reference the ‘RandNumber’ for managing risk and possible setting pending orders?
どんなお手伝いもありがたく受けとります。.
よろしくお願いいたします。,
ジェームズ
0
Have many concurrent trades there can be for the same pair?
Do you use the same stop-loss distance for other positions or how is SL calculated?
Generally you have to create variables and store values like the magic number of opened trade you mention. You can then use “Order Average Price (Magic Number)” function and knowing your stop-loss size I would calculate price for that pending order and stop-loss price would be the “Order Average Price” ….
But considering I don’t know exactly how your strategy works I cannot tell this is what you need.
0
ssdx,
The only problem you will have when using that method of setting magic numbers is that every time you reset your EA or restart MT4, you will have a different set of magic numbers so you will not be able to touch your EA or MT4 or your EA will loose track of your trades
0
Thanks everyone for your replies. At the moment it seems easier to stick to the magic number system I have going. All the replies have spurred some ideas that might help. Thanks again.
よろしくお願いいたします。,
ジェームズ
0
I think I have found solution. You need to use variable with magic number and put it in your rules with + operation. So long will be “magic+1”, short : “magic+2”, long2: “magic+3”, short2: “magic+4”. Then depends on how many opening position rules you have, when you add EA to another instrument you incrise “magic” variable respectively. When you have 2 long and 2 short rules your EA use 4 different numbers. For example: EA working on EUR/USD. Magic is 10. EA use numbers 11,12,13,14. Then you put EA on USD/JPY with magic number 20. EA use numbers 21,22,23,24 etc. With this method you dont have to generate random numbers and your EA don’t lost “connection” with opened trades.
Hope this help.
よろしくお願いいたします
0
Thanks luk85
I’ll take a look at what you are suggesting. Thanks for your input.
よろしくお願いいたします。,
ジェームズ
0
Good evening Luk85.
I’m back looking for options to eliminate magic number for a grid system I want to try and code. It has been a while since this thread has been active but I thought I’d ask again.
I didn’t quite understand what you explained in the above post. I would really appreciate if you could expand on that a little (or lot). 🙂
it looks like i might need around 10-20 trades per side (buy/sell).
Thank you for any of your time in helping with understanding this possibility.
よろしくお願いいたします。,
ジェームズ
0
9件の返信を表示中 - 1 - 9件目 (全9件中)