Straddle system using the ADR

Hi All, great thread.

I have got this far, now understanding the mechanics of the trade.
I have copied the to mq4s, to the scripts folder and can see them in the Navigator window. When I right click on them, I go “execute on chart”, am asked to confirm it, which I do, but I do not see how the orders are then filled in the order window ?
Am I doing something wrong ?
Any tips welcome.
Many thanks

Make sure you have trading enabled for EAs/scripts. Go to the “Tools” menu of MetaTrader, choose “Options”, and then the “Expert Advisors” tab. Make sure the box next to “Allow Live Trading” is checked.

If this is checked and the trades still aren’t being placed, check the “Journal” and “Experts” tabs in MetaTrader for any error messages when you run the scripts.

Are the pending orders on IBFX’s server or on your pc when the scripts are utilized?

My gain for the week is right at 10%. See the attachment for the stats if interested.

straddle 10-3-08.zip (8.93 KB)

Here’s the great thing about this system. Good days like Tuesday and Thursday compensate for bad days like Wednesday. Then there are [B]UGLY[/B] days like today. Every trade hit S/L (I could kinda feel it was going to happen, but traded anyway). I ended the day down 1040 pips. Now for the psychology and money management. Can you stand to watch every trade close for a loss? Can you handle the draw down. Personally, I do fine with this because I can track things tangibly and logically. Even with my worst day ever, I ended the week up 1090 pips. That equals a 79.72% gain in 3 weeks! :smiley:

One thing I might recommend based on my charting is to track a few days and start out on a day after one with heavy losses. Also, Mondays have historically been good days, though I’ve only tested 3 weeks.

Another thing I noticed/decided. USD/CAD absolutely stinks with this method and NZD/USD is even worse. I will not be trading these pairs anymore. The 8 I’m testing starting next week are: USD/JPY, EUR/USD, GBP/USD, AUS/USD, USD/CHF, EUR/JPY, GBP/JPY, and EUR/CHF.

PIP_CHASER…I want to use the data I have and test the outcome of your reverse MM (+1 for wins, -1 for losses) and see the results. Apart from USD/CAD and NZD/USD, I’ve never had more than 2 consecutive losses. I’ll let you know.

I had all loses today as well (NFP go figure). GBPUSD is still open. What mm strategy have you been using to get that kind of return?
Another option is trade only your favorite pair and increase the position to compensate for the other pairs you stop trading. I have thought about just trading the EURUSD. This would make it a lot faster to enter trades and more manageable on the spreadsheet side.

Thanks 4xLongname, I have managed to get the script into my newly opened Interbank FX Trader 4 Demo account - $ based.

One question to your script on Post#46 Straddle.zip.
While reviewing the orders it is trying to make in the Journal tab, I see the S/L for Eur/Jpy @ 144.70 and the Usd/Jpy @104.99
The S/L are according the logic of the set up calculations, the previous days close.

So I have looked in the script, and see this “yclose=iClose(pairs[x],PERIOD_D1,1)”
I assume here through the software it is picking up the closing price from the broker.
Though I cannot trace these closing numbers to anywhere else. Reuters.com shows 105.28 & 145.00 respectively.

So my questions:
First question - specific to the script.

  1. Where would the close price be coming from. With a Friday market close and now the weekend, I would have thought the close prices would be fairly clear cut ?
    Second question - closing snap in general
  2. On say Tuesday next week when I apply the script, from which point would it draw the previous close price, the previous NY close, the broker based in the USA close ?

Testing week 6 October
I live in Germany (GMT+2), and I am planning to test this out the coming week using the demo account, and report back.
One slight problem I foresee is me not being able to knock/cancel the second trade out, after the first one has been executed.
I would run the script (order the trades) before I go to work each day. That would equate to 4am GMT. (Or would there be a better entry point ? )
I have a long days at work and would next be able to check them when getting home 19:00 GMT.
Until next time.

I just finished a web page with complete details for this system along with the spreadsheets I use and instructions for using them. They are at: Straddle System for ForEx Trading. Enjoy!

That was nice of you to do that. Thank you.

Thanks for your work bk

The answer to both of your questions is, the price(s) used for all calculations come from your broker. The “close” price is the price that the previous daily candle closed at in your MT4 platform. So, if you open a daily chart for a pair, whatever the previous candle closed at is “yesterday’s close” for the purposes of this. This is how MT4 works - any scripts, indicators, EAs, etc that you attach to it do their calculations based on the price feed that comes from the broker.

If you’re using the script I wrote (I can’t speak for the originals that were posted that I “merged” in to one, but can’t see any reason this wouldn’t be the same for them), the best time to run it is right after a new daily candle forms at your broker. If you wait too many hours after that, you may “miss” an entry that would have triggered earlier.

I also like the “set and forget” aspect of this method. I’ve modified my script to add some logic to track the orders, and created an EA to go with it that will automatically close the “opposite” order - this way, I don’t have to worry about checking in all the time to see if anything triggered.

Thanks for clearing that up for me - on the close prices and where they are coming from.
By the way I checked on a couple of pairs and the close prices were the same in your merged script and the original 2.
The script that you posted in #46 does that include the closing of the “opposite” order ?

Can you post your revised script or the code for closing the opposite pending order? I’m finishing up my total EA for this system and am curious how you coded this. Does the OrderType() actually change from OP_BUYSTOP to OP_BUY or do you check the bid/ask points to see if a trade opened? Also, is there a way to see if a trade closed (either TP or SL) without checking the bid/ask? I’ve been programming for decades and MQL is pretty straight forward, but some things that are specific to the trading aspect take a little time to grasp, plus there’s not any really good tutorials. I appreciate your help.

All of the “math” in my script comes from the original. All I did was have the part that does all the calculation repeat for each pair entered in the parameters, and enter the buy and sell pending trades at the same time rather than having to run two separate scripts.

No, my script does not include the part that closes the trades. That is done separately with an EA (Expert Advisor) that watches for when one of the pending orders is triggered.

For each “pair” of trades (long and short), I generate a pair of trade IDs in the script that opens the orders. Yes, the order type changes when a trade is opened, OP_BUYSTOP becomes OP_BUY - OP_SELLSTOP becomes OP_SELL. So, my EA looks for OP_BUY and OP_SELL orders, when it finds one, it references the ID to determine the opposite one, and does an OrderDelete() with the opposite trade ID. You can use a combination of OrderCloseTime() and OrderProfit() to check if a trade closed and if it hit TP or SL based on what OrderProfit() returns, too. OrderCloseTime() will return 0 if the order is still open (or pending).

I spent about an hour building an EA for the whole system over the weekend that I’ll be testing this week (I expect it work, but have to wait for the market to open to make sure) - although instead of PC’s suggested money management, I simply trade via a % of my equity for each trade (hence why I coded my script with that option). I didn’t want to post it, as you had mentioned previously you were working on one, and I didn’t want to hijack the thread (you were here first :)).

FYI - There’s a good MQL reference about trading functions here: Trading functions - MQL4 Documentation

Thanks so much for your help. I definitely don’t mind you posting anything you’ve worked on. I’m sure my EA will have some holes so if I compared it to yours I could pick up a few ideas.

I’m sticking with the original MM based on the adding and subtracting of lots right now, even though that risks a higher % than most are comfortable with. The EA I’m writing will initiate by asking how many lots to trade (so you can implement it even if you’ve been testing for awhile or if you restart MT4) and whether they’re mini lots (=0.1) or not (=1). The EA will place both pending orders when it’s started, then check for openings, closing, profit etc. on each tick, updating the number of lots for the next day. At the opening of the next candle, it uses the lots and new entry points calculated previously and re-enters (or modifies) the pending orders. My hope is that this will allow for back testing to get a more long term idea of how this performs.

Your answer helped a ton. Thanks.

One more question…anyone can answer if you know. Using the OrderType(), does it return an integer value that corresponds to the values you can use when placing an order? i.e. OP_BUY=0, OP_SELL=1

The example in MetaEditor assigns the value to a defined integer, but only lists the textual names. Just need a little clarification.

Long…,

Can you tell me why I’m generating an error with this command in my EA?

if(OrderSelect(bTicket,SELECT_BY_TICKET)==true)
      buyOrder=OrderType();
else
      Print("OrderSelect returned the error of ",GetLastError());

bTicket is assigned in this prior line:

bTicket=OrderSend(Symbol(),OP_BUYSTOP,Lots,buyPoint,0,sl,buy_tp,"Script entry",0);
          if(bTicket<=0) Print("Error = ",GetLastError());
          else Print("ticket = ",bTicket);

My pending order is placed and returns the ticket number as assigned to bTicket, but then bTicket doesn’t work in my OrderSelect(). I get an error 0 returned. I tried referencing by SELECT_BY_POS and assigning the returned ticket number to bTicket and it worked fine, but there’s no way of knowing what the position number of all of my orders will be just be running the script. Any help is greatly appreciated.


What OrderSend() returns (what you’re assigning to bTicket) is your broker’s order number. I don’t believe it is possible to reference this in an OrderSelect() query. What I do (there may be other ways, but this is sure-fire reliable) is create my own order ID and assign it in my OrderSend(). It is one of the parameters of the OrderSend() function - in your example above, the very last parameter (0) after the comment is the one that would be your unique orderid. This way, it’s easy for me to find it later, since I know exactly what I’m looking for.

Oh yeah - your other question OP_BUY, OP_SELL etc - yes, they are constants that have integer values, but it’s good practice to code using the constants rather than their integer values. If nothing else, it makes it much easier to read through you code later and understand what you were doing at the time.

I’m not sure if babypips has a forum for programming. If they do, I might suggest the coding discussion move there, in order to keep the focus of this thread on PC’s system…

Hi All,

I have been following the progress of this thread with great interest. First off I must say thank you PIP CHASER for posting this, I have learned a lot by following the thread.

I have one question. Is the ADR indicator that you use the Advance Decline Ratio indicator or the Average Day Range indicator?

Thanks to everyone who is keeping us up to date with progress made with this system.

Thanks,
John