| New signals service! | |
|
|||||||
| 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 | Thread Tools | Display Modes |
|
|||
|
If it was me, I'd probably delete the whole function and put
Code:
lotMM=Lots; to post code, use "[" "code" "] " but without the quotations. Had to do it like that or it would think I wanted to use it. Last edited by Morpheus; 06-15-2006 at 10:15 PM. |
|
||||
|
it's not workin it tells me that I have exceeded the character limit. so the [] thing,...I must not be doing it right. could you explain it again more specifically?
this is what i'm doing... [ //+------------------------------------------------------------------+ //| EMA_CROSS_2.mq4 | //| Coders Guru | //| http://www.forex-tsd.com | //+------------------------------------------------------------------+ // ultima versiune cu micro lots! H1 si D1 #property copyright "Coders Guru" #property link "http://www.forex-tsd.com" //---- Trades limits extern double TakeProfit = 15, TrailingStop = 20, StopLoss = 20; extern bool UseStopLoss = false; //---- EMAs paris extern int ShortEma = 2, LongEma = 5; //---- Crossing options extern bool immediate_trade = true, //Open trades immediately or wait for cross. reversal = false, //Use the originally reversal crossing method or not ConfirmedOnEntry = false; //---- Money Management extern double Lots = 1; extern bool MM = true, //Use Money Management or not AccountIsMicro = true; //Use Micro-Account or not extern int Risk = 10; //10% extern int MAGICMA = 20060301; extern bool Show_Settings = true; //---- Global varaibles static int TimeFrame = 0; datetime CheckValueTime; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { if(Show_Settings) Print_Details(); else Comment(""); return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { TimeFrame=Period(); //Prevent counting the cross while the user changing the timeframe return(0); } bool isNewSumbol(string current_symbol) { //loop through all the opened order and compare the symbols int total = OrdersTotal(); for(int cnt = 0 ; cnt < total ; cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); string selected_symbol = OrderSymbol(); if (current_symbol == selected_symbol) return (False); } return (True); } int Crossed (double line1 , double line2) { static int last_direction = 0; static int current_direction = 0; if(TimeFrame!=Period()) { TimeFrame=Period(); return (0); } if(line1>line2)current_direction = 1; //up if(line1<line2)current_direction = 2; //down if(immediate_trade==false) { if(last_direction == 0) //first use { last_direction = current_direction; return(0); } } if(current_direction != last_direction) //changed { last_direction = current_direction; return (last_direction); } else { return (0); //not changed } } //--- Bassed on Alex idea! More ideas are coming double LotSize() { double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100; if(AccountIsMicro==false) //normal account { if (lotMM < 0.1) lotMM = Lots; if ((lotMM > 0.5) && (lotMM < 1)) lotMM=0.5; if (lotMM > 1.0) lotMM = MathCeil(lotMM); if (lotMM > 100) lotMM = 100; } else //micro account { if (lotMM < 0.01) lotMM = Lots; if (lotMM > 1.0) lotMM = MathCeil(lotMM); if (lotMM > 100) lotMM = 100; } return (lotMM); } string BoolToStr ( bool value) { if(value) return ("True"); else return ("False"); } void Print_Details() { string sComment = ""; string sp = "----------------------------------------\n"; string NL = "\n"; sComment = sp; sComment = sComment + "TakeProfit=" + DoubleToStr(TakeProfit,0) + " | "; sComment = sComment + "TrailingStop=" + DoubleToStr(TrailingStop,0) + " | "; sComment = sComment + "StopLoss=" + DoubleToStr(StopLoss,0) + " | "; sComment = sComment + "UseStopLoss=" + BoolToStr(UseStopLoss) + NL; sComment = sComment + sp; sComment = sComment + "immediate_trade=" + BoolToStr(immediate_trade) + " | "; sComment = sComment + "reversal=" + BoolToStr(reversal) + NL; sComment = sComment + sp; sComment = sComment + "Lots=" + DoubleToStr(Lots,0) + " | "; sComment = sComment + "MM=" + BoolToStr(MM) + " | "; sComment = sComment + "Risk=" + DoubleToStr(Risk,0) + "%" + NL; sComment = sComment + sp; Comment(sComment); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int cnt, ticket, total; double SEma, LEma, SEmaLAST, LEmaLAST; string comment = ""; if(reversal==true) comment = "EMA_CROSS_Counter-Trend"; if(reversal==false) comment = "EMA_CROSS_Trend-Following"; if(Bars<100) { Print("bars less than 100"); return(0); } if(TakeProfit<10) { Print("TakeProfit less than 10"); return(0); // check TakeProfit } static int isCrossed = 0; if(ConfirmedOnEntry) { if(CheckValueTime==iTime(NULL,TimeFrame,0)) return(0); else CheckValueTime = iTime(NULL,TimeFrame,0); SEma = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1); LEma = iMA(NULL,0,LongEma ,0,MODE_EMA,PRICE_CLOSE,1); SEmaLAST = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,2); LEmaLAST = iMA(NULL,0,LongEma ,0,MODE_EMA,PRICE_CLOSE,2); if(SEmaLAST<LEmaLAST && SEma>LEma) isCrossed = 1; if(SEmaLAST>LEmaLAST && SEma<LEma) isCrossed = 2; } else { SEma = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,0); LEma = iMA(NULL,0,LongEma ,0,MODE_EMA,PRICE_CLOSE,0); isCrossed = Crossed (LEma,SEma); } if(reversal==false) { if(isCrossed==1) isCrossed = 2; else if(isCrossed==2) isCrossed = 1; } if(MM==true) Lots = LotSize(); //Adjust the lot size total = OrdersTotal(); // TRAILING STOP for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); ..... ] |
|
|||
|
I've uploaded a modification of his EA. This one uses fixed lots. No moneymanagement whatsoever. It appears to still backtest well. Whatever you want the lots to be, just enter it in the code where it says "LOts = " and it will be the same lots throughout and then when you want to change it, go in an change it same way again. Try it. It appears to me, though, that the money management in this EA is kind of important since it's like a hedging strategy so use this one at your own risk.
You could also just increase the risk % . It looks like you have it at 10 % . Increase to 40 % . Or something and see what that does. It should increase your lots. Last edited by Morpheus; 06-15-2006 at 11:38 PM. |
|
||||
|
i'm sorry the obvious has escaped me once again...
everything I wanted to fix isn't in fact broken I just didn't look at the bottom of the inputs window when attaching it to the chart... all i have to do is change the lot parameter when i use it and that handles it. i didn't use the slider bar on the inputs window and didn't see all the additional parameters which i could change...that's WHY the program was built with the option!!! I still havn't figured out how to do the post code in window thing either... fyi I'm going live with this now using a small lot size to see if it performs as expected and if so I'll increase the lot size as I feel more confident with it. sometimes I'm amazed by the size of my own skitomas. Last edited by Aaragorn; 06-16-2006 at 12:21 AM. |
|
||||
|
all I know is that it executes on the cross signal of the two moving averages.
the fact that it hedges with an opposing position which I bets on closing on the retracement is a hedging strategy. I am also running this in demo and have run numerous strategy tests on various settings. It appears to run as well in the 5m as the 15m TF. I think the key to making this really work is scale/stepping the opposing position with some kind of probability curve. If you put a 2period EMA and a 5period EMA on a chart and watch them cross that's what is driving the signal as I have it configured. The other factor is the TP. According to my tests the 15TP gives the greatest net profit. |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calling All Masterminds, Programmers, And Coders!!! | FX-Hedger | Indicators - Metatrader 4 | 65 | 01-28-2008 04:58 PM |
| HMA - Calling All Programmers!! | secxces | Indicators - Metatrader 4 | 58 | 01-26-2008 09:19 PM |
| Calling All Coders And Specialists | jwoger | Indicators - Metatrader 4 | 11 | 08-01-2006 05:19 AM |
| Custom Chart Request-calling all programmers | Aaragorn | Metatrader 4 | 6 | 06-16-2006 12:18 AM |
| Coders Guru Please Help Us | sisi | Metatrader 4 | 1 | 06-08-2006 01:10 PM |