Need 50% of range to create variable price
-
I am trying to create a buy line/ sell line at 50% of the current High of day to low or current Low of day to high of day depending on if I am looking for a short or long. I can't get MT5 to recognize this 50% level. What is wrong with the way I structured it?
-
Maybe you are over thinking this? The mid price of the day candle is the 50% value, so may find this the best way to work with it.

-
@jstap To use that, I need the high/low of the 9:30-16:00 timeframe. It can't be the DAILY timeframe. How would I establish that time range as a variable?
-
Ok so the mid of the range in the day, you can use a formula block to get this:

-
@jstap Thanks. I gave that a try and I wanted to add a draw line at that level to make sure it was working but the line doesn't seem to show up. Here are the updated adjustments. I turned everything off that isn't relevant.
-
You can draw lines on those places like this:
https://fxdreema.com/shared/8Hr6vlcrd
-
-
just copy what I did, it shows it works and how to do it
-
@jstap Ok. It appears to draw the lines but it seems to draw 50% of the 9:30-10AM ORB. It isn't drawing the line at 50% of the HOD/LOD range.

-
It seems to make sense to me.
lowest at 10:45 so >9:00 and <16:00

Highest at 10:15 so >9:00 and <16:00

And the blue line being drawn in the middle, may be that backtester had to load enough data to display correctly.
-
@jstap I think I got it working. I will let you know if I run into an issue. Thank you.
-
Your welcome
-
@jstap So I got the 50% line to draw. Now I am trying to execute the following.
Buy at 50% line after price closes with a 30m candle above the the 30M opening high from 9:30-10AM. Expiration of any new trade at 16:00. Only execute 1 trade per day and it's based on the 1st 30min close above the 30min ORB high or below the 30M ORB low. That sets the direction for todays trade.
When I run it, I see price come back to the 50% line but it is not taking trades at it .

-
@jstap I also see the following on the backtest which has 100k in the sim account. 'No Money'. Then trades aren't executing even if they are within the expiration time.

-
That picture doesn't show the lot size it was trying to place, I would set to 0.01 while testing so I know this is not the problem. I would use flags (as a gate) so when condition 1 happens (a candle closing) the flag is set, then the x over/under the line checks the flag and places the trade, switch the flag off when a trade is placed or condition is no longer valid. To test this set up a test project, that draws a named line on init and every time it crosses add 1 to a variable, and view it in a comment, this way you know if it should work when adding to your main project.
-
@jstap I am a bit lost on the gates/flags suggestion. Is this picture where the lots are adjusted? It is a 2 decimal place NQ US index.

-
Watch on backtest and view what has been done, that picture is not lots, it's pips/points, this won't affect lots, except for if the EA views a pip/point differently resulting in a bigger/smaller distance, leave it as standard, drag your cross hare (ctrl f on backtest) snd use that number in any place pips are needed.
