Bill Curry Posted January 30, 2011 Author Report Share Posted January 30, 2011 I've gotten a request to share the modifications I've made to this EA. My modifications have been made to TMT, but some of them should work for FMT as well. I won't put the whole EA here, but I'm sure you can find it around these forums somewhere. You'll have to decompile it using ex4 to mq4 (search for it on Google or these forums) before you can make any changes. Allow smallest increments in lot step while using MM Replace the "getLots()" function with this: double getLots() { if (UseMoneyManagement == FALSE) { //if (Lots > MaximumLots) return (MaximumLots); return (Lots); } if (RiskInPercent < 0) { Log("Incorrect RiskInPercent size, it must be above 0"); return (0); } double risk_in_currency = AccountBalance() * (RiskInPercent / 100.0); if (StopLossPips <= 0) { Log("Incorrect StopLossPips size, it must be above 0"); return (0); } double calculated_lots = risk_in_currency / (10.0 * StopLossPips); double final_lots = calculated_lots - MathMod(calculated_lots, MarketInfo(Symbol(), MODE_LOTSTEP)); if (MarketInfo(Symbol(), MODE_LOTSIZE) == 10000.0) final_lots = 10.0 * final_lots; final_lots = NormalizeDouble(final_lots, LotsDecimals); double min_lot = MarketInfo(Symbol(), MODE_MINLOT); //double l_maxlot_24 = MarketInfo(Symbol(), MODE_MAXLOT); if (final_lots < min_lot) final_lots = min_lot; //if (final_lots > l_maxlot_24) final_lots = l_maxlot_24; //if (final_lots > MaximumLots) final_lots = MaximumLots; return (NormalizeDouble(final_lots, LotsDecimals)); } Allow true MM when hitting the maximum lots cap This will open up multiple positions when using MM and the max lots/position cap has been hit, allowing for true MM. Replace the "openTrade()" function with this: bool openTrade(int ai_0) { double l_price_4; int l_cmd_12; int l_error_52; double ld_60; string ls_68; if (MathAbs(ai_0) == 0.0) return (FALSE); writeExitStrategies(); RefreshRates(); int li_16 = 0; if (EntryType == 1) { Log("Entering at MARKET"); if (ai_0 > 0) { l_price_4 = Ask; l_cmd_12 = 0; } else { l_price_4 = Bid; l_cmd_12 = 1; } } else { li_16 = Time[0] + 60 * (60 * LimitOrderExpirationHours) - 100; Log("Entering at LIMIT, offset: ", EntryPipsOffset); if (EntryPipsOffset > 0) { if (ai_0 > 0) { l_price_4 = Ask + EntryPipsOffset * gd_404; l_cmd_12 = 4; } else { l_price_4 = Bid - EntryPipsOffset * gd_404; l_cmd_12 = 5; } } else { if (ai_0 > 0) { l_price_4 = Ask + EntryPipsOffset * gd_404; Log("Ask : ", Ask, ", Buy limit ", l_price_4); l_cmd_12 = 2; } else { l_price_4 = Bid - EntryPipsOffset * gd_404; l_cmd_12 = 3; } } } gi_unused_484 = 0; gs_488 = ""; l_price_4 = NormalizeDouble(l_price_4, Digits); gd_464 = l_price_4; if (UseStealthMode == FALSE) StealthModePips = 0; double l_price_20 = l_price_4 - (StopLossPips + StealthModePips) * gd_404 * ai_0; double l_price_28 = 0; if (FirstTargetClosingPercent == 100 && FirstProfitTargetPips > 0) l_price_28 = l_price_4 + (FirstProfitTargetPips + StealthModePips) * gd_404 * ai_0; double total_lots = getLots(); double ld_44 = 0; if (RiskInPercent > 0) ld_44 = AccountBalance() * (RiskInPercent / 100.0); Log("Account balance: ", DoubleToStr(AccountBalance(), 2), ", risk in currency per trade: ", DoubleToStr(ld_44, 4)); Log("Lots computed: ", total_lots); Log("Sending order, price: ", l_price_4, ", SL: ", l_price_20, ", PT: ", l_price_28, ", Lots: ", total_lots, ", Magic: ", MagicNumber, ", Comment: ", CustomComment); Log("Expiration: ", li_16, " = ", TimeToStr(li_16)); double max_lots = MarketInfo(Symbol(), MODE_MAXLOT); int number_of_positions = MathCeil(total_lots / max_lots); double remaining_lots = total_lots; for (int i=0; i<number_of_positions; i++) { double lots = remaining_lots; if (lots > max_lots) { lots = max_lots; remaining_lots -= max_lots; } int ticket_number = OrderSend(Symbol(), l_cmd_12, lots, l_price_4, 3, 0, 0, CustomComment, MagicNumber, li_16, Green); gi_504 = 0; if (ticket_number < 0) { l_error_52 = GetLastError(); Log("Error opening order: ", l_error_52, " : ", ErrorDescription(l_error_52)); if (l_error_52 != 138/* REQUOTE */ && l_error_52 != 131/* INVALID_TRADE_VOLUME */) { addLastMsg("Error:" + l_error_52 + "," + ErrorDescription(l_error_52)); return (FALSE); } if (l_error_52 == 131/* INVALID_TRADE_VOLUME */ && LotsDecimals > 0) { ld_60 = NormalizeDouble(lots, LotsDecimals - 1); if (ld_60 >= 0.01) lots = ld_60; } else addLastMsg("requote1"); RefreshRates(); if (ai_0 > 0) l_price_4 = Ask; else l_price_4 = Bid; l_price_4 = NormalizeDouble(l_price_4, Digits); l_price_20 = l_price_4 - gd_428 * ai_0; if (FirstTargetClosingPercent == 100 && FirstProfitTargetPips > 0) l_price_28 = l_price_4 + gd_436 * ai_0; Log("Requoted, Sending order again, price: ", l_price_4, ", SL: ", l_price_20, ", PT: ", l_price_28, ", Lots: ", lots, ", Magic: ", MagicNumber, ", Comment: ", CustomComment); ticket_number = OrderSend(Symbol(), l_cmd_12, lots, l_price_4, 3, 0, 0, CustomComment, MagicNumber, li_16, Green); } if (ticket_number < 0) { l_error_52 = GetLastError(); Log("Error opening order: ", l_error_52, " : ", ErrorDescription(l_error_52)); if (l_error_52 != 138/* REQUOTE */ && l_error_52 != 131/* INVALID_TRADE_VOLUME */) { addLastMsg("Error:" + l_error_52 + "," + ErrorDescription(l_error_52)); return (FALSE); } if (l_error_52 == 131/* INVALID_TRADE_VOLUME */ && LotsDecimals > 0) { ld_60 = NormalizeDouble(lots, LotsDecimals - 1); if (ld_60 >= 0.01) lots = ld_60; } else addLastMsg("requote2"); RefreshRates(); if (ai_0 > 0) l_price_4 = Ask; else l_price_4 = Bid; l_price_4 = NormalizeDouble(l_price_4, Digits); l_price_20 = l_price_4 - gd_428 * ai_0; if (FirstTargetClosingPercent == 100 && FirstProfitTargetPips > 0) l_price_28 = l_price_4 + gd_436 * ai_0; Log("Requoted, Sending order again, price: ", l_price_4, ", SL: ", l_price_20, ", PT: ", l_price_28, ", Lots: ", lots, ", Magic: ", MagicNumber, ", Comment: ", CustomComment); ticket_number = OrderSend(Symbol(), l_cmd_12, lots, l_price_4, 3, 0, 0, CustomComment, MagicNumber, li_16, Green); } if (ticket_number <= 0) { l_error_52 = GetLastError(); addLastMsg("Error:" + l_error_52 + "," + ErrorDescription(l_error_52)); Log("Error opening order: ", l_error_52, " : ", ErrorDescription(l_error_52)); return (FALSE); } if (OrderSelect(ticket_number, SELECT_BY_TICKET, MODE_TRADES)) { Log("Order opened : ", OrderTicket(), ", price :", OrderOpenPrice()); addLastMsg("Order opened"); } if (SendEmailAfterSignal) { if (ai_0 > 0) ls_68 = "LONG "; else ls_68 = "SHORT "; SendMail("TurboMorningTrade EA Signal " + TimeToStr(Time[0], TIME_DATE), ls_68 + "Trade opened at price : " + DoubleToStr(gd_464, Digits)); } if (OrderModify(ticket_number, OrderOpenPrice(), l_price_20, l_price_28, li_16, Black)) Log("Order modified : ", OrderTicket(), ", sl:", OrderStopLoss()); else { if (OrderModify(ticket_number, OrderOpenPrice(), l_price_20, l_price_28, li_16, Black)) Log("Order modified : ", OrderTicket(), ", sl:", OrderStopLoss()); else { Sleep(500); if (OrderModify(ticket_number, OrderOpenPrice(), l_price_20, l_price_28, li_16, Black)) Log("Order modified : ", OrderTicket(), ", sl:", OrderStopLoss()); else { Sleep(2500); if (OrderModify(ticket_number, OrderOpenPrice(), l_price_20, l_price_28, li_16, Black)) Log("Order modified : ", OrderTicket(), ", sl:", OrderStopLoss()); else { l_error_52 = GetLastError(); Log("CANNOT MODIFY ORDER: ", OrderTicket(), ", CLOSING, Error opening order : ", l_error_52, " : ", ErrorDescription(l_error_52)); addLastMsg("Cannot add PT/SL,cancelling order!"); if (OrderClose(ticket_number, lots, l_price_4, 6) != 1) { l_error_52 = GetLastError(); Log("CANNOT CLOSE ORDER: ", OrderTicket(), ", Error opening order : ", l_error_52, " : ", ErrorDescription(l_error_52)); addLastMsg("Cannot cancel order!"); return (FALSE); } addLastMsg("Cancelled OK"); return (FALSE); } } } } } addLastMsg("SL/PT set. All OK"); return (TRUE); } I would use these changes with a demo account first because I only just began forward testing. I've only tested these with my broker, TadawulFX, and my MQL programming experience is very limited. Use with caution. kraven and freddy 2 Quote Link to comment Share on other sites More sharing options...
freddy Posted January 30, 2011 Report Share Posted January 30, 2011 Thanks a lot Bill, I will try to figure out how to use your code, but it's a good step for learning! Will watch your TMT trading with great interest. Quote Link to comment Share on other sites More sharing options...
Bill Curry Posted January 31, 2011 Author Report Share Posted January 31, 2011 No trade today for TMT. Quote Link to comment Share on other sites More sharing options...
Bill Curry Posted February 1, 2011 Author Report Share Posted February 1, 2011 (edited) Long trade First TP hit at +35 pips (75% of position) Second TP hit at +46 pips (25% of position) Total growth of account: +13.8% Edited February 1, 2011 by Bill Curry Quote Link to comment Share on other sites More sharing options...
Roels Major Posted February 1, 2011 Report Share Posted February 1, 2011 Long trade First TP hit at +35 pips (75% of position) Second TP hit at +46 pips (25% of position) Total growth of account: +13.8% Good Jab Bill!! Quote "You Ain't Seen Nothing Yet!". Link to comment Share on other sites More sharing options...
joeytrader Posted February 2, 2011 Report Share Posted February 2, 2011 Long trade First TP hit at +35 pips (75% of position) Second TP hit at +46 pips (25% of position) Total growth of account: +13.8% Nice!! BTW, what do you use for initial stop loss? Quote Link to comment Share on other sites More sharing options...
Bill Curry Posted February 2, 2011 Author Report Share Posted February 2, 2011 Nice!! BTW, what do you use for initial stop loss? 45 pip SL 1st BE is at 20 pips, with BE+0 2nd BE is at 30 pips, with BE+15 1st TP is at 35 pips, 75% of position 2nd TP is at 45 pips, 25% of position (worst case at this point is +15 pips at 2nd BE) domonkos, hitescape and joeytrader 3 Quote Link to comment Share on other sites More sharing options...
Bill Curry Posted February 2, 2011 Author Report Share Posted February 2, 2011 (edited) Long trade First TP hit at +35 pips (75% of position) 2nd BE hit at +15 pips (25% of position) Total growth of account: +15.8% Growth since beginning of month: +27.1% Something strange happened today where a second position was opened at the full amount of lots (take a look at myfxbook trade history to see what I mean). This ended up being profitable today (hit my 2nd BE at +15 pips), but it could've been very bad if my SL was hit. Edit: Figured out what was going on. Edited February 2, 2011 by Bill Curry Quote Link to comment Share on other sites More sharing options...
kraven Posted February 2, 2011 Report Share Posted February 2, 2011 what was the problem Bill? Quote Link to comment Share on other sites More sharing options...
Bill Curry Posted February 2, 2011 Author Report Share Posted February 2, 2011 what was the problem Bill? My VPS service notified me that my machine was "down" due to a DDoS attack on their servers. I wasn't able to access it from VNC, so I assumed this was true. I setup my local machine to trade in the meantime while I waited for my VPS service to return. Today I found out that my VPS machine was actually still on and actively trading, in addition to my local machine. In other words I was accidentally running this EA twice. Could have potentially been very bad. In case you're wondering I'm using Thrust VPS, and I don't recommend them. My machine has crashed for no apparent reason at least twice, and their systems have had down time twice... all within one month. Very unreliable thus far. Quote Link to comment Share on other sites More sharing options...
kraven Posted February 3, 2011 Report Share Posted February 3, 2011 maybe this thread may help you Bill http://indo-investasi.com/showthread.php/4623-What-is-the-Best-VPS-server-to-run-your-EA Quote Link to comment Share on other sites More sharing options...
Bill Curry Posted February 3, 2011 Author Report Share Posted February 3, 2011 No trade today. Quote Link to comment Share on other sites More sharing options...
freddy Posted February 4, 2011 Report Share Posted February 4, 2011 Good trade today, now you're on your way up again towards your aim! =D> Quote Link to comment Share on other sites More sharing options...
Bill Curry Posted February 4, 2011 Author Report Share Posted February 4, 2011 (edited) Short trade First TP hit at +36 pips (75% of position, 36 * .75 = 27) Second TP hit at +47 pips (25% of position, 47 * .25 = 11.75) Total real pips: +38.75 Total growth of account: +16% Growth since beginning of month: +59.2% Today's trade was a bit scary and probably should have been a no trade. Almost immediately the price started going in the opposite direction and didn't stop until around -40 pips, nearly hitting my SL of -45 pips! Right around then is when it started turning around and went all the way down to hit both of my TP's! This trade was abnormally long, lasting around 6.5 hours. This strategy usually hits the TP's within a few hours or it goes on forever and losses. Today's trade looked like it was going to be a loser, but I'm very glad it turned around. That said, today was a loser for this strategy in my book. The fact that the price turned around is chance and there is no way TMT could've predicted that. This week has been a great way to start the month. All winners, no losers. By next week I should have completely recovered from January's losses. Hope everyone has a great weekend! Edited February 4, 2011 by Bill Curry Quote Link to comment Share on other sites More sharing options...
kraven Posted February 4, 2011 Report Share Posted February 4, 2011 nice results so far Bill......Good luck Quote Link to comment Share on other sites More sharing options...
jm2110 Posted February 5, 2011 Report Share Posted February 5, 2011 Hi Bill, I looked at your strategy tester results and just have a question on trade entry time. I thought I was fairly sure your brokers (name listed on report) server time is gmt + 1 ? Therefore if you were following a standard FMT strategy (6.30 am London) because current London = gmt shouldn't your entry time with your brokers server be centered around 7.30 am ? I may have misunderstood your server time or you may intentionally be entering an hour earlier than FMT which is great if it tests well but the question is really just so I can confirm that my interpretation of the entry time is correct? Also in the strategy tester report it mentions a 2hr expiry of signal parameter, I presumed this meant that after this period of time the trade would close regardless of where the market was at the time but in the message above you said you were in a trade for many hours. Does this mean you aren't using this parameter in live or do I misunderstand what this parameter means? Thanks Quote Link to comment Share on other sites More sharing options...
joeytrader Posted February 5, 2011 Report Share Posted February 5, 2011 . . . This week has been a great way to start the month. All winners, no losers. By next week I should have completely recovered from January's losses. Hope everyone has a great weekend! Congratulation!! Quote Link to comment Share on other sites More sharing options...
Bill Curry Posted February 5, 2011 Author Report Share Posted February 5, 2011 Hi Bill, I looked at your strategy tester results and just have a question on trade entry time. I thought I was fairly sure your brokers (name listed on report) server time is gmt + 1 ? Therefore if you were following a standard FMT strategy (6.30 am London) because current London = gmt shouldn't your entry time with your brokers server be centered around 7.30 am ? I may have misunderstood your server time or you may intentionally be entering an hour earlier than FMT which is great if it tests well but the question is really just so I can confirm that my interpretation of the entry time is correct? Also in the strategy tester report it mentions a 2hr expiry of signal parameter, I presumed this meant that after this period of time the trade would close regardless of where the market was at the time but in the message above you said you were in a trade for many hours. Does this mean you aren't using this parameter in live or do I misunderstand what this parameter means? Thanks I use historical data from Dukascopy with my broker to achieve 99% modeling quality for my backtests. They use GMT+0 for their server time, which is why I have it set as so. My live account uses the time range 7:15-7:45AM. Quote Link to comment Share on other sites More sharing options...
Bill Curry Posted February 7, 2011 Author Report Share Posted February 7, 2011 What a great way to start the week with an easy win that finally puts me back in the green! Long trade entered at 7:15 First TP hit at +35 pips (75% of position, 35 * .75 = 26.25) Second TP hit at +45 pips (25% of position, 47 * .25 = 11.25) Total real pips: +37.5 Total growth of account: +15.7% Growth since beginning of month: +84.2% This is the forth consecutive win I’ve had with Turbo Morning Trade since the beginning of February and I’ve already made up for January’s losses, so I think it’s safe to say that I was correct in my prediction. With this many consecutive winning trades I’d expect to see a loss coming up soon, so don’t be surprised if that happens soon. I may fall below my initial deposit temporarily, but I think we’ll be seeing at least +200% account growth by the end of February. Quote Link to comment Share on other sites More sharing options...
chrisbenjy Posted February 7, 2011 Report Share Posted February 7, 2011 **** me! Nice one Quote Link to comment Share on other sites More sharing options...
Bill Curry Posted February 8, 2011 Author Report Share Posted February 8, 2011 As expected, TMT finally had a losing trade today and dipped below my initial deposit again. Long trade entered at 7:15 Hit SL at -50 pips Total growth of account: -22.5% Growth since beginning of month: +46.6% It almost hit what would've been my first BE at +20 pips (which it did on my demo account) but before it could it shot way, way down for 75 pips. With such an aggressive change in direction I'd think that there was some kind of news that I'm missing but I can't seem to find any at around that time. Regardless, I still expect this week to be a winner and that I'll end up in the green. Quote Link to comment Share on other sites More sharing options...
hitescape Posted February 8, 2011 Report Share Posted February 8, 2011 I received this from the Kangaroo people: "$AUDUSD: Takes a dive on the news that China has hiked its key interest rate amid fears a slowdown in Chinese growth will effect Aust. too" That probably shook the markets. Oh, I went live last night after watching the comeback. That also could be the reason. :) Quote Link to comment Share on other sites More sharing options...
Bill Curry Posted February 8, 2011 Author Report Share Posted February 8, 2011 I received this from the Kangaroo people: "$AUDUSD: Takes a dive on the news that China has hiked its key interest rate amid fears a slowdown in Chinese growth will effect Aust. too" Yup I got that e-mail too, and I think that could've been the problem. Does anyone know of a place to check when China is releasing their news? This is the second time I've been burned by news coming out of China and I don't see it listed on all the popular news calendars I follow. Oh, I went live last night after watching the comeback. That also could be the reason. :) Grats! It would be great if you could you keep this thread updated with your progress as well. Don't be discouraged by today's loss, we'll be in the green by the end of the month. Today would've been a win if the fundamentals hadn't gone and messed everything up ;) Are you using FMT or TMT? Quote Link to comment Share on other sites More sharing options...
businessman9821 Posted February 8, 2011 Report Share Posted February 8, 2011 Question Bill, (I just went live also, :), with a $500 dollar account though) Tadawulfx sever gmtoffset is GMT+1 correct? Well my broker is the same GMT+1, so since the best results on backtest were achieved in GMT+0 from 5:15 to 5:45, wouldn't this translate to 6:15 to 6:45 GMT+1 time? Instead of 7:15 to 7:45, i don't mean to contradict b/c apparently its working out for you. I'm just trying to make sure. offsetting always confuses me. Thanks for the reply. Quote Link to comment Share on other sites More sharing options...
Bill Curry Posted February 8, 2011 Author Report Share Posted February 8, 2011 Question Bill, (I just went live also, :), with a $500 dollar account though) Tadawulfx sever gmtoffset is GMT+1 correct? Well my broker is the same GMT+1, so since the best results on backtest were achieved in GMT+0 from 5:15 to 5:45, wouldn't this translate to 6:15 to 6:45 GMT+1 time? Instead of 7:15 to 7:45, i don't mean to contradict b/c apparently its working out for you. I'm just trying to make sure. offsetting always confuses me. Thanks for the reply. Great! Are you using the same settings as me? Like I said to hitescape, it'd be great if you could keep us updated with your progress. To be honest, this has been somewhat confusing to me as well. I tried backtests with different times and there were clearly some problems. I'm thinking this may have something to do with winter/summer time changes. The good news is that if you check the FMT manual Marc actually gives an example of a broker with GMT+1 and suggests 7:30 as the time to start. It would be awesome if Marc could implement something like they have in the KangarooEA, where it automatically sets your GMT offset for you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.