udanii
23rd October 2009, 05:20 AM
buy signal :
F1:=ValueWhen(1,H<Ref(H,-2) AND Ref(H,-1)<Ref(H,-2) AND Ref(H,-3)<Ref(H,-2) AND Ref(H,-4)<Ref(H,-2),Ref(H,-2));
F2:=ValueWhen(1,L>Ref(L,-2) AND Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) AND Ref(L,-4)>Ref(L,-2),Ref(L,-2));
a:=Cross(H,F1);
b:=Cross(F2,L);
state:=If(BarsSince(a)<BarsSince(b),1,0);
state>Ref(state,-1)
Sell Signal :
F1:=ValueWhen(1,H<Ref(H,-2) AND Ref(H,-1)<Ref(H,-2) AND Ref(H,-3)<Ref(H,-2) AND Ref(H,-4)<Ref(H,-2),Ref(H,-2));
F2:=ValueWhen(1,L>Ref(L,-2) AND Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) AND Ref(L,-4)>Ref(L,-2),Ref(L,-2));
a:=Cross(H,F1);
b:=Cross(F2,L);
state:=If(BarsSince(a)<BarsSince(b),1,0);
state<Ref(state,-1)
( I have made indicators in metastock for the same )
what exactly i want to code :
1) is that when i am in a trade and a profit target of x points is achived , i want to trail by y points ( i would want to optimise y ).
2) after a trade moves in favour of x points , i wolud want to trail with y points ( i would want to optimise y ) or trail with another condition eg , a cross of a small moving average.
Thanks
Gaurav Udani
F1:=ValueWhen(1,H<Ref(H,-2) AND Ref(H,-1)<Ref(H,-2) AND Ref(H,-3)<Ref(H,-2) AND Ref(H,-4)<Ref(H,-2),Ref(H,-2));
F2:=ValueWhen(1,L>Ref(L,-2) AND Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) AND Ref(L,-4)>Ref(L,-2),Ref(L,-2));
a:=Cross(H,F1);
b:=Cross(F2,L);
state:=If(BarsSince(a)<BarsSince(b),1,0);
state>Ref(state,-1)
Sell Signal :
F1:=ValueWhen(1,H<Ref(H,-2) AND Ref(H,-1)<Ref(H,-2) AND Ref(H,-3)<Ref(H,-2) AND Ref(H,-4)<Ref(H,-2),Ref(H,-2));
F2:=ValueWhen(1,L>Ref(L,-2) AND Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) AND Ref(L,-4)>Ref(L,-2),Ref(L,-2));
a:=Cross(H,F1);
b:=Cross(F2,L);
state:=If(BarsSince(a)<BarsSince(b),1,0);
state<Ref(state,-1)
( I have made indicators in metastock for the same )
what exactly i want to code :
1) is that when i am in a trade and a profit target of x points is achived , i want to trail by y points ( i would want to optimise y ).
2) after a trade moves in favour of x points , i wolud want to trail with y points ( i would want to optimise y ) or trail with another condition eg , a cross of a small moving average.
Thanks
Gaurav Udani