L11

Trader
Jan 5, 2018
11
4
14
52
Enivid,

First, I want to say this is a great open source version of the MP indicator and you're code is nice and clean...which is rare. Great work.

But I was wondering if you'd be willing to create a multi-session version of your MP indicator. What I mean is a version that allows for TPO profiles for multiple intraday sessions within a single calendar day. I know you have the minutes-shift as an input, but what I'm asking is whether you could create a version that allows the user to set the beginning and end time of the intraday session as well as allow for multiple sessions within each whole calendar day (I think 3 or 4 sessions is enough for each day). It may be best to fork a separate multi-session version of the indicator.

For an example of what I'm talking about, check out this indicator: https://www.mql5.com/en/market/product/9008

The idea behind this is that the user can do a TPO profile for each intraday session, such as an Asian/European/US session in forex pairs...and the "pit" session and overnight session for stock index CFDs. For example, if I trade US stock index CFDs, the CFD (just like a futures contract) has an overnight session as well as the session in which the "trading pit" is open in the cash market. Combining these in one 24-hour (or really 23-hour) TPO profile is not as helpful as having two separate profiles: one for the overnight session and one for the regular-trading-hour cash session. The same is true for forex trading, with each of the various global continental trading sessions. The idea behind it is that, just like the prior day’s session informs the current day’s session, the prior intraday session also informs the current intraday session. All of the information is useful.

I've checked your code and tried to make these changes, but your code essentially expects a 24-hour whole-day session and does not easily lend itself to allowing the user to set an arbitrary-length intraday sessions within one calendar day. It would be difficult to make this change…which is why I’m contacting you on your forum. It would also be nice to set the length of each TPO to either 15 mins or 30 mins, but that doesn’t really matter too much when using the “dots” or bars for the TPOs rather than letters for TPOs. I very much appreciate your use of bars that gradually change color later into the session rather than letters…your method is so much better, which is one of the reasons I was first drawn to this indicator. The visual appeal is nice, just like your code.

I guess I would prefer to have this in MQL4 but I could easily translate between the languages if you wanted to offload some of the grunt work on to me. I think you have a great foundation and this conceptual change would make a world of difference in the usefulness of the indicator. Plus, translating this to MQL5 allows American futures traders to use it too...in addition to forex and CFD traders. An MQL5 version could also give the option of switching between TPO profiles and true/real volume profiles (assuming the broker and exchange provides real volume, such AMP Futures in America). MQL4 of course only allows for TPO profiles.

Just to be clear, I would imagine (altho you may certainly have better ideas) such a multi-intraday-session indicator would require inputs for the start time and stop time (in whatever the chart time is) for each intraday session, as well as Boolean input to turn on/off each intraday session….exactly like the link above. This is why I think it would be better to fork the code out into a separate multi-session intraday indicator and keep the current version for whole-day/week/month TPO profiles separate from the multi-intraday-session version. You may also want to restrict its use to H1 or M30 timeframes plus any lower timeframe. If you’d like to discuss the code, let’s do that. I can be of service or not, that’s your call. I am not a professional coder, but I’ve been writing code as a hobby since high school many, many years ago. And I actually started writing MQL back when MT3 was around back in the early 2000s.

I think you have a great thing going here that you’ve been working on for several years, and adding multiple intraday sessions of arbitrary length is the clear next step for this indicator….and it would certainly be of a lot of use to any MT4/5 trader. I am certain many people would find such an open source indicator very useful. There is not another such indicator that is currently open source, but of course there are several closed source versions. Yours would be the first, I believe.


PS. …I also want to point out that it is not that I want this “for free.” I already own multiple closed source versions that are available on the MQL marketplace. I own several: https://www.mql5.com/en/market/product/14244, https://www.mql5.com/en/market/product/14288, https://www.mql5.com/en/market/product/3033, https://www.mql5.com/en/market/product/11796. The closed source versions are not expensive. Rather, my goal is to have an open source version for the community to grow and expand upon. That’s why I’m contacting you about this…just to share ideas out in the open.

PPS. If I’m wrong, and there is an open source version out there that does do this, please point me to it. Though, I do appreciate the visuals of yours so all I’d end up doing is trying to merge that functionality with the visual style of yours anyway.
 
Last edited:
  • 👍
Reactions: jagg and Enivid

L11

Trader
Jan 5, 2018
11
4
14
52
Thanks for the suggestion. That is an interesting idea. I will definitely consider coding it when I figure out the best way to do it.
Awesome! I appreciate you taking the time to consider it. Cheers!
 

L11

Trader
Jan 5, 2018
11
4
14
52
Any progress made on including functionality for multiple intraday sessions in this MP indicator? Cheers mate.
 

L11

Trader
Jan 5, 2018
11
4
14
52
1
 

Attachments

  • AECA10D1-EA16-41EB-A1A2-6A8F947913BD-1349-0000014E4AD4468C.jpeg
    AECA10D1-EA16-41EB-A1A2-6A8F947913BD-1349-0000014E4AD4468C.jpeg
    90.3 KB · Views: 28

Enivid

Administrator
Staff member
Nov 30, 2008
18,532
1,355
144
Odesa
www.earnforex.com
Intraday sessions have been implemented in version 1.07. Set Session input parameter to Intraday and configure the available four intraday sessions as you like:

mp-inputs.png

You will get something like this:

market-profile-intraday.png
Apart from the intraday session support, the new version features new color schemes and some minor improvements.

It is quite likely that it also introduces quite a few new bugs and glitches, so any bug reports are appreciated.
 
  • 👍
Reactions: jagg and L11

L11

Trader
Jan 5, 2018
11
4
14
52
This is great, I just saw it (I thought I had it where the forum would alert me when a new post was posted here, but I guess I didn't).

I will test out this week and try to suss out any bugs.

Thanks for your hard work !!
 

L11

Trader
Jan 5, 2018
11
4
14
52
Here are my thoughts / bug report for the MQL4 version only . . .

  • there seems to be an inherent problem with color gradients and the time-length of a given session. That is, a color gradient and offset that is good for a 1 to 2 hour intraday session, may not be good for a 2-6 hour intraday session, which may not be good for a 6-12 hour intraday session, which may not be good for a daily or weekly session. The "best" offset will depend on the length of the session. There may be no perfect solution to this for all end users unless you built in a lot of if-logic into the switch-statement in PutDot(). For example, take a look at this code in the PutDot()....but I understand if you don't like this solution.
    Code:
    case Red_to_Green:
         colour = clrFireBrick;
         if(Session == Intraday){
            offset1 = 0x000002;
            offset2 = 0x100;
            }
        else{
            offset1 = 0x000002;
            offset2 = 0x000400;
            }

  • I attached a pic called Cyan_to_Magenta.png to show how this color_scheme seems to have its offsets mis-valued for INTRADAY but not DAILY profile sessions. The pic does not show a DAILY profile, but shows the same INTRADAY profile with the offsets you originally had plus a "fix" with offsets that I tailored to the time-length of the profile for my purposes. Again, not all offsets will be ideal for all profile session time-lengths. In the above code, where I put a simple if-statement, you could also add logic to use different offsets depending on the length of the intraday session. I'm not sure this is super necessary or helpful for 90% of the users, but it is perhaps something to consider. Maybe. One of the big strengths of your code is its visual appeal. I think non-coders will gravitate to strong visual appeal, whereas I can just adjust the hexadecimal offsets to whatever I happen to want/need. However, if joe trader sees colors that loop back around, he's not going to understand what's happening and will likely walk away from this indicator.

  • on the MQL4 version, when there are several price levels that all equal the POC (i.e., several price levels have the same max number of TPOs), it appears the script has trouble deciding which value to use as the POC. I have no idea what the solution to this, and I also do not know what the "correct" POC should even be in that type of situation. But I attached a pic called POCs.png to show you.

  • for a few different reasons (e.g., performance increase and granularity adjustment), I removed the logic that set the onetick variable to always be exactly one pip and then added an input that allows the user to set a multiplier for the "onetick" variable. In other words, if the onetick variable would normally equal 0.01 for USDJPY (i.e., a tenth of a true pip) and TickValueMultiplier was set to 10....onetick would now equal 0.1 rather than 0.01. This allows the user to adjust the price granularity of the market profile to whatever he/she wants. I do this because it affects the accuracy or usability of the market profile with non-forex instruments. With forex only, it's not such a big deal. However, other traders may believe differently than I do. I think a value of 5 is good for stock index CFDs because you thin out the number of objects on the chart and you don't lose too much price granularity in the market profile. On a forex instrument, a value of 5 essentially means a half pip...so each price level in the profile covers a half pip. To explain the code...I deleted the DigitsM variable and the code defining what DigitsM equals, then have the following code where TickValueMultiplier is an input int type variable:
    Code:
    onetick = NormalizeDouble( (1*TickValueMultiplier) / (MathPow(10, Digits)), Digits);

  • This is personal idea on how to deal with Sundays, you could easily think differently....imo, I think that only intraday session # 4 should be displayed on Sundays on the chart. This is a bigger deal for folks who trade non-forex; I think a lot of forex brokers set the server time such that Sunday is not displayed on the chart. The reason I think intraday session 4 should be displayed on Sundays is that I often have my intraday session # 4 start at 21:00 or 22:00 or 23:00 and have it go until somewhere between 11:00 and 14:30 the following day. Therefore, intraday session 4 spans (or crosses over) the midnight hour for me. Iow, I'm using it more as a part of the Monday's overnight profile (if that makes sense). I'm in favor of not displaying any other intraday profile on the Sunday portions of charts. But there may be a better way of handling this, than what I describe here. Alternatively, maybe show only intraday session # 1 on Sundays. ...or...?

  • one thought to help performance when there are multiple charts running intraday profiles during heavy market hours...perhaps have the indicator run on a timer so that it update only every X secs. I moved all the code that is inside OnCalculate() into OnTimer(), and then call OnTime() at the very end of the OnInit() function so that it draws the profile when first attached to the chart. The thing is, though, I had to comment out some code that referred to the rates_total and prev_calculated variables, because these variables are not received by the OnTimer(). This created some problems with failing to draw the profiles, some times. To remedy this and keep that logic I commented out, you could create your own global variables to mimic the rates_total and prev_calculated....and by global variables, I mean variables scoped outside of all the functions in the script. I do NOT mean global variables that get by hitting F3 in the client terminal (or going to the tools menu). I do not believe (and another trader could easily disagree) the profile needs to be updated with every single tick. I think it is sufficient to update every 60 or 30 secs, or even every 5 secs would be fine I think. The benefit is that it makes the indicator more performant. Sometimes ticks will come in quicker than the OnCalculate() function can finish. It's a bigger deal on MT4 (which lacks multithreading) when you have three different stock index symbols with the profile running during the stock market open...for example.
Things I like a lot
  • the additional color schemes for profiles
  • you're a great commenter of code and that is uber helpful
 

Attachments

  • POCs.png
    POCs.png
    61.2 KB · Views: 36
  • Cyan_to_Magenta.png
    Cyan_to_Magenta.png
    93.1 KB · Views: 33
Last edited:
  • 👍
Reactions: jagg and Enivid

L11

Trader
Jan 5, 2018
11
4
14
52
As to the MQL5 version.........I haven't had as much time with this one but I did notice one glaring problem and I do not beleive any code changes I made caused this problem in MT5.
  • the MQL5 version somehow changes all my candles sticks to be the same color, and it does so on every chart that is open, not just the chart the indicator is plotted on. In other words, both "bull" and "bear" candles have the same color. Then, when I goto chart properties to fix the color, the "fix" only works until the next time the indicator is updated with a new incoming tick. Further, when I close the chart with the Profile indicator, the other charts go back to normal coloration. Idk what is causing this. If you cannot reproduce it, then perhaps the problem is on my end.
 

L11

Trader
Jan 5, 2018
11
4
14
52
btw, meant to add that there's no way I could have translated this code from mql4 to mql5 or vice versa. this code you've written is really outstanding work and is crazy complicated. I just remembered that today and wanted to mention it. you've given a lot to the community with this work...a lot.