Friday 6 March 2015

Forex Trading P & F Chart AFL

Amibroker AFL: Amibroker AFL: Market Profile - V1.71 for Amibroker (AFL)







if(MarketID()==3)
{
GraphXSpace = 5;
SetChartBkColor(ParamColor("BackGroundColor",  colorCustom1));

gridColor = ParamColor("GridColor", ColorRGB( 37,64,90));
SetBarsRequired(100000,100000);


symbol = Name();
ccy2= StrRight(symbol,3);
Ccy1= StrLeft(symbol,3);

decimals=IIf(ccy2 == "JPY" OR Ccy1 =="XAG",100, IIf( Ccy1 == "XAU" , 10, 10000));
format = IIf (ccy2 == "JPY"|| Ccy1 == "XAU", 8.2, 8.4);

Box = Param("Box", 10, 1, 100, 1)/decimals;

Reverse = Param("Reverse",3, 1, 5, 1);

j = 0;

Lo[0] = Box * ceil(L[0]/Box) ;
Hi[0] = Lo[0] + box;
direction = 0;

for( i = 1; i < BarCount; i++ )
{  
    if(direction[j] == 0)
    {
        if(L[i] <= Lo[j] - Box)
        {
            Chg = Lo[j] - L[i];
            n= floor(Chg/box);
            Lo[j] = Lo[j] - n* box;
        }
        else
        {
            if(H[i] >= Lo[j] + Reverse*Box)
            {
                Chg = H[i] - Lo[j];
                n = floor(Chg/box);
                j++;
                direction[j] = 1;
                Hi[j] = Lo[j-1] + n* Box;
                Lo[j] = Lo[j-1] + Box;
            }
        }
    }
    else
    {
        if(H[i] >= Hi[j] + Box)
        {
            Chg = H[i] - Hi[j];
            n= floor(Chg/box);
            Hi[j] = Hi[j] + n*box;
        }
        else
        {
            if(L[i] <= Hi[j] - Reverse * Box )
            {
                Chg = Hi[j] - L[i];
                n= floor(Chg/box);
                j++;
                direction[j] = 0;
                Lo[j] = Hi[j-1] - n*box;
                Hi[j] = Hi[j-1] - Box;
              
            }
        }
    }
  
}
delta = BarCount - j -1;
direction = Ref(direction, - delta);



Hi = Ref(Hi, -delta) + Box/2;
Lo = Ref(Lo, -delta)- Box/2;
Cl = IIf(direction == 1, Hi, Lo);
Op = IIf(direction == 1, Cl - Box, Cl + Box);
PlotOHLC(Op, Hi, Lo, Cl,"", colorLightYellow , stylePointAndFigure|styleNoLabel);

Lastc = LastValue( C);
Last = Ref(Lastc, -(BarCount-1));
Plot( Last,"", colorRed,styleNoLine|styleDots, 0 , 0, 1);


/* Grid Construction*/
PlotGridLines = ParamToggle("PlotdGrid", "No|Yes");
if (PlotGridLines)
{
    SetChartOptions(1,0, 0);       

    end = BarCount-1;
    bar = BarIndex();
    begin =  Status("firstvisiblebar");
  
  
  
        ScreenHigh =LastValue( HHV(Hi, end - begin)) + box;
        ScreenLow =LastValue( LLV(Lo, end - begin))-box;
        shift = 5;
        gLine= LineArray( begin-shift, screenlow, end, screenLow, 0, 1);
        GridMin = screenLow;
        GridMax = screenhigh;
        step = round((GridMax - GridMin )/ box);
  
     Plot(LineArray( begin-shift, screenhigh, end, screenhigh, 0, 1),
"", gridColor, styleLine|styleNoLabel|styleNoRescale, 0, 0 ,shift);

        for (n =0; n <step ; n++)
        {
            Plot(  gLine + n*Box, "", gridColor, styleLine|styleNoLabel|styleNoRescale, 0, 0 ,shift);
            text = NumToStr( GridMin + n*Box+ 0.5*box, format);
            PlotText(text, end+2, GridMin + n*Box+ 0.25*box, colorLightYellow);
        }  
        VerticalGrid = IIf ( bar >= begin-1, IIf(frac(bar/2) ==0, screenHigh, screenLow), Null);
        Plot (VerticalGrid, "", gridColor, styleStaircase|styleNoLabel|styleNoRescale, 0,0, 1);
  
}
else
SetChartOptions(1,chartShowArrows|0);

Title  =
"Interval:   " + Interval(2) + "\n" +
"Box  :      " +  Box*decimals + "  pip \n" +
"ATR :      " +NumToStr(LastValue(ATR(20) *decimals), 1.0) + "  pip";
}

else
Title = "PF with Forex Settings is not Suitable for this market";

2 comments:

  1. Thanks for sharing the info, keep up the good work going.... I really enjoyed exploring your site. good resource... FXGM ZA review

    ReplyDelete
  2. Thanks for taking the time to discuss this, I feel strongly that love and read more on this topic. If possible, such as gain knowledge, would you mind updating your blog with additional information? It is very useful for me. 70trades

    ReplyDelete

Thanks