Sunday Breakout Strategy

No offence, but I feel that the forex books out there are full of **********!!! One forex author talked about go fishing, another talked about wolves. Have not much idea and confused after reading them. But your ebook is so useful!!

They pumped up the number of pages by doing lots of analogy and stuffs, and if u really cut them down to useful pages, it probably less than 10 pages…

If u really want to publish it, your publisher might want you to pump it up?

It would be easy to modify your indicator into an EA. All you’d need to do is add a few lines of code.

You need something to compute the lot size, which it looks like you’ve already done in your new indicator, and then an if statement open an order when the price reaches the entry point.

Read up on the “OrderSend()” command. That’s all you need that you haven’t already done before!

Just stick something like this at the end of your indicator…

if ( Buy_Trade_Opened_This_Week == 0 && OrdersTotal() == 0)
      { 
        // money management code here
         
         if ( Bid > OSP_Buy)
            {
               buy_ticket = OrderSend(blah, blah, blah);
               Buy_Trade_Opened_This_Week = 1;
            }
      }

Of course you’d need another one for the short trade, and one for setting the trade to breakeven, but it shouldn’t be too hard. The hard and time consuming part is debugging and testing it before you use it with real money!

Looking at your code I can tell you are a much better programmer than I am! If I can learn to do it than you can do it better!

btw, pipvalue = same currency of your account

In the official document, they said u need to keep track of your orders, and that’s where I got lost…

You’re probably right. I have 75 pages of real information, written in the same style as my ebook, and once I add in the pictures, charts, and diagrams it will probably be around 125-150 pages. I checked the forex books on Amazon and most are 250 pages or more.

There’s no way I could write that much about forex (trading really isn’t THAT complicated) without adding fluff, and I refuse to do that! My publisher gave me the names of two other publishers that I should send it too, and if they don’t like it as-is (which they probably won’t) then I’ll give it away here…

It’s no big deal to me since I’m writing it because I enjoy doing it, not to make a buck. But if a publisher will pay me a buck or two for it, I’m not going to refuse it!

Excellent!!! Get it out ASAP!! I need to do trades other than breakouts, as I need to retire tomorrow! haahah!!

That’s true, but it’s easy…

We’d have multiple copies of the EA running on multiple charts at once, so you need something called a “magicnumber” so each EA knows which order belongs to it.

You have all your pairs assigned to a number…

if( Symbol() == "EURUSD" ) { Magic_Number = 4; }

Then you plug the Magic_Number variable into the proper place in the OrderSend() function.

Voila! Your orders are being tracked!

hmmmm, how does this concept of orders work…I’m going to re-read the official document

Still don’t understand why they need keep track of number and so forth…and they would return ticket number?..

Wait a min?!?!!? I thought u said you don’t trust EA!?!?!?!!?

based on this in the help file:

int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

symbol - Symbol for trading.
cmd - Operation type. It can be any of the Trade operation enumeration.
volume - Number of lots.
price - Preferred price of the trade.
slippage - Maximum price slippage for buy or sell orders.
stoploss - Stop loss level.
takeprofit - Take profit level.
comment - Order comment text. Last part of the comment may be changed by server.
magic - Order magic number. May be used as user defined identifier.
expiration - Order expiration time (for pending orders only).
arrow_color - Color of the opening arrow on the chart. If parameter is missing or has CLR_NONE value opening arrow is not drawn on the chart.

seemed like just 2 lines of code, one for buy and one for sell

I don’t trust it to do my trading automatically, but I do trust it to figure my lot size and open a trade using a trading system that I know inside and out.

It’s not really the EA’s I don’t trust, it’s the trading strategies they use the things that programmers try to make them do… Like simulate human judgement.

With this EA I’d still be the one making the decisions, not the EA. I know when to turn it off. It’s a tool to help you trade, not a robot to trade for you! :slight_smile:

oh yeah, need a few more condition checks:

  • when to place orders
  • when to remove orders when it’s Friday
  • when to move to breakeven

Not contradicting?..

going to draft out the program I am going to write an EA for,

  1. find the closest sunday candle and draw a box and SL TP with it
    =====> after this is done, do not do it again
    =====> this should probably be put in the init module

  2. if the Day=Monday, and 0100 hour candle is formed
    =====> draw the box with SL and TP
    =====> send buy and sell order; keep track of the TicketNumber
    =====> set inMarket flag = true

  3. if inMarket flag is true
    =====> check if price reached BE for OSPBuy or OSPSell, if true, modify order’s SL to BE
    =====> check if current ATR is more than 40% of the weekly ATR(14), if true, remove all pending orders
    =====> check if Friday GMT 1200, close all inMarket Orders

did I miss anything?

Can you confirm this? I was under the impression that a chart will not interfere with another chart of the same indicator?

Consider it confirmed. When an EA places a trade it needs the magic number to know which trade belongs to it.

If you leave them out you can potentially have the EA on the GBP/JPY chart messing with the trades on GBP/USD.

Here’s a piece of magic number code I found…

// Set the Magic numbers
  if( Symbol() == "AUDCADm" || Symbol() == "AUDCAD" ) { _magicNumber = 95741001; }
  if( Symbol() == "AUDJPYm" || Symbol() == "AUDJPY" ) { _magicNumber = 95741002; }
  if( Symbol() == "AUDNZDm" || Symbol() == "AUDNZD" ) { _magicNumber = 95741003; }
  if( Symbol() == "AUDUSDm" || Symbol() == "AUDUSD" ) { _magicNumber = 95741004; }
  if( Symbol() == "CHFJPYm" || Symbol() == "CHFJPY" ) { _magicNumber = 95741005; }
  if( Symbol() == "EURAUDm" || Symbol() == "EURAUD" ) { _magicNumber = 95741006; }
  if( Symbol() == "EURCADm" || Symbol() == "EURCAD" ) { _magicNumber = 95741007; }
  if( Symbol() == "EURCHFm" || Symbol() == "EURCHF" ) { _magicNumber = 95741008; }
  if( Symbol() == "EURGBPm" || Symbol() == "EURGBP" ) { _magicNumber = 95741009; }
  if( Symbol() == "EURJPYm" || Symbol() == "EURJPY" ) { _magicNumber = 95741010; }
  if( Symbol() == "EURUSDm" || Symbol() == "EURUSD" ) { _magicNumber = 95741011; }
  if( Symbol() == "GBPCHFm" || Symbol() == "GBPCHF" ) { _magicNumber = 95741012; }
  if( Symbol() == "GBPJPYm" || Symbol() == "GBPJPY" ) { _magicNumber = 95741013; }
  if( Symbol() == "GBPUSDm" || Symbol() == "GBPUSD" ) { _magicNumber = 95741014; }
  if( Symbol() == "NZDJPYm" || Symbol() == "NZDJPY" ) { _magicNumber = 95741015; }
  if( Symbol() == "NZDUSDm" || Symbol() == "NZDUSD" ) { _magicNumber = 95741016; }
  if( Symbol() == "USDCHFm" || Symbol() == "USDCHF" ) { _magicNumber = 95741017; }
  if( Symbol() == "USDJPYm" || Symbol() == "USDJPY" ) { _magicNumber = 95741018; }
  if( Symbol() == "USDCADm" || Symbol() == "USDCAD" ) { _magicNumber = 95741019; }
  if( Symbol() == "XAUUSDm" || Symbol() == "XAUUSD" ) { _magicNumber = 95741020; }
  if( Symbol() == "XAGUSDm" || Symbol() == "XAGUSD" ) { _magicNumber = 95741021; }
  if( _magicNumber == 0 ) { _magicNumber = 95741999; }

Put that at the top of the code, make sure all the pairs you want are listed inthere, and then put the “_magicNumber” variable in the proper field in the OrderSend() function and you’re covered!

From here:
Magic Number mystery! | metatrader.info

Looks like it’s to differciate orders by different indicators running at the same time in a same chart?

Okay, I’m going to define a magic number for this indicator - I don’t think it should be different for each symbol?

Most US brokers won’t let you set up both long and short limit orders at the same time now. A better solution might be to open a market order when the current price is >= (or <= for short) the entry price. Then no pending orders are needed.

It needs to be different for each symbol. Say you have 4 charts up with 4 different symbols, each running a copy of the EA.

If you close MT4 and then start it back up the EA’s will have no idea which order belongs to which EA. Ticket numbers will be useless because they were lost during the restart, but the magic numbers are attached to the order on the brokers side so they can always be used to tell which order belongs to which EA.

I’m editing the book and just got to the part where I tell a story about toilet paper.

Does that beat the fishing and the wolves?

It’s only a few paragraphs and has a good point… I’m keeping it. :slight_smile: