Swing high of indicator strategy
-
Hello everyone, How do I create such a strategy, buy when bid price crosses previous swing high of a moving average and sell when price crosses previous swing low of moving average? Stop loss would be the most recent opposite swing high or low
N/B: I don't know how to use variables or conditions
-
Start with the cross: no trade block - condition block (market properties x> ma) - place a buy to test on backtest
-
The problem is defining a 'swing'. Humans can see them easuly, but bots are dumb. They need crystal clear conditions. Unless you get them before, you can be frustrated with many trials and errors.
-
 -
That's a good first approach. Now wee need additional criteria to make the EA understand that those high and low are those you want and not intermediate relative high/lows in between those you want. So the question would be, are there any possible intermediate high/lows betwee those you want or do you consider the last high and the last low all the time only?
-
yes I only consider the last/recent high and low as the swing high
-
If a new swing occurs then the previous one is disregarded
-
Yes, but how can you distinguish that's the last recent low, for example? How can the bot know it is a major low and not an intermediate low? What I mean is, how many candles in the past are supposed to be looked at in order to identify it as a legit low? Do you see the problem?
-
maximum number of candles to look back should be 10
-
Ok. Now we can begin. Do you have any initial fxDreema structure to begin with?
-
none..I don't have much experience here
-
Ok. Let's move step by step. You will need a loop searching for the closest swing high/low on the MA loking bak to 10 candles. However, I have a previous question. What if there is nor such swing in 10 candles back? What if the last 10 candles are showing a continuous up/down of the MA value?