MARKING A PRICE
-
Is there a way or block that can determine the highest, lowest, or median price over a given range?
Like: Lowest price over past 6 bars.
Basically I'm trying to develop a system that creates a stop loss and target depending on how many pips back a particular trend started.
-
If you are in "Condition", look somewhere in "Market properties" - https://fxdreema.com/demo/mt4-trace-multiple Only Highest and Lowest prices are available here.
As an indicator this is known as Donchian Channel -
Will this use absolute value if we choose "Custom pips".
FOR BUY: For example the ea I'm working on determines the stop loss from the lowest within the last 5 candles. That's easy enough.
FOR BUY: For whatever that distance is (in pips) the stop-loss is (calculated from the lowest within the last 5 candles) I want that to be the same number of pips for take-profit moving forward.
So if I choose "Custom pips" lowest point within the last 5 candles, will it just apply that pip value for the take profit? Or will it apply that lowest price for the number of pips (which would close the trade instantly)?
In other words the distance of the stop loss is equal to the distance of the take profit from the trade. But the stop loss changes depending on the lowest within the last 5 candles (I would prefer the lowest 'close' within the last 5 candles but I don't see that option).
If you need to see the ea, it is the one with the cheesy name: BOLLINGER ROCKET 1-0
-
Try this - https://fxdreema.com/shared/FbPnl5L7
This creates Buy trade with SL = Lowest price of the last 10 candles and TP is calculates as the same distance. I want to get the difference between Bid and the Lowest price, but because I selected the Lowest price and I want to include the Bid price in the Adjust field, I use this formula to invert the calculation: *-1)+Bid
Bid is predefined variable in MQL4. MetaTrader puts the value of Bid on every tick. By the way there is no such variable for MQL4. Why Bid... because candles are built out of Bid prices.
But note that this project is dangerous! Put it to test and you will see why. Before going to Buy, the difference between Bid and the Lowest value must be checked.
You can also use Variables and calculate these values in a different way
I just wanted to show you this example that uses no extra blocks for calculations. -
So for Take Profit, even though you chose "Lowest Candle" it still "knows" to just use that for the distance in pips and only close after the price has moved into that far into profit. Did I get that right?
-
I see. So the calculation account for the Positive distance (for buy).
-
I forgot that in the settings for Take Profit there is also "% of Stop Loss". Try this
