Jump to content

⤴️-Paid Ad- Check advertising disclaimer here. Add your banner here.🔥

[REQ] EA for modifying SL to previous swing low/high


Recommended Posts

Posted

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

  • 3 weeks later...
Posted

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,

a New Year 2011 has come, and the challenge has just started 8-)
Posted

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! :)

Posted

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.

Posted

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


⤴️-Paid Ad- Check advertising disclaimer here. Add your banner here.🔥

×
×
  • Create New...