Pivot Price Chart

rajputz

Well-Known Member
#1
I work on my Turtles method for trading indian stock markets. Simmilarly i want to test it on MT4 also. Can some body provide me price chart the same way for MT4. It marks level of Pivot High and Pivot Low. I am Posting a Chart on amibroker with Code. If some body can write it the same way for Metatrader 4 for forex, i will be extremely Helpful.

Code is: -

Code:
_SECTION_BEGIN("Simple Pivot based Trading System");

// User defined parameters.

GraphXSpace = 10; //defines how much extra space should be added above and below graph line (in percent).

dist = 0.25*ATR(10); 
Capital=Param("Total capital",100000,10000,1000000,1000);
drawdown=Param("Max. loss per trade as % of Capital", 1.0,0.5,25.0,0.1);
room=Param("Room for S/L as % of Pivot value",0.001,0.001,0.02,0.001);

SetChartBkColor(ParamColor("Panel color ",colorBlack)); 
// Now calculate pivots. 

PH= ValueWhen(
(Ref(H,-2) > Ref(H, -4)) AND
(Ref(H,-2) > Ref(H, -3)) AND
(Ref(H,-2) > Ref(H, -1)) AND
(Ref(H,-2) > H), Ref(H,-2));

PL= ValueWhen(
(Ref(L,-2) <= Ref(L, -4)) AND
(Ref(L,-2) <= Ref(L, -3)) AND
(Ref(L,-2) <= Ref(L, -1)) AND
(Ref(L,-2) <= L), Ref(L,-2));

// filter lines

phfilter=PH+(room*PH);
plfilter=PL-(room*PL);

//Uncomment following code if you wish to see the pivot lines.
//Plot(Ref(PH,2), "UpPivot", ParamColor("UpPivot Color",colorRed), styleDashed);
//Plot(Ref(PL,2), "DownPivot",ParamColor("DownPivot Color",colorGreen), styleDashed);

Plot(Ref(Phfilter,2), "Upfilter", ParamColor("upfilter Color",colorBlue), styleLine);
Plot(Ref(Plfilter,2), "Downfilter",ParamColor("dnfilter Color",colorOrange), styleLine);


//Plot(Ref(UpFractal,2), "Up Fractal", ParamColor("Up Fractal Color",colorRed),8);
//Plot(Ref(DownFractal,2), "Down Fractal",ParamColor("Down Fractal Color",colorGreen),8);



/* 
for (a=4;a<BarCount;a++)
{
if ((H[a-2] >= H[a-4]) AND
(H[a-2] >= H[a-3]) AND
(H[a-2] >= H[a-1]) AND
(H[a-2] >= H[a]))
PlotText("PH \n"+H[a-2], a-2, H[a-2], colorGreen);

if ((L[a-2] <= L[a-4]) AND
(L[a-2] <= L[a-3]) AND
(L[a-2] <= L[a-1]) AND
(L[a-2] <= L[a]))
PlotText("PL \n"+L[a-2], a-2, L[a-2]-dist[a-2], colorRed);
}
*/
//Condition for buy : Enter when Close crosses latest pivot high.
Buy = C> (PH+(room*PH));

initialStopBuy=Ref(PL,2)-(Ref(PL,2)*room/100);
trailStopBuy=IIf(C>PH,Ref(initialStopBuy,-1),initialStopBuy);

newStopBuy=trailStopBuy;

BuyLimitCapital=int(Capital/C);
SLbuy=round(C-initialStopBuy);
BuyLimitSL=int((Capital*drawdown)/(100*SLbuy));

//Condition for sell : Exit when previous pivot low is cracked.
Sell = C< (PL-(room*PL));

Buy = ExRem(Buy,Sell);
Sell= ExRem(Sell,Buy);

//Short = Sell;
//Cover = Buy;

//Short=ExRem(Short,Cover);
//Cover=ExRem(Cover,Short);

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ),0, IIf( Buy, Low, High ) );


_SECTION_END();
/*
Q=Param("% Change",0.2,0.1,10,0.1);
Z= Zig(C ,q ) ;
HH=((Z<Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2)) AND (Peak(z,q,1 ) >Peak(Z,q,2)));
LH=((Z<Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2)) AND (Peak(Z,q,1 ) <Peak(Z,q,2)));
HL=((Z>Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) >Trough(Z,q,2)));
LL=((Z>Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) <Trough(Z,q,2)));
GraphXSpace = 5;
dist = 0.5*ATR(20); 

for( i = 0; i < BarCount; i++ ) 
{ 
if( HH[i] ) PlotText( "HH  \n"+Ref(H[i],-1), i, H[ i ]+dist[i], colorBlack,colorGreen );
if( LH[i] ) PlotText( "SAR \n"+Ref(H[i],-1), i, H[ i ]+dist[i], colorBlack, colorRed ); 
if( HL[i] ) PlotText( "SAR \n"+Ref(L[i],-1), i, L[ i ]-dist[i], colorBlack, colorGreen );
if( LL[i] ) PlotText( "LL  \n"+Ref(L[i],-1), i, L[ i ]-dist[i], colorBlack,colorRed );

}
*/

SL = ( HHV( H, 26 ) + LLV( L, 26) )/2;
TL = ( HHV( H, 9 ) + LLV( L, 9 ) )/2;
Plot (TL, "Stop line", colorAqua,styleThick); 

breakeven = Param ("brokerage",2,0,500,0.05);


risk_long = PH -SL-breakeven;
risk_short = SL - PL-breakeven;
range = PH-PL;
key = range / 2;
Short_tgt1 = PL- range*1.68;
Short_tgt2 = PL- range*2.68;
Long_tgt1 = PH + range*1.68;
Long_tgt2 = PH + range*2.68;

Color_buy = IIf (Close > sl AND Close > TL, colorGreen, IIf (Close < sl AND Close < TL,colorRed,colorYellow));
PlotOHLC( Open, High, Low, Close, "", Color_buy, styleBar ); 


 Title = EncodeColor(colorWhite)+ "RAJPUTZ'S PIVOT SYSTEM" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
 "  - " + Date() +" - "+"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+ "Cl-"+C+"  "+ "Vol= "+ WriteVal(V) + WriteIf ( V > MA(V,26),EncodeColor(colorGreen)+"  UP "+ ((V/MA(V,26))*100-100) + " %", EncodeColor(colorRed)+"  DOWN "+ ((100- V/MA(V,26)*100)) + " %")
+ EncodeColor(colorRed)+   "\n Pivot High : "+ EncodeColor(colorWhite)+PH+EncodeColor(colorRed)+ "  Place LONG    Trigger at :"+EncodeColor(colorWhite)+ phfilter + EncodeColor(colorRed)+ "   SL of :"+ EncodeColor(colorWhite)+SL+ EncodeColor(colorRed)+ "    Risk of " + EncodeColor(colorWhite)+risk_long
+ EncodeColor(colorYellow)+ "\n Long Target of : "+Long_tgt1 +"  and second target of :" + Long_tgt2   
+ "\n"
+ EncodeColor(colorGreen)+ "\n Pivot  Low : "+EncodeColor(colorWhite)+PL+EncodeColor(colorGreen)+"  Place SHORT Trigger at :"+ EncodeColor(colorWhite)+plfilter + EncodeColor(colorGreen)+"   SL of :"+ EncodeColor(colorWhite)+SL+ EncodeColor(colorGreen)+"    Risk of " + EncodeColor(colorWhite)+risk_short
+ EncodeColor(colorYellow)+ "\n Short Target of : "+short_tgt1 +"  and second target of :" + short_tgt2   
;

_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorLavender ), styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick | styleNoLabel, maskHistogram  ), 4 );
_SECTION_END();
 

rkkarnani

Well-Known Member
#2
I never used Metatrader. Did try but as I lost interest in Forex never installed it. Have the attached 3 files had the word "Pivot" in their name. Seeif they afre of any use to you. They have been posted on as is basis :D, Please do not ask me anything about them if you get an error as I would not know how to resolve it.

Trust that the come of some use to a few.
 
Last edited:

rajputz

Well-Known Member
#3
I never used Metatrader. Did try but as I lost interest in Forex never installed it. Have the attached 3 files had the word "Pivot" in their name. Seeif they afre of any use to you. They have been posted on as is basis :D, Please do not ask me anything about them if you get an error as I would not know how to resolve it.

Trust that the come of some use to a few.
Thanks rkkarnani...This is not what i am looking for...Thanks for your effort though...

Just to ask, i am looking for some thing which forms a pivot high and low everytime a step is created...

say a price moves to new high and then profit booking comes in and price moves down...So the last high is pivot high and formula forms a pivot line 1 or 2 ticks above it....
Simmilarly for pivot low...Price moves lower and then short covering comes in that moves price higher...So formula forms a pivot line 1 or 2 ticks below that pivot low...
 

rkkarnani

Well-Known Member
#4
Okay, frankly i do not know what I have sent you. Never used themon MT, rather have not used MT for almost 2+ years now. As one of the Indicators name was Auto Pivot, I thought it might serve your purpose.
Good luck for your search.
 
#5
Thanks rkkarnani...This is not what i am looking for...Thanks for your effort though...

Just to ask, i am looking for some thing which forms a pivot high and low everytime a step is created...

say a price moves to new high and then profit booking comes in and price moves down...So the last high is pivot high and formula forms a pivot line 1 or 2 ticks above it....
Simmilarly for pivot low...Price moves lower and then short covering comes in that moves price higher...So formula forms a pivot line 1 or 2 ticks below that pivot low...
Hi Rajputz,

Can u explain me these codes on these software ?please .
 

Similar threads