Thread: Market Profile
View Single Post
  #14 (permalink)  
Old 07-19-2006, 01:04 PM
apfx's Avatar
apfx apfx is offline
Junior Member
 
Join Date: Dec 2005
Posts: 18
apfx is on a distinguished road
Market Profile

This is the code in Amibroker Formula Languange it shouldn't be very difficult to translate into MQL4.

//Market Profile

//===========================

Den = Param("Density", 40, 10, 100, 10);
ShowMP = ParamToggle("Show MP", "No|Yes");
ShowVP = ParamToggle("Show VP", "No|Yes");
StyleMP = ParamStyle("style MP", styleLine, maskAll);
StyleVP = ParamStyle("style VP", styleLine, maskAll);

//===========================
BarsInDay = BarsSince(Day() != Ref(Day(), -1)) + 1;

//===========================
NewDay = Day() != Ref(Day(), 1) OR Cum(1) == BarCount;

//===========================
Bot = TimeFrameGetPrice("L", inDaily, 0);
Top = TimeFrameGetPrice("H", inDaily, 0);
Vol = TimeFrameGetPrice("V", inDaily, 0);

//===========================

Range = Highest(Top-Bot);
Box = Range/Den;
VolumeUnit = Vol/BarsInDay;

for (k = 0; k < Den; k++) // loop through each line (price) starting at the Lowest price
{
Line = Bot + k*Box;
detect = Line >= L & Line <= H;

if(ShowMP == True)
{
CountMPString = IIf(NewDay, Sum(detect, BarsInDay), 0);
CountMPString = Ref(ValueWhen(NewDay, CountMPString, 0),-1);
MpLine = IIf(CountMPString >= BarsInDay, Line, Null);

Plot(MPLine, "", colorRed, styleMP);
}

if(ShowVP == True)
{
CountVPString = IIf(NewDay, um(detect*V,arsInDay)/VolumeUnit,0);
CountVPString = Ref(ValueWhen(NewDay, CountVPString, 0), -1);
VpLine = IIf(CountVPString >= BarsInDay, Line + Box/4, Null);

Plot(VPLine, "", colorBlue, styleVP);
}
}

Last edited by apfx; 07-19-2006 at 01:11 PM.
Reply With Quote