|
|||||||
| 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 (46) | Thread Tools | Display Modes |
|
|||
|
Ok, Don...here's how to sort the trend filtering:
extern int MAPeriod = 1200; double Trend = iMA(NULL, 0, MAPeriod, 0, MODE_LWMA, MODE_CLOSE, 0); should be... double Trend = iMA(NULL, PERIOD_M1, MAPeriod, 0, MODE_LWMA, MODE_CLOSE, 0); as your existing code uses 1200 periods of the current chart timeframe And for the Buy and Sell routines, you're missing some brackets so the logic is currently wrong so these: if (Ask < LowestBuy-(Spacing*Point) || Ask > HighestBuy + (TrendSpacing * Point) && Ask > Trend) if (Bid > HighestSell + (Spacing * Point) || Bid < LowestSell - (TrendSpacing * Point) && Bid < Trend) should be replaced with: if ((Ask < LowestBuy-(Spacing*Point) || Ask > HighestBuy + (TrendSpacing * Point)) && Ask > Trend) if ((Bid > HighestSell + (Spacing * Point) || Bid < LowestSell - (TrendSpacing * Point)) && Bid < Trend) Good luck, Neo |
|
||||
|
Quote:
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe. By putting in PERIOD_M1, you are locking in the 1M timeframe no matter what. I was even thinking of having a couple of externs so people could customize the MA, like one for TF and one for type of MA. Nice catch on the brackets. I didn't think that would matter. The closes are still not 100% doing what they are supposed to doing. Same situation above buys and below sells not closing out the losing opposite order all the time. Don |
|
||||
|
Ticket numbers
I think I have an idea about the improper closings. I added a HighestBuyTicket and LowestSellTicket to the comment block and noticed when I ran the backtester the tickets weren't reseting like they should. Maybe this might give us some new area of thought. Maybe a whole subroutine to refresh all the variables once profit is taken.
Don |
|
|||
|
There seem to be two more areas of issue....both in the start() function:
First, simplify the "count-up" code - I'm also pretty sure you had missed some variables that were being used later in the code... for (Order = OrdersTotal() - 1; Order >= 0; Order--) { if (OrderSelect(Order, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference) { Profit = OrderProfit() + OrderSwap() + OrderCommission(); if (OrderType() == OP_BUY) { if (OrderOpenPrice() >= HighestBuy) { HighestBuy = OrderOpenPrice(); HighestBuyTicket = OrderTicket(); HighestBuyProfit = Profit; } if (OrderOpenPrice() <= LowestBuy) { LowestBuy = OrderOpenPrice(); LowestBuyTicket = OrderTicket(); LowestBuyProfit = Profit; } BuyOrders++; if (BuyOrders > MaxBuys) MaxBuys = BuyOrders; BuyLots += OrderLots(); BuyProfit += Profit; if (Profit > 0) PosBuyProfit += Profit; } if (OrderType() == OP_SELL) { if (OrderOpenPrice() <= LowestSell) { LowestSell = OrderOpenPrice(); LowestSellTicket = OrderTicket(); LowestSellProfit = Profit; } if (OrderOpenPrice() >= HighestSell) { HighestSell = OrderOpenPrice(); HighestSellTicket = OrderTicket(); HighestSellProfit = Profit; } SellOrders++; if (SellOrders > MaxSells) MaxSells = SellOrders; SellLots += OrderLots(); SellProfit += Profit; if (Profit > 0) PosSellProfit += Profit; } } } } Next, try connecting the "if"s in the close analysis section with "else"s - I'm convinced that is where the main issue lies (might also be worth calculating MidPoint unconditionally).... MidPoint = (HighPoint + LowPoint) / 2; RefreshRates(); if (MidPoint > 0 && Ask - Bid > MidPoint) { if (PosBuyProfit + LowestSellProfit >= ProfitTarget && LowestSell < LowestBuy) { OrderSelect(LowestSellTicket, SELECT_BY_TICKET); OrderClose(OrderTicket(), OrderLots(), Ask, 5, Green); CloseBuysInProfit(); LowestBuy = 1000; HighestBuy = 0; LowestSell = 1000; LowestSellTicket = 0; } else if (PosSellProfit + LowestSellProfit >= ProfitTarget && LowestSell < LowestBuy) { OrderSelect(LowestSellTicket, SELECT_BY_TICKET); OrderClose(OrderTicket(), OrderLots(), Ask, 5, Red); CloseSellsInProfit(); LowestSell = 1000; HighestSell = 0; LowestSellTicket = 0; } else if (PosBuyProfit + LowestBuyProfit >= ProfitTarget && LowestBuy < LowestSell) { OrderSelect(LowestBuyTicket, SELECT_BY_TICKET); OrderClose(OrderTicket(), OrderLots(), Bid, 5, Green); CloseBuysInProfit(); LowestBuy = 1000; HighestBuy = 0; LowestBuyTicket = 0; } else if (PosSellProfit + LowestBuyProfit >= ProfitTarget && LowestBuy < LowestSell) { OrderSelect(LowestBuyTicket, SELECT_BY_TICKET); OrderClose(OrderTicket(), OrderLots(), Bid, 5, Red); CloseSellsInProfit(); LowestSell = 1000; HighestSell = 0; LowestBuy = 1000; LowestBuyTicket = 0; } } else if (Ask - Bid < MidPoint) { if (PosBuyProfit + HighestBuyProfit >= ProfitTarget && HighestBuy > HighestSell) { OrderSelect(HighestBuyTicket, SELECT_BY_TICKET); OrderClose(OrderTicket(), OrderLots(), Bid, 5, Green); CloseBuysInProfit(); LowestBuy = 1000; HighestBuy = 0; HighestBuyTicket = 0; } else if (PosSellProfit + HighestBuyProfit >= ProfitTarget && HighestBuy > HighestSell) { OrderSelect(HighestBuyTicket, SELECT_BY_TICKET); OrderClose(OrderTicket(), OrderLots(), Bid, 5, Red); CloseSellsInProfit(); LowestSell = 1000; HighestSell = 0; HighestBuy = 0; HighestBuyTicket = 0; } else if (PosBuyProfit + HighestSellProfit >= ProfitTarget && HighestSell > HighestBuy) { OrderSelect(HighestSellTicket, SELECT_BY_TICKET); OrderClose(OrderTicket(), OrderLots(), Ask, 5, Green); CloseBuysInProfit(); LowestBuy = 1000; HighestBuy = 0; HighestSell = 0; HighestSellTicket = 0; } else if (PosSellProfit + HighestSellProfit >= ProfitTarget && HighestSell > HighestBuy) { OrderSelect(HighestSellTicket, SELECT_BY_TICKET); OrderClose(OrderTicket(), OrderLots(), Ask, 5, Red); CloseSellsInProfit(); LowestSell = 1000; HighestSell = 0; HighestSellTicket = 0; } } Finally, I changed the initialisation code in the function header like this: double LowestBuy = 999, HighestBuy = 0.0001, LowestSell = 999, HighestSell = 0.0001, HighPoint, MidPoint, LowPoint; ...to run the Buy & Sell criteria routines on the first pass through: // BUY Trade Criteria if (HighestBuy > 0 && LowestBuy < 1000) // SELL Trade Criteria if (HighestSell > 0 && LowestSell < 1000) I added in some auditing code the to version I'm playing with and it was throwing out all sorts of errors before I made these changes. Now there are none being generated and opposite orders appear to be closing correctly. Neo Last edited by Neo : 06-26-2007 at 09:35 PM. |
|
|||
|
Ok... you guys asked for it
![]() The reason I didn't post the entire EA previously is that I generally "rewrite" EAs in my own formatting style which helps me work out what's going on. I also generally rename variables and functions, though that may just be OCD ![]() Anyway, the major deviation from Don's version is that I grafted the magic number routine from Fifth's Blessing code and added error reporting to a text file. There are a few minor revisions too but the most important is that I added the trend filtering into the Start() function. I've got a sneaking suspicion that the Martingale side of things isn't working correctly but that's no big shakes at the moment. Opps... almost forgot! I converted all neccesary "extern bool" parameters into "extern int" so that you can use them in optimisation mode in the strategy tester (0 = false, 1 = true) - the boolean code is just commented out throughout so you can switch it back if you want. If you find any other issues then I guess you'll let me know ![]() |
|
|||
|
Why Ea is warning "cannot load external expert stdlib" ?
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/martingale-average-cost-hedging/8126-pipmaker-v1-price-action-based-ea.html
|
|||
| Posted By | For | Type | Date |
| Per tutti: Expert Advisor/Strategia da valutare - Forex Forum | This thread | Refback | 06-26-2008 09:37 AM |
| FXシステムトレード自動売買実践室 | Post #1021 | Refback | 06-24-2008 02:16 PM |
| FXシステムトレード自動売買実践室 | Post #1021 | Refback | 06-14-2008 04:09 PM |
| メタトレーダーだぁ! 200805 | This thread | Refback | 06-06-2008 03:17 PM |
| Per tutti: Expert Advisor/Strategia da valutare - Forex Forum | This thread | Refback | 04-15-2008 12:39 PM |
| ^g!@SゥXX: PipMaker | This thread | Refback | 03-28-2008 02:42 AM |
| ^g!@SゥXX: tEA!! | This thread | Refback | 03-26-2008 12:06 AM |
| ^g!@SゥXX | This thread | Refback | 03-25-2008 11:15 PM |
| Expert Advisor | Forex MetaTrader Expert Advisors | Over 40 of the Best EA's for MT4 on Squidoo | This thread | Refback | 03-14-2008 04:32 AM |
| Expert Advisor | Forex MetaTrader Expert Advisors | Over 40 of the Best EA's for MT4 on Squidoo | This thread | Refback | 03-09-2008 07:41 PM |
| Expert Advisor | Forex MetaTrader Expert Advisors | Over 40 of the Best EA's for MT4 on Squidoo | This thread | Refback | 03-07-2008 02:31 AM |
| 【MT4】MetaTrader Part8【メタトレーダー】 - MetaTraderまとめWiki | This thread | Refback | 02-24-2008 06:14 AM |
| FXなんでもかんでも・・・All you need is TREND!(仮題) | This thread | Refback | 02-23-2008 08:51 PM |
| Per tutti: Expert Advisor/Strategia da valutare - Forex Forum | This thread | Refback | 02-23-2008 11:01 AM |
| 悋擧愕拆惘惠悋 愕惆惆 !!! - 惶忰 16 - Sarmaye Forums | This thread | Refback | 02-21-2008 12:27 AM |
| 悋擧愕拆惘惠悋 愕惆惆 !!! - 惶忰 16 - Sarmaye Forums | This thread | Refback | 02-13-2008 06:28 AM |
| TSDのフォーラムへのリンク | 1万円から目指す原資回復 | This thread | Refback | 02-09-2008 09:35 PM |
| 悋擧愕拆惘惠悋 愕惆惆 !!! - 惶忰 16 - Sarmaye Forums | This thread | Refback | 02-08-2008 01:34 PM |
| 悋擧愕拆惘惠悋 愕惆惆 !!! - 惶忰 15 - Sarmaye Forums | This thread | Refback | 02-08-2008 01:18 PM |
| 悋擧愕拆惘惠悋 愕惆惆 !!! - 惶忰 16 - Sarmaye Forums | This thread | Refback | 02-07-2008 12:16 AM |
| 悋擧愕拆惘惠悋 愕惆惆 !!! - 惶忰 16 - Sarmaye Forums | This thread | Refback | 02-06-2008 03:30 PM |
| 悋擧愕拆惘惠悋 愕惆惆 !!! - 惶忰 16 - Sarmaye Forums | This thread | Refback | 02-06-2008 07:43 AM |
| 悋擧愕拆惘惠悋 愕惆惆 !!! - 惶忰 16 - Sarmaye Forums | This thread | Refback | 02-06-2008 06:23 AM |
| 悋擧愕拆惘惠悋 愕惆惆 !!! - 惶忰 16 - Sarmaye Forums | This thread | Refback | 02-06-2008 06:03 AM |
| 200801 FXなんでもかんでも・・・All you need is TREND!(仮題) | This thread | Refback | 02-03-2008 08:40 AM |
| Per tutti: Expert Advisor/Strategia da valutare - Forex Forum | This thread | Refback | 01-31-2008 07:00 PM |
| FXなんでもかんでも・・・All you need is TREND!(仮題) | This thread | Refback | 01-30-2008 07:57 AM |
| 20080116 FXなんでもかんでも・・・All you need is TREND!(仮題) | This thread | Refback | 01-27-2008 12:50 PM |
| 悋擧愕拆惘惠悋 愕惆惆 !!! - 惶忰 15 - Sarmaye Forums | This thread | Refback | 01-22-2008 08:16 PM |
| FXなんでもかんでも・・・All you need is TREND!(仮題) | This thread | Refback | 01-18-2008 05:43 PM |
| FXなんでもかんでも・・・All you need is TREND!(仮題) | This thread | Refback | 01-18-2008 03:32 AM |
| ブログを書いてる暇などない・・・ FXなんでもかんでも・・・All you need is TREND!(仮題) | This thread | Refback | 01-17-2008 02:28 AM |
| FXなんでもかんでも・・・All you need is TREND!(仮題) | This thread | Refback | 01-16-2008 12:34 PM |
| 悋擧愕拆惘惠悋 愕惆惆 !!! - 惶忰 15 - Sarmaye Forums | This thread | Refback | 01-09-2008 12:03 PM |
| 悋擧愕拆惘惠悋 愕惆惆 !!! - 惶忰 15 - Sarmaye Forums | This thread | Refback | 01-07-2008 09:33 PM |
| 悋擧愕拆惘惠悋 愕惆 惆 !!! - 惶忰 15 - Sarmaye Forums | This thread | Refback | 12-29-2007 05:07 PM |
| 悋擧愕拆惘惠悋 愕惆 惆 !!! - 惶忰 15 - Sarmaye Forums | This thread | Refback | 12-29-2007 01:28 PM |
| shez_78's bookmarks tagged with | This thread | Refback | 12-27-2007 11:50 AM |
| Long Term Smooching Method - Page 2 - FXOpen Forex Forum | Forex review | Trading methods | Education | Analytics | This thread | Refback | 12-11-2007 02:12 AM |
| Long Term Smooching Method - Page 2 - FXOpen Forex Forum | Forex review | Trading methods | Education | Analytics | This thread | Refback | 12-10-2007 11:46 PM |
| Forex TSD| Metatrader Indicators and Experts Advisors | This thread | Refback | 11-09-2007 09:11 PM |