PureBytes Links
Trading Reference Links
|
How can I have when testing on 200 bars:
391000$ profit with a sellstop ( sell price) AND
-22000 $ loss with an exit on the close the same day.
I don't find where is the error.
stephane
MaxGraph=14 ;
/*Gann HiLo*/
pdg=4;
Hl=IIf(Close>Ref(MA(H,pdg),-1),
/*then*/ 1,
/*else*/ IIf(Close<Ref(MA(L,pdg),-1),
/*then*/ -1,
/*else*/ 0));
Hv=ValueWhen(HL != 0,HL,1);
Hilo3=IIf(Hv==-1,
/*then*/MA(H,pdg),
/*else*/MA(L,pdg));
/*Gann HiLoShort*/
pds= 10;/*Optimize("pds",10,7,14,1);*/
Hl=IIf(Close>Ref(MA(H,pds),-1),
/*then*/ 1,
/*else*/ IIf(Close<Ref(MA(L,pds),-1),
/*then*/ -1,
/*else*/ 0));
Hv=ValueWhen(HL != 0,HL,1);
HiloSh=IIf(Hv==-1,
/*then*/MA(H,pds),
/*else*/MA(L,pds));
/*Gann HiLoMid*/
pdm=20;/*Optimize("pdm",20,18,24,2);*/
Hl=IIf(Close>Ref(MA(H,pdm),-1),
/*then*/ 1,
/*else*/ IIf(Close<Ref(MA(L,pdm),-1),
/*then*/ -1,
/*else*/ 0));
Hv=ValueWhen(HL != 0,HL,1);
HiloMd=IIf(Hv==-1,
/*then*/MA(H,pdm),
/*else*/MA(L,pdm));
/*Gann HiLoLong*/
pdl=32;/* Optimize("pdl",32,28,48,4);*/
Hl=IIf(Close>Ref(MA(H,pdl),-1),
/*then*/ 1,
/*else*/ IIf(Close<Ref(MA(L,pdl),-1),
/*then*/ -1,
/*else*/ 0));
Hv=ValueWhen(HL != 0,HL,1);
HiloLg=IIf(Hv==-1,
/*then*/MA(H,pdl),
/*else*/MA(L,pdl));
/****************************************/
R1= 18;/*Optimize("R1",14,10,20,2);*/
R2= 38;/*Optimize("R2",38,30,44,2);*/
X= C < Hilo3;
Trend=Hilosh > HiloMd and HiloMd >HiloLg;
Retrace= Close < hilo3 and Hold(H< Ref(H,-1)
AND L< Ref(L,-1),2) ;
Fib= (L < (MA(L,r1) + 1.2*StDev(MA(L,r1),r1))) and
(C > MA(L,r2));
Setup= Trend AND Retrace and Fib;
N=Ref(setup,-1) AND H>(Ref(H,-1)*1.005);
N= N and Ref(N, -1)==0;
N=ExRem(N,X);
Np=ValueWhen(N,Close,1);
/****************Loss Stop********************/
PerSl=0.99;/*Optimize("PerSl",0.990,0.975,0.995,0.005);*/
Slp= ValueWhen(N,LLV(L,5),1)*PerSl;
Sl= L<Slp AND BarsSince(N)!=0;
Sl= Sl and Ref(Sl,-1)==0;
/****************Target Stop****************/
Pct=3.75;/*Optimize("Pct",3.5,3,5,0.1);*/
Spp=ValueWhen(N,Np*(1+(Pct/100)));
Sp= H>spp AND BarsSince(N)!=0;
Sp=Sp and Ref(Sp,-1)==0;
/************Stop******************/
Stop= Sp Or Sl;
Xb= ExRem(Stop,N);
/**************Define Stops Price*********/
Spp=IIf(Xb,IIf(O>= Spp ,O,
IIf(H> Spp , Spp ,0)),0);
Slp=IIf(Xb,IIf(O<= Slp ,O,
IIf(L< Slp, Slp ,0)),0);
Xp=
IIf(Xb,IIf(Spp>0,Spp,IIf(Slp>0,Slp,0)),0);
Xp=ValueWhen(Xb,Xp);
/*************Buy& Sell Signals*****************/
Buy=N;
Sell= Xb ;
/*Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy);*/
BuyPrice= Np;
SellPrice= Xp;
Trade=Flip(N,Xb)*Np;
/****************Graph****************/
Graph0=Close;
Graph0Style=64;
Graph0BarColor = IIf( Buy, 6, IIf(Sell , 4 , 1 ));
Graph6=Buy*BuyPrice;
Graph6Color=11;
Graph6Style=1;
Graph7=Sell*SellPrice;
Graph7Color= 8 ;
Graph7Style=1;
|