Académique Documents
Professionnel Documents
Culture Documents
GraphXSpace = 7;
SetChartOptions( 0, chartShowArrows | chartShowDates );
Cg = Foreign(".NESI", "C");
accel = Param("Acceleration", 0.02, 0, 1, 0.001);
mx = Param("Max. acceleration", 0.2, 0, 1, 0.001);
rt=PTA_Pos();
SellPrice = ValueWhen( Sell, C, 1 );
BuyPrice = ValueWhen( Buy, C, 1 );
Long = Flip( Buy, Sell );
Shrt = Flip( Sell, Buy );
state = IIf( BarsSince( a ) < BarsSince( b ), 1, 0 );
Longs = state == 1;
shorts = state == 0;
Colorbar = IIf( Longs, colorGreen, IIf( Shorts, colorRed, colorGrey40 ) );
Plot( C, "Close", colorbar, styleCandle = 64 | styleNoTitle );
PlotShapes( IIf( aHPivs == 1, shapeDownArrow, shapeNone ), colorOrange, 0, High,
Offset = -30 );
PlotShapes( IIf( aLPivs == 1, shapeUpArrow , shapeNone ), colorLime, 0, Low, Off
set = -30 );
PlotShapes( IIf(Buy, shapeSmallCircle, shapeNone),colorBrightGreen, 0, BuyPrice,
Offset = -15 );
PlotShapes( IIf(Sell, shapeSmallCircle, shapeNone),colorWhite, 0 ,SellPrice, Of
fset = 50 );
FirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status("LastVisibleBar");
for( b = Firstvisiblebar; b <= Lastvisiblebar AND b < BarCount; b++)
{
if( Buy[b] ) PlotText("\n\n\n\n Buy\n "+NumToStr(BuyPrice[b],1.2),b,BuyPrice[b],
colorBrightGreen);
else if( Sell[b] ) PlotText("Sell "+NumToStr(SellPrice[b], 1.2),b,SellPrice[b],
colorWhite);
}
Plot( EMAC13, "" , colorSkyblue + styleLine + styleNoRescale );
Change1 = StrFormat("%1.2f% ",xChange1);
barche1= xChange1>=0;
Comche1= xChange1<0;
xperchange1 = xChange1/100;
perchange1 = StrFormat("%1.2f% ",xperchange1);
positivechange1 = xperchange1>0;
negativechange1 = xperchange1<0;
_SECTION_BEGIN( "Title" );
printf( "Open : " + O );
);
RequestTimedRefresh(0.1,True);
xx=BarIndex();x=xx;Lx=LastValue(x);
nbar=Param("N Pivot Bars",5,2,50,1);
tf=Param("Time Frame (min)",inWeekly/60,1,inWeekly/60,1);tfrm=in1Minute*tf;
CleanPivots=ParamToggle("Use Clean Pivots","Off|On",1);
PivotSymmetry=ParamToggle("Use Symmetric Pivots","Off|On",0);
displayMode=ParamToggle("Display Mode","Classic|Alternative",1);
logscale=ParamToggle("Axis type","Linear|Logarithmic",0);
SetChartOptions(0,chartShowDates);
if(logscale) SetChartOptions(2,chartLogarithmic,chartGridMiddle|chartGridMargins
);
else SetChartOptions(3,chartLogarithmic,!(chartGridMiddle|chartGridMargins));
TimeFrameSet(tfrm);
rt=TimeFrameProc();
pkhn=IIf(pk,H,Null);
trln=IIf(tr,L,Null);
TimeFrameRestore();
fact=Nz(Max(tfrm/60,Interval()/60)/(Interval()/60));
if(fact==0)fact=1;
Lkbk=Nz(tfrm/Interval());
if(Lkbk>1)
{
pk=TimeFrameExpand(pk,tfrm,expandFirst);
pkhn=TimeFrameExpand(pkhn,tfrm,expandFirst);
pkhs=IIf(!IsEmpty(pkhn),1,0);pkhs=pkhs-Ref(pkhs,-1);
pk=pk AND H==pkhn;
cond1=Sum(pk,BarsSince(pkhs==1)+1)==1 AND pk;
pk=pk AND cond1;
tr=TimeFrameExpand(tr,tfrm,expandFirst);
trln=TimeFrameExpand(trln,tfrm,expandFirst);
trls=IIf(!IsEmpty(trln),1,0);trls=trls-Ref(trls,-1);
tr=tr AND L==trln;
cond1=Sum(tr,BarsSince(trls==1)+1)==1 AND tr;
tr=tr AND cond1;
rt=PxTx();
}
pkhn=IIf(pkh,pkh,Null);
trln=IIf(trln,trln,Null);
for(i=0;i<BarCount;i++){xkk[i]=pk[i];}
for(i=0;i<BarCount;i++){trkk[i]=tr[i];}
SetBarFillColor(IIf(C>O,colorGreen,IIf(C<=O,colorRed,colorLightGrey)));
Plot(C,"Price",IIf(C>O,colorDarkGreen,IIf(C<=O,colorDarkRed,colorLightGrey)),64,
0,0,0,0);
Plot(pkhn,"",colorRed,styleThick,0,0,0,-1);
Plot(trln,"",colorBrightGreen,styleThick,0,0,0,-1);
PlotShapes(shapeSmallCircle*trkk,IIf(Lx-ValueWhen(tr,x)>nbar*fact,ColorRGB(0,100
,0),colorWhite),0,L,-10);
PlotShapes(shapeSmallCircle*xkk,IIf(Lx-ValueWhen(xkk,x)>nbar*fact,ColorRGB(255,0
,0),colorWhite),0,H,10);
qq=Interval()/60;
if(qq < 60){tf=" min";tt=qq;}
else if(qq >= 60 AND qq < 1440){tf=" hrs";tt=qq/60;}
else if(qq >= 1440){tf=" days";tt=(qq/60)/24;}
qq=Max(tfrm/60,Interval()/60);
if(qq < 60){tfa=" min";tta=qq;}
else if(qq >= 60 AND qq < 1440){tfa=" hrs";tta=qq/60;}
else if(qq >= 1440){tfa=" days";tta=(qq/60)/24;}
function GetVisibleBarCount()
{
lvb=Status("lastvisiblebar");
fvb=Status("firstvisiblebar");
return Min(lvb-fvb,BarCount-fvb);
}
function GfxConvertBarToPixelX(bar)
{
lvb=Status("lastvisiblebar");
fvb=Status("firstvisiblebar");
pxchartleft=Status("pxchartleft");
pxchartwidth=Status("pxchartwidth");
return Nz(pxchartleft+bar*pxchartwidth/(lvb-fvb+1));
}
function GfxConvertValueToPixelY(value,logscale)
{
local Miny,Maxy,pxchartbottom,pxchartheight;
Miny=Status("axisminy");
Maxy=Status("axismaxy");
pxchartbottom=Status("pxchartbottom");
pxchartheight=Status("pxchartheight");
delta=log(maxy)-log(Miny);
if(logscale) rv=Nz(pxchartbottom-floor(0.5+(log(Value)-log(Miny))*pxcharthei
ght/(delta)));
else rv=Nz(pxchartbottom-floor(0.5+(Value-Miny)*pxchartheight/(Maxy-Miny)));
return rv;
}
AllVisibleBars=GetVisibleBarCount();
fvb=Status("firstvisiblebar");
for(i=0;i<AllVisibleBars;i++)
{
DisplayRes=1;
DisplaySup=1;
lvix=i+fvb;
if(pk[lvix])
{
if(displayMode)
{
hval=H[lvix];
for(j=i;j<AllVisibleBars;j++)
{
lvjx=j+fvb;
if(H[lvjx]>hval)
{
DisplayRes=0;
break;
}
}
}
if(DisplayRes)
{
GfxSelectPen(ColorRGB(100,0,0),3,0);
GfxMoveTo(GfxConvertBarToPixelX(i),GfxConvertValueToPixelY(H[lvix],l
ogscale));
GfxLineTo(GfxConvertBarToPixelX(AllVisibleBars-1),GfxConvertValueToP
ixelY(H[lvix],logscale));
GfxSelectFont("Tahoma",8,650);GfxSetBkColor(ColorRGB(200,0,0));GfxSe
tTextColor(colorWhite);
GfxTextOut(""+H[lvix],GfxConvertBarToPixelX(AllVisibleBars+1),GfxCon
vertValueToPixelY(H[lvix],logscale));
}
}
if(tr[lvix])
{
if(displayMode)
{
lval=L[lvix];
for(j=i;j<AllVisibleBars;j++)
{
lvjx=j+fvb;
if(L[lvjx]<lval)
{
DisplaySup=0;
break;
}
}
}
if(DisplaySup)
{
GfxSelectPen(ColorRGB(0,0,100),3,0);
GfxMoveTo(GfxConvertBarToPixelX(i),GfxConvertValueToPixelY(L[lvix],l
ogscale));
GfxLineTo(GfxConvertBarToPixelX(AllVisibleBars-1),GfxConvertValueToP
ixelY(L[lvix],logscale));
GfxSelectFont("Tahoma",8,650);GfxSetBkColor(ColorRGB(0,0,200));GfxSe
tTextColor(colorWhite);
GfxTextOut(""+L[lvix],GfxConvertBarToPixelX(AllVisibleBars+1),GfxCon
vertValueToPixelY(L[lvix],logscale));
}
}
}
}
}
}
GraphXSpace=7;
nLastVisBar = LastValue(
Highest(IIf(Status("barvisible"), BarIndex(), 0)));
rt=HLPivs();
if (bDraw) {
PlotShapes(
IIf(aHPivs==1, shapeDownArrow, shapeNone),
colorRed, 0,
High, Offset=-15);
PlotShapes(
IIf(aAddedHPivs==1, shapeDownArrow, shapeNone),
colorCustom12, 0, High, Offset=-15);
PlotShapes(
IIf(aLPivs==1, shapeUpArrow , shapeNone),
5, 0, Low, Offset=-15);
PlotShapes(
IIf(aAddedLPivs==1, shapeUpArrow , shapeNone),
colorWhite, 0, Low, Offset=-15);
_SECTION_END();