logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
mutkan  
#1 Posted : Tuesday, January 5, 2016 7:22:04 PM(UTC)
mutkan

Rank: Newbie

Groups: Registered Users, Subscribers, Unverified Users
Joined: 12/14/2015(UTC)
Posts: 6

Thanks: 1 times

Hi ,

The following self referencing function with PREV needs a revision to be converted into Valuewhen but I could not figure out how to do it. Difficulty for me is at the sell short order part. Logical OR is not yielding -1.

Please advise a solution. 

 

Thanks in advance

 

BUY Order

x:=Mov(PDI(14)-MDI(14),10,S);
bset:=Cross(x,Mov(x,10,S));
el:=Cross(C,ValueWhen(1,bset,H)) AND BarsSince(bset)<5;
xl:=ADX(14)>PDI(14);
lt:=If(el,1, If(xl,0,PREV));
Cross(lt,0.5)


SELL Order

x:=Mov(PDI(14)-MDI(14),10,S);
bset:=Cross(x,Mov(x,10,S));
el:=Cross(C,ValueWhen(1,bset,H)) AND BarsSince(bset)<5;
xl:=ADX(14)>PDI(14);
lt:=If(el,1, If(xl,0,PREV));
Cross(0.5,lt)


SELL SHORT Order

x:=Mov(PDI(14)-MDI(14),10,S);


sset:=Cross(Mov(x,10,S),x);


es:=Cross(ValueWhen(1,sset,L),C) AND BarsSince(sset)<5;


xs:=ADX(14)>MDI(14);


st:=If(es,-1,If(xs,0,PREV));


Cross(-0.5,st)


 

BUY TO COVER ORDER

x:=Mov(PDI(14)-MDI(14),10,S);
sset:=Cross(Mov(x,10,S),x);
es:=Cross(ValueWhen(1,sset,L),C) AND BarsSince(sset)<5;
xs:=ADX(14)>MDI(14);
st:=If(es,-1,If(xs,0,PREV));
Cross(st,-0.5)


 


mstt  
#2 Posted : Wednesday, January 6, 2016 10:50:22 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi Mutkan I've merged the Long Buy and Sell signals into one indicator, and the same for Sell Short and Buy Cover. The removal of PREV seems to be working OK for the long side, and for the short side as far as I've tested. However, I haven't compared the new short version against the old. The result of both formulas generates positive 1 for an entry and negative 1 for an exit. The solution for your Logical OR problem is easily solved by reverting to +1 rather than -1. It works for me anyway. The nature of your code appears to lend itself to potential entry and exit signals on the same bar, though they will be filtered out at the lt and st stages. Maybe it's not a problem. Roy {Mutkan Long System New} x:=Mov(PDI(14)-MDI(14),10,S); bset:=Cross(x,Mov(x,10,S)); el:=Cross(C,ValueWhen(1,bset,H)) AND BarsSince(bset)<5; xl:=ADX(14)>PDI(14); i:=Cum(el+xl>-1)=1; lt:=ValueWhen(1,i+el+xl,If(el,el,xl*0)); BuyLong:=Cross(lt,0.5); SellLong:=Cross(0.5,lt); BuyLong-SellLong; {Mutkan Short System New} x:=Mov(PDI(14)-MDI(14),10,S); sset:=Cross(Mov(x,10,S),x); es:=Cross(ValueWhen(1,sset,L),C) AND BarsSince(sset)<5; xs:=ADX(14)>MDI(14); i:=Cum(es+xs>-1)=1; st:=ValueWhen(1,i+es+xs,If(es,es,xs*0)); SellShort:=Cross(st,0.5); BuyCover:=Cross(0.5,st); SellShort-BuyCover;
thanks 1 user thanked mstt for this useful post.
mutkan on 1/7/2016(UTC)
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.