konorti Posted January 14, 2010 Report Share Posted January 14, 2010 Does anybody has an EA for modifying the SL to previous swing high/low? I just want to trail my manual trades this way. Probably zigzag or fractal indi could be used. thanks Quote Link to comment Share on other sites More sharing options...
scarface Posted February 1, 2010 Report Share Posted February 1, 2010 Re: [REQ] EA for modifying SL to previous swing low/high Hi konorti, Good day, I'm not sure if I can do that or not, but I can try that if you like whenever I have time. what do you think?? sorry for the late reply. Please let me know whenever you can. Best wishes, Quote a New Year 2011 has come, and the challenge has just started 8-) Link to comment Share on other sites More sharing options...
Starting Posted February 1, 2010 Report Share Posted February 1, 2010 Re: [REQ] EA for modifying SL to previous swing low/high Does anybody has an EA for modifying the SL to previous swing high/low? I just want to trail my manual trades this way. Probably zigzag or fractal indi could be used. thanks Mate, Everything (I believe) you need to know on trailing with code samples (trailing by last swings, fractals etc.) is here: http://codebase.mql4.com/ru/1101 Use Google Translator, it's all written by Russian in Russian, no English version. Have a great day! :) Quote Link to comment Share on other sites More sharing options...
⭐ birt Posted February 1, 2010 Report Share Posted February 1, 2010 Re: [REQ] EA for modifying SL to previous swing low/high To look for the swings in code, the easiest method I could think of was to check for the lack of a new high/low starting from the current bar and back. extern int LackOfNewPeak = 10; int CheckBars = 20; double previousPeak(int cmd) { int j = 0; int shift = 0; double peak = 0; if (cmd == OP_BUY) { peak = 2 * Ask; } while(j < LackOfNewPeak) { if (cmd == OP_BUY) { if (peak > iLow(Symbol(), timeframe, iLowest(Symbol(), timeframe, MODE_LOW, CheckBars, shift))) { peak = iLow(Symbol(), timeframe, iLowest(Symbol(), timeframe, MODE_LOW, CheckBars, shift)); j = 0; } else { j++; } } else if (cmd == OP_SELL) { if (peak < iHigh(Symbol(), timeframe, iHighest(Symbol(), timeframe, MODE_HIGH, CheckBars, shift))) { peak = iHigh(Symbol(), timeframe, iHighest(Symbol(), timeframe, MODE_HIGH, CheckBars, shift)); j = 0; } else { j++; } } shift++; } return(peak); } Say you need the previous low swing. The above code will return the lowest value that has the previous 10 bars higher than it. Note that the code is copied from an EA I wrote, pasted in the browser and modified here so it is entirely possible that it won't compile. If you pass it OP_BUY, it'll return the low swing, if you pass OP_SELL it'll return the high swing. Quote Link to comment Share on other sites More sharing options...
konorti Posted February 2, 2010 Author Report Share Posted February 2, 2010 Re: [REQ] EA for modifying SL to previous swing low/high I coded (taking the code from mq4 codebase link shared by Starting) and shared the EA in the next forum: http://www.indo-investasi.com/viewtopic.php?f=6&t=7784 thebfxc 1 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.