bräuchte mal eure hilfe,
ich habe hier ein cross MA System und will die Ausstiege mit dem SAR machen, programmiert ist eigentlich alles, nur das vollautomatische handeln geht nicht und die berechnung ist fehlerhaft:
so sieht die programmierung aus:
SR:=SAR(vorn,hinten) ;
DataBars:= Ref(Pr3,-HShift3);
tmpMV:= Mov(DataBars,tPr3,mt3);
MA3:= tmpMV+((tmpMV*VShift3)/100);
Multiplikator:= if (C >= 10, 100, 10000);
price:=close;
TH:=if(Ref(C,-1) > H,Ref(C,-1),H);
TL:=if(Ref(C,-1) < L,Ref(C,-1),L);
TR:=TH-TL;
pr:=pr_ADX;
PlusDM:=if(H>Ref(H,-1) AND L>=Ref(L,-1), H-Ref(H,-1),if(H >Ref(H,-1) AND L<Ref(L,-1) AND H-Ref(H,-1)> Ref(L,-1)-L, H-Ref(H,-1),0));
PlusDI:=100*Wilders(PlusDM,Pr)/Wilders(Tr,Pr);
MinusDM:=if(L<Ref(L,-1) AND H<=Ref(H,-1), Ref(L,-1)-L,if(H>Ref(H,-1) AND L<Ref(L,-1) AND H-Ref(H,-1)<Ref(L,-1)-L, Ref(L,-1)-L,0));
MinusDI:=100*Wilders(MinusDM,Pr)/Wilders(Tr,Pr);
DIDif:=Abs(PlusDI-MinusDI);
DISum:=PlusDI+MinusDI;
ADXFinal:=100*Wilders(DIDif/DISum,Pr);
ADXRCustom:= (ADXFinal+Ref(ADXFinal,1-Pr))/2;
pr_ADX := ADXRcustom;
pr_ADX:=pr_ADX*3;
pr_ADX:=IF(pr_ADX>100,100,pr_ADX);
{---------price1---------}
MA1:= Mov(Price1, int (Pr *(1 -pr_ADX/100 )) +1 ,mt);
pr:=pr_ADX2;
PlusDM:=if(H>Ref(H,-1) AND L>=Ref(L,-1), H-Ref(H,-1),if(H >Ref(H,-1) AND L<Ref(L,-1) AND H-Ref(H,-1)> Ref(L,-1)-L, H-Ref(H,-1),0));
PlusDI:=100*Wilders(PlusDM,Pr)/Wilders(Tr,Pr);
MinusDM:=if(L<Ref(L,-1) AND H<=Ref(H,-1), Ref(L,-1)-L,if(H>Ref(H,-1) AND L<Ref(L,-1) AND H-Ref(H,-1)<Ref(L,-1)-L, Ref(L,-1)-L,0));
MinusDI:=100*Wilders(MinusDM,Pr)/Wilders(Tr,Pr);
DIDif:=Abs(PlusDI-MinusDI);
DISum:=PlusDI+MinusDI;
ADXFinal:=100*Wilders(DIDif/DISum,Pr);
ADXRCustom:= (ADXFinal+Ref(ADXFinal,1-Pr))/2;
pr_ADX := ADXRcustom;
pr_ADX:=pr_ADX*3;
pr_ADX:=IF(pr_ADX>100,100,pr_ADX);
{----------price2--------}
MA2:= Mov(Price2, int (Pr2 *(1 -pr_ADX/100 )) +1 ,mt);
{MA2:=0.01*MA2;
MA1:=0.01*MA1;}
{smoothing}
MA1:=(ref(ma1,-1)+ma1)/2;
MA2:=(ref(ma2,-1)+ma2)/2;
Long:=cross(ma1,ma2+trigger);
longstop1:= cross (c, SR) ;
short:=cross(ma2-trigger,ma1);
shortstop1:= cross (Sr, c) ;
OpenBuy:= Long and (eventCount('OpenBuy')= eventCount('CloseBuy'));
CloseBuy:= longstop1 and (eventCount('OpenBuy')> eventCount ('CloseBuy'));
{OpenSell und CloseSell}
OpenSell:=Short and (eventCount('OpenSell')= eventCount('CloseSell'));
CloseSell:= shortstop1 and (eventCount('OpenSell')> eventCount('CloseSell'));
Multiplikator:= if (C >= 10, 100, 10000);
{---Positionsausstieg, der aber nicht gehandelt werden darf---}
{---ist nur für Positionsflagge wichtig---}
{LongStop:= if(short,1,if(Short=1,1,0));
ShortStop:= if(long,1,if(Long =1,1,0));}
{---Positionsflagge setzen---}
PositionFlagLong:= if(long=1,1,
if(prev=null,0,
if(longstop1=1,0,prev)));
PositionFlagshort:= if(short=1,1,
if(prev=null,0,
if(shortstop1=1,0,prev)));
{OpenBuy and CloseBuy}
OpenBuy1:= if(Long=1 and ref(PositionflagLong,-1)=0 ,1,0);
EntryPriceBuy:=if(OpenBuy1=1,C,Prev);
CloseBuy1:= If(LongStop1=1 and ref(PositionFlagLong,-1)=1 ,1,0);
ExitPriceBuy:=if(CloseBuy1=1,C,Prev);
{OpenSell and CloseSell}
OpenSell1:= if(Short=1 And ref(PositionFlagShort,-1)=0,1,0);
EntryPriceSell:=if(OpenSell1=1,C,Prev);
CloseSell1:= If(ShortStop1=1 And ref(PositionFlagShort,-1)=1,1,0);
ExitPriceSell:=if(CloseSell1=1,C,Prev);
{---Profit berechnen---}
TradeProfit:= If(closebuy1=1,((ExitpriceBuy-EntryPriceBuy)*MultiPlikator)-Spread,
If(closesell1=1,((EntryPriceSell-ExitPriceSell)*MultiPlikator)-Spread,0));
TotalProfit:= cum(TradeProfit);
falls ihr fragen dazu habt fragt ruhig, ist ein MA Cross System 6 und 22 sind die Einstellungen und will es so programmieren, das das System bei unter/überschreiten des SAR aussteigt.
Danke für eure Hilfe.