Rank: Advanced Member
Groups: Registered, Registered Users Joined: 2/19/2012(UTC) Posts: 103
Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
Hello, I use Metastock 11 Professional edition. I am trying to code a buy and sell order for the system tester—long position only. The buy order should buy the security when the 20 period exponential moving average crosses above the 40 period exponential moving average in a security whose present closing price is greater than 800. Cross(Mov(C,20,E),Mov(C,40,E)) AND C>800 The sell order should sell when the price arises 8 units from the price when it was bought. Something like Create this binary indicator sellx Z1:= Cross(Mov(C,20,E),Mov(C,40,E)) AND C>800; Z2:= (ValueWhen(1,Z1,C) + 8)>=C+8; Z2; then the sell order should read If(sellx=1,(ValueWhen(1,Z1,C)+8),C) Could you check whether the coding is correct as—the ValueWhen function only returns the closing value for the first instance of the MA crossover while the system tester looks historically backward for say 4years. I am aware my code is a bit amateurish But if the coding is not correct—what should it be? Awaiting your reply, Regards, Sourav
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,934
Thanks: 85 times Was thanked: 154 time(s) in 150 post(s)
|
Originally Posted by: gorachand Hello, I use Metastock 11 Professional edition. I am trying to code a buy and sell order for the system tester—long position only. The buy order should buy the security when the 20 period exponential moving average crosses above the 40 period exponential moving average in a security whose present closing price is greater than 800. Cross(Mov(C,20,E),Mov(C,40,E)) AND C>800 The sell order should sell when the price arises 8 units from the price when it was bought. Something like Create this binary indicator sellx Z1:= Cross(Mov(C,20,E),Mov(C,40,E)) AND C>800; Z2:= (ValueWhen(1,Z1,C) + 8)>=C+8; Z2; then the sell order should read If(sellx=1,(ValueWhen(1,Z1,C)+8),C) Could you check whether the coding is correct as—the ValueWhen function only returns the closing value for the first instance of the MA crossover while the system tester looks historically backward for say 4years. I am aware my code is a bit amateurish But if the coding is not correct—what should it be? Awaiting your reply, Regards, Sourav
Hello, Have you considered using the Profit Stop within the Stops tab? You could enable the Longs option under the Profit Stop, set the Method to Points and the Profit Target to 8.
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
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.