| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Random Generator
Does anyone know how I can set a random variable?
I'm trying to simulate a coin toss, so if variable = true, then buy, and if variable = false, then sell. I would imagine MathSrand and MathRand is used, but how? |
|
|||
|
Quote:
MathRand() return a number integer between 0 and 32767. So you can decide that if(MathRan() > 16383.5) buy else sell |
|
|||
|
Look at MathRand and MathMod. Your looking for odd or even numbers. Not too difficult.
Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV ![]() ForexArea.com Users of Gap Trader from 'Forex-Assistant' MUST Read This |
|
|||
|
Random number generation will work just fine, but you can do it with time as well.
if (CurrentTime() % 2 == 0) openLong; else openShort; Instead of CurrentTime(), you could also use Seconds() or really anything that returns the same number of odd as even values (I'm counting zero as an even value here). -MRE-
__________________
I'm open to professionally developing EAs. PM me if you're interested. |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Profit Generator EA | holyguy7 | Expert Advisors - Metatrader 4 | 841 | 04-29-2008 02:23 PM |
| Random Walk Index? | WNW | Indicators - Metatrader 4 | 28 | 04-22-2008 03:02 PM |
| How do u use random data (custom charts) in MT4?? | HellGungrave_777 | Metatrader 4 | 2 | 12-28-2007 12:33 AM |
| Random Walk indicator | raff1410 | Indicators - Metatrader 4 | 21 | 08-23-2007 09:57 AM |