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

Notification

Icon
Error

Options
Go to last post Go to first unread
gorachand  
#1 Posted : Saturday, December 16, 2023 6:27:23 PM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 104

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
MS Support  
#2 Posted : Tuesday, January 2, 2024 5:54:28 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,937

Thanks: 85 times
Was thanked: 155 time(s) in 150 post(s)

Originally Posted by: gorachand Go to Quoted Post
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.

gorachand  
#3 Posted : Tuesday, May 7, 2024 4:01:41 PM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 104

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
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. When the system tester profit stop is set to 8 as described by you-- what happens in a trade where profits do not rise to 8 units? What is the sell exit signal then? If I am to put an additional sell order along with the 8 unit profit stop-- which sell signal will be executed first?
MS Support  
#4 Posted : Thursday, May 9, 2024 2:19:35 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,937

Thanks: 85 times
Was thanked: 155 time(s) in 150 post(s)

Originally Posted by: gorachand Go to Quoted Post
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. When the system tester profit stop is set to 8 as described by you-- what happens in a trade where profits do not rise to 8 units? What is the sell exit signal then? If I am to put an additional sell order along with the 8 unit profit stop-- which sell signal will be executed first?

Hello again,

You may find this excerpt from our MetaStock Help File Useful, from the "Entering Stops" topic: Home > The Power Console > System Tester > Creating a System Test > Stops > Entering Stops

In addition to trading rules, each trading system can have up to five "stops." Stops are set by selecting the Stops tab in the System Editor dialog. Stops are used to close long and/or short positions based on the position's gains/losses. For example, the Maximum Loss stop will close a position if the position loses more than a specified amount.

When a stop is triggered, the position is closed regardless of the current status of your trading rules. The price at which the position is closed is the actual stop price or the specified exit price.

If the price gaps below a stop level on a long position, MetaStock exits at the open price of the next bar. If no open price is available, the high price of the next bar is used. Likewise, if the price gaps above a stop level on a short position, MetaStock exits at the open price of the next bar. If no open price is available, the low price of the next bar is used.

Stops automatically take entry and exit commissions into account. For example, the Maximum Loss stop knows the amount of your "exit" commission and will attempt to close the position so the maximum loss will not be exceeded after you pay the exit commission.

If two stops are triggered on the same bar, the more conservative stop takes precedence (i.e., the stop that generates the most losses). The precedence of stops is; Maximum Loss, Breakeven, Trailing, Profit Target, and Inactivity Minimum Change.

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.