Lukeye Posted October 3, 2009 Report Share Posted October 3, 2009 Re: Building your own EA G/08. Has anyone else found that back-testing on the weekends yields a different result? Possibly, I am just going nuts for the last 3 weekends! LOL Same here I am just going nuts for the last 3 weekends! Quote Link to comment Share on other sites More sharing options...
Rio Posted October 3, 2009 Report Share Posted October 3, 2009 Re: Building your own EA G/08. Excellent.. did you try it and see how it goes? Haven't tested yet. So far this code will only pull out a stop loss when the indicator bars give a clear opposite trend signal.. however, I am not sure which is better yet.... a clear signal of the accelerator going the other way, or the accelerator losing it's signal positive to the trend and giving no direction. .... this will require some testing. it's very easy to modify the logic so that the stoplosses occur when flat acceleration is detected... simply change if(UseAcceleratorIndicator == 1 && miAccelerator > 0) to if(UseAcceleratorIndicator == 1 && miAccelerator >= 0) and from < to <= for the sell part.... that should make the dynamic stoploss more stringent Quote Link to comment Share on other sites More sharing options...
Lukeye Posted October 3, 2009 Report Share Posted October 3, 2009 Re: Building your own EA G/08. I need some help :D I fixed my error code 130 problem : for(j = 0; j < 2; j++) { _OrderMagicNumber = MN_Usual; if(j == 0) // STOP { if(type == _OP_BUY) { if(BuyStopLevel < 0) continue; _OrderType = OP_BUYSTOP; typedefer = _OP_BUYSTOP; typestr = "BUY STOP"; if(CurrentPrice < (CurrentFigure + BuyStopLevel * _Point)&& (CurrentPrice-(CurrentFigure + BuyStopLevel * _Point) >(MarketInfo(Symbol(),MODE_STOPLEVEL)))) //if(CurrentPrice < (CurrentFigure + BuyStopLevel * _Point)) //BuyStopLevel= 50 _OrderOpenPrice = CurrentFigure + BuyStopLevel * _Point; else _OrderOpenPrice = CurrentFigure + (100 + BuyStopLevel) * _Point; } But I still don't find a solution for the following (video by asgard): After a buystop order was deleted the next buystop will step down by xx points (follow the market). Quote Link to comment Share on other sites More sharing options...
asgard2 Posted October 3, 2009 Author Report Share Posted October 3, 2009 Re: Building your own EA G/08. But I still don't find a solution for the following (video by asgard): After a buystop order was deleted the next buystop will step down by xx points (follow the market). It doesn't step down exactly.. it just puts a buystop at 15 points above the current market price.. I just got to this in the last couple of days.. now I have it working on 4 digit broker.. You need to change these two things in particular in the code. if(CurrentPrice < (CurrentFigure + BuyStopLevel * _Point)) _OrderOpenPrice = CurrentFigure + BuyStopLevel * _Point; else _OrderOpenPrice = CurrentFigure + (10 + BuyStopLevel) * _Point; // changed the 100 to 10 for four digits } else { if(SellStopLevel < 0) continue; _OrderType = OP_SELLSTOP; typedefer = _OP_SELLSTOP; typestr = "SELL STOP"; if(CurrentPrice < (CurrentFigure - SellStopLevel * _Point)) // changed the + to a - _OrderOpenPrice = CurrentFigure - (10 - SellStopLevel) * _Point; // changed the 100 to 10 for four digits else _OrderOpenPrice = CurrentFigure - SellStopLevel * _Point; // changed the + to a - and this needs to be changed as well CurrentFigure = (MathFloor((CurrentPrice / _Point) / 10) * 10) * _Point; //changed the two values for four digit, from 100 to 10 Quote Link to comment Share on other sites More sharing options...
asgard2 Posted October 3, 2009 Author Report Share Posted October 3, 2009 Re: Building your own EA G/08. I need some help :D . you know, when you reply with code there is a code button up the top along with the other things you can do with your text.. if you hit that you can put your code inside the brackets Quote Link to comment Share on other sites More sharing options...
asgard2 Posted October 4, 2009 Author Report Share Posted October 4, 2009 Re: Building your own EA G/08. Here is a back test.. This is my test period. the Period is an uptrend... so it has way more longs than shorts. Finally got the thing to sell respectably and this is a four digit broker. :-bd Had a loss though.. need to fix buying on a buying on spike after a trailing stopout... will have that done asap. http://rapidshare.com/files/288382233/MasterForex_Real.rar if someone does not have the mql4 book.. I have put it here http://rapidshare.com/files/288407465/mql4bookenglish.chm It is the only one I can find that actually opens on either of my pc's.. so if you are have the same problem? Quote Link to comment Share on other sites More sharing options...
Lord_Sauron Posted October 4, 2009 Report Share Posted October 4, 2009 Re: Building your own EA G/08. congrats :) Quote Link to comment Share on other sites More sharing options...
Lukeye Posted October 4, 2009 Report Share Posted October 4, 2009 Re: Building your own EA G/08. Hi All, here is a backtest starting January 2009. I have no idea why modelling quality is that bad . h**p://deposit*files.com/de/files/9m0vm0fl0 Quote Link to comment Share on other sites More sharing options...
ezsi Posted October 5, 2009 Report Share Posted October 5, 2009 Re: Building your own EA G/08. Hi asgard2! Could you post some more backtest results for different intervals and longer periods? Quote Link to comment Share on other sites More sharing options...
asgard2 Posted October 6, 2009 Author Report Share Posted October 6, 2009 Re: Building your own EA G/08. Hi asgard2! Could you post some more backtest results for different intervals and longer periods? Can do this.. I am not doing it for before 2009 though.. who cares... Certainly not something I care about. ATM I am still sorting out the sell and hope to be able to add 30% to those results.. So, it will be a couple of days, the sell logic side is flawed. I am having hells own job getting it going.. so we will see. Quote Link to comment Share on other sites More sharing options...
Rio Posted October 6, 2009 Report Share Posted October 6, 2009 Re: Building your own EA G/08. Some of your code patches that you've pasted in this thread are fairly broken asgard. (the defer order timeout routine works until a successful trade is taken, and then after that it kills all limit and stop orders as soon as they are opened) Perhaps you have done this deliberately so we have to fix them... in any case I am managing 8-) Quote Link to comment Share on other sites More sharing options...
asgard2 Posted October 6, 2009 Author Report Share Posted October 6, 2009 Re: Building your own EA G/08. Some of your code patches that you've pasted in this thread are fairly broken asgard. (the defer order timeout routine works until a successful trade is taken, and then after that it kills all limit and stop orders as soon as they are opened) Perhaps you have done this deliberately so we have to fix them... in any case I am managing 8-) No.. I posted two lots of code I thought, one I wrote myself and one made from Greezly code.. either way it is not deliberate. I am not sure, you are right about that cause it is working for me. If you are following the way the video trades.. there should not be limit orders; so I wouldn't know about that. Didn't you say you were a coder? Anyway I am not.. I just go with what works. If it doesn't work.. I worry about it then. Anyway.. this is the code u should be using so try that.. see how it goes. Otherwise I have no answer other than you have the orders back to front.. it reads like a script and things are done in order. Also, there should only be two orders open at once and it should not reorder.. if( UseDeferOrderTimeout >0) //this piece of code deletes the order { total = OrdersTotal(); if(total>0) for(i = total - 1; i >= 0; i--) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType()==OP_SELLSTOP && OrderSymbol()==Symbol()) { if((TimeCurrent() - OrderOpenTime()) > StopResetMinutes * 60 ) { if(PrintComments) Print("Sell Stop Deleted."); OrderDelete(OrderTicket()); } } } } This peice of code.. is the time delay before it is allowed to order again. if ((type == _OP_BUY) && (MayOpenDeferOrder && NextBuyStop_Order_Minutes !=0)) { total = OrdersHistoryTotal(); for(e = total - 1; e >= 0; e--) { OrderSelect(e, SELECT_BY_POS,MODE_HISTORY); if(OrderSymbol() != Symbol()) continue; { if(((TimeCurrent() - OrderOpenTime())/60) < NextBuyStop_Order_Minutes) MayOpenDeferOrder = false; break; } } } If the code can be improved.. you might ask one of the people here that are far superior at coding than I am. Quote Link to comment Share on other sites More sharing options...
Lukeye Posted October 6, 2009 Report Share Posted October 6, 2009 Re: Building your own EA G/08. Hey Rio, My thinking was the same when I saw orders were deleted as soon as they are opened . Add this line if(PrintComments) Print("CountHighlowLimit close."); here : if(CountHighLowLimits > 0) { // óäàëÿåì âñå STOP îðäåðà, ðàñïîëîæåííûå â îïàñíûõ çîíàõ (BUY ñëèøêîì âûñîêî, SELL ñëèøêîì íèçêî) ............................ { if(PrintComments) Print("CountHighlowLimit close."); glDeleteAllDeferOrders(_OP_SELLSTOP, Symbol(), 0, iHL_High[k] - _iHL_LimitDistance * _Point); } } } and run your tests again. Maybe this helps. Quote Link to comment Share on other sites More sharing options...
Rio Posted October 6, 2009 Report Share Posted October 6, 2009 Re: Building your own EA G/08. Anyway.. this is the code u should be using so try that.. see how it goes. Otherwise I have no answer other than you have the orders back to front.. it reads like a script and things are done in order. Also, there should only be two orders open at once and it should not reorder.. Ahh! That's the code I eventually ended up creating myself. You have a block of DeleteAllDeferOrders at the beginning of this thread, but just like you, I changed the code to order select my way through each of the orders and yank them out individually if (UseDeferOrderTimeout == 1) { total = OrdersTotal(); for(i = total - 1; i >= 0; i--) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol() != Symbol()) continue; // skip trades that have nothing to do with our symbol if((OrderType() == OP_BUY) || (OrderType() == OP_SELL)) continue; if((TimeCurrent() - OrderOpenTime()) /60 >= StopResetMinutes) { if(OrderDelete(OrderTicket())) { if(PrintComments) Print("Pending order open longer than " , StopResetMinutes, " minutes\n"); } else { Print("Pending order delete failed\n"); } } } } Anyway, the code I have now produces a graph curve similar to the video asgard originally posted... except mine tends to stop out towards the end after doing so well before hand. Some extra tweaking required! Quote Link to comment Share on other sites More sharing options...
Rio Posted October 7, 2009 Report Share Posted October 7, 2009 Re: Building your own EA G/08. Hrm.... I'm noticing some issues with the results of the EA I've bult so far. The very first cancelled buystop on asgards video happens two bars after a spike... but on my version, it opens the buy on the same candle as the spike on the way down, which then catches on the way up before sliding off. Also, the trialing stop loss code is not working. Quote Link to comment Share on other sites More sharing options...
asgard2 Posted October 7, 2009 Author Report Share Posted October 7, 2009 Re: Building your own EA G/08. Hrm.... I'm noticing some issues with the results of the EA I've bult so far. The very first cancelled buystop on asgards video happens two bars after a spike... but on my version, it opens the buy on the same candle as the spike on the way down, which then catches on the way up before sliding off. Also, the trialing stop loss code is not working. I have don't trade rules.. here a a couple.. but they really need to be your own. I am a data comms engineer.. so think access list or firewall... they are the sort of rules I am talking. if(MayOpenDeferOrder) //Rules 1, 2 ,3 //Rule 1 { if((type == _OP_BUY) && (iOpen(NULL,PERIOD_H1,1) >= iClose(NULL,PERIOD_H1,1)) && (iClose(NULL,PERIOD_H1,1)-(priceTolerance*0.0001)) >= ((Ask+Bid)/2)) MayOpenDeferOrder = false;// This one works well } // 21.9.32:07 Rule 2 { if ((type == _OP_BUY) && (iHigh(NULL,PERIOD_M5,1)-(35*0.0001) >= iClose(NULL,PERIOD_M5,1)) && ((Ask+ 10* 0.0001) < iClose(NULL,PERIOD_M5,1))) MayOpenDeferOrder = false;// This one works well } if((MayOpenDeferOrder) && (DojieBail !=0) && (type == _OP_BUY))//Dojie Rules, Rule 3 { if (iOpen(NULL,PERIOD_H4,1) <= iClose(NULL,PERIOD_H4,1)) //3a { if ((iClose(NULL,PERIOD_H4,1)-iOpen(NULL,PERIOD_H4,1) <= 5 *0.0001) && ((High[iHighest(NULL,240,MODE_HIGH,10,0)] - Ask) < 45*0.0001)) MayOpenDeferOrder = false; } else if ((iOpen(NULL,PERIOD_H4,1) >= iClose(NULL,PERIOD_H4,1))) //3b { if ((iOpen(NULL,PERIOD_H4,1)-iClose(NULL,PERIOD_H4,1) <= 5 *0.0001) && ((High[iHighest(NULL,240,MODE_HIGH,10,0)] - Ask) < 45*0.0001)) MayOpenDeferOrder = false; } } So do you have information have you found that can help others? Quote Link to comment Share on other sites More sharing options...
asgard2 Posted October 7, 2009 Author Report Share Posted October 7, 2009 Re: Building your own EA G/08. Also, the trialing stop loss code is not working. here is an example of the type of stop loss I am talking about. It is not cut and paste code, you need to make it suit you for your own requirements. I say this because I would rather blow my account every few months and make a fortune in the middle.. others would rather be safe and earn much less in the middle.. It is your call and you must decide. int x1 = 120; int x2 = 30; int x3 = 55; int x4 = 100; int prevtime = 0; if (perceptron() < 0) { total = OrdersTotal(); for(i = total - 1; i >= 0; i--) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol() != Symbol()) continue; if((OrderType() == OP_BUY) { if((TimeCurrent() - OrderOpenTime()) > 60*0.0001) && ( // put your other conditions here "percentage of loss" etc )) { if(PrintComments) Print("Stop Loss."); glOrderClose(); } } } } double perceptron() { double w1 = x1 - 100; double w2 = x2 - 100; double w3 = x3 - 100; double w4 = x4 - 100; double a1 = iAC(Symbol(), 0, 0); double a2 = iAC(Symbol(), 0, 7); double a3 = iAC(Symbol(), 0, 14); double a4 = iAC(Symbol(), 0, 21); return(w1 * a1 + w2 * a2 + w3 * a3 + w4 * a4); } Quote Link to comment Share on other sites More sharing options...
asgard2 Posted October 8, 2009 Author Report Share Posted October 8, 2009 Re: Building your own EA G/08. Hi Rio Just to add something... You should not need (in theory) to use the stoploss and if the EA uses the stoploss it is because it should never have entered that position \ in the first place. If it did, then it has a clear signal and you need to delay any further purchase signals for x amount of time with a follow up delay code. One would hope it has corrected itself by then. This EA works on retracement, if you watch it trade, it will not buy on an uptrend, it wants to buy on a downtrend and visa/versa. The trading lane is what supposedly keeps it safe and it will not buy for x amount of time if the price falls below or goes above the trading lane boundary. The trading lane is not as dynamic as it needs to be. It needs modes.. ie uptrend 1 = ma(something) + ma(something else). Flat= ma(anotherMa)+(ma(confirmation)) downtrend = someother ma paramenters. I find 5 modes are good.. but here is an example. Then if uptrend, mode1 = channel is correct if downtrend mode2 = sell only. The GBP is difficult for shorts. If flat tp= something channel is correct but risk is increased scalp only. I will post a video, of the stoploss working.. so you get the idea.. God, I hate stoploss, I would rather have the logic perfect but it will never be the case. Quote Link to comment Share on other sites More sharing options...
Lukeye Posted October 9, 2009 Report Share Posted October 9, 2009 Re: Building your own EA G/08. Hi, can anyone translate this peace of code into plain english please ? // ïðîâåðêà HughLowLimit if(CountHighLowLimits > 0) { // óäàëÿåì âñå STOP îðäåðà, ðàñïîëîæåííûå â îïàñíûõ çîíàõ (BUY ñëèøêîì âûñîêî, SELL ñëèøêîì íèçêî) for(k = 0; k < CountHighLowLimits; k++) { switch(k) { case 0 : _iHL_LimitDistance = iHL_LimitDistance1; break; case 1 : _iHL_LimitDistance = iHL_LimitDistance2; break; default: continue; } if((Counts[_OP_BUYSTOP] != 0) && (iHL_Low[k] > 0) && (MaxPrices[_OP_BUYSTOP] >= (iHL_Low[k] + _iHL_LimitDistance * _Point))) { glDeleteAllDeferOrders(_OP_BUYSTOP, Symbol(), iHL_Low[k] + _iHL_LimitDistance * _Point, 0); } if((Counts[_OP_SELLSTOP] != 0) && (iHL_High[k] > 0) && (MinPrices[_OP_SELLSTOP] <= (iHL_High[k] - _iHL_LimitDistance * _Point))) { if(PrintComments) Print("CountHighlowLimit close."); glDeleteAllDeferOrders(_OP_SELLSTOP, Symbol(), 0, iHL_High[k] - _iHL_LimitDistance * _Point); } } } I ask because this one is the part which deletes stop orders the same minute they were opened. Quote Link to comment Share on other sites More sharing options...
asgard2 Posted October 10, 2009 Author Report Share Posted October 10, 2009 Re: Building your own EA G/08. Hi, can anyone translate this peace of code into plain english please ? I ask because this one is the part which deletes stop orders the same minute they were opened. Hi Lukeye take out the original code and replace it with this one... I will send you a copy of the translated EA as soon as I find it. The below code will fix that problem if( UseDeferOrderTimeout >0) //Reset Buystop { total = OrdersTotal(); if(total>0) for(i = total - 1; i >= 0; i--) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType()==OP_BUYSTOP && OrderSymbol()==Symbol()) { if((TimeCurrent() - OrderOpenTime()) > StopResetMinutes * 60 ) { if(PrintComments) Print("Sell Stop Deleted."); OrderDelete(OrderTicket()); } } } } Quote Link to comment Share on other sites More sharing options...
Rio Posted October 10, 2009 Report Share Posted October 10, 2009 Re: Building your own EA G/08. take out the original code and replace it with this one... I will send you a copy of the translated EA as soon as I find it. The below code will fix that problem We've already covered the defer order time out. Wouldn't it just be easier to disable the CHeckHighLowLimit? (set it to 0) Quote Link to comment Share on other sites More sharing options...
asgard2 Posted October 11, 2009 Author Report Share Posted October 11, 2009 Re: Building your own EA G/08. We've already covered the defer order time out. Wouldn't it just be easier to disable the CHeckHighLowLimit? (set it to 0) Mate, Personally, I am pretty sure I don't need your ideas however, I think it is time you contributed something for others, instead of telling them it is already covered. As far as the question Lukeye asked.. I do not have that block of code in my version (because I removed it a long time ago) so I did/could not answer. If it is any help.. I am prepared to cover anything many times. The thread is long and wading through it for detail does not mean you will see it. Now, for some more detail for anyone else that might be doing this. I mentioned modes before in a somewhat scant way.. however, the fact is it needs them to survive and each mode needs to be different. The different modes work on trend. some buy settings need to be tightened for a downtrend. (still having problems with sell). Which settings you tighten, will be trial and error. I imagine, it wont matter which EA is used, it will always be the case that it should use different settings for market changes. // this is just an example. If I had perfect code that never failed, I would post it for you. If (Trend1=true) ModeSurvive; //Anyone who has a foolproof trend identifier.. feel free to post it.. Now that is something I could use. if (ModeSurvive) { TakeProfitB = 200; timeVunerableB = 100; // closes the trade if the market goes nowhere. StopLossDelay = 60; //Sets time before next trade after trade is taken out by the trailing stop FromHourTrade = 12; // Start Trade Time ToHourTrade = 21; BuyTrailingStop = 100; } Here is a clue to increasing trades... for the record. I removed the Gepard Logic as a failed idea (I have plenty of them). //......Changing the iHL_LimitDistance1 increases trades also increases risk. It buys higher in the Market! extern double BuyDistance=240; extern double SellDistance=110; // HighLowLimit bool glCheckHighLowLimit(double _OrderOpenPrice, int type, string typestr) { int i, j, k, total; for(k = 0; k < CountHighLowLimits; k++) { switch(k) { case 0 : _iHL_LimitDistance = iHL_LimitDistance1; break; case 1 : _iHL_LimitDistance = iHL_LimitDistance2; break; default: continue; } if (type == _OP_BUY) iHL_LimitDistance1 = BuyDistance; //240;//-------------------------------------- --testing Works well if((type == _OP_BUY) && (iHL_Low[k] > 0) && (_OrderOpenPrice >= (iHL_Low[k] + _iHL_LimitDistance * _Point))) { return(false); } if (type == _OP_SELL) iHL_LimitDistance1 = SellDistance; //110;--------------------------------------------testing Works well if((type == _OP_SELL) && (iHL_High[k] > 0) && (_OrderOpenPrice <= (iHL_High[k] - _iHL_LimitDistance * _Point))) { return(false); } } return(true); } I am sure with some imagination, you could adjust the limit distance to be included in your modes. Quote Link to comment Share on other sites More sharing options...
asgard2 Posted October 11, 2009 Author Report Share Posted October 11, 2009 Re: Building your own EA G/08. . Here are a couple of set files for Greezly and some early test results This is where I started and the settings comparison might give some clues. http://rapidshare.com/files/291385439/Tests.rar For those people wanting to compare different versions, you can download total edit here and it has a file comparison feature in it. Personally, I am always getting lost with my changes so it may be of use to others. h**p://download.codertools.com/TotalEditStd_5_2_8_install_en.msi Quote Link to comment Share on other sites More sharing options...
metalriff Posted October 11, 2009 Report Share Posted October 11, 2009 Re: Building your own EA G/08. Great thread, great work guys. I don't have much of anything to offer but I am learning from this. Quote Link to comment Share on other sites More sharing options...
asgard2 Posted October 11, 2009 Author Report Share Posted October 11, 2009 Re: Building your own EA G/08. Here is the time vunerable code.. it closes only if break even and no trailing or stoploss is set. extern int timeVunerableB = 0; extern int timeVunerableS = 60; //----------------------------------------------------------------- if(timeVunerableB !=0) { total = OrdersTotal(); for(i = total - 1; i >= 0; i--) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol() != Symbol()) continue; if (((OrderType() == OP_BUY) && OrderStopLoss()==0) && ((OrderProfit() + 0.0003) > OrderOpenPrice())) { if (((TimeCurrent() - OrderOpenTime())/60 > timeVunerableB)&& (((High[iHighest(NULL,15,MODE_HIGH,4,0)]-OrderOpenPrice()) < 4*0.001))) { if(PrintComments) Print("InertiaProtection, closed trade!"); glOrderClose(); } } } } if(timeVunerableS !=0) { total = OrdersTotal(); for(i = total - 1; i >= 0; i--) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol() != Symbol()) continue; if (((OrderType() == OP_SELL) && OrderStopLoss()==0) && ((OrderProfit() + 0.0003) > OrderOpenPrice())) { if (((TimeCurrent() - OrderOpenTime())/60 > timeVunerableS)&& (((High[iHighest(NULL,15,MODE_HIGH,4,0)]-OrderOpenPrice()) < 4*0.001))) { if(PrintComments) Print("InertiaProtection, closed trade!"); glOrderClose(); } } } } 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.