Discussions
»
Product and Service Development
»
Formula Assistance
»
Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 4/26/2009(UTC) Posts: 7
|
I have a few queries,if anyone of you could please help me out.
I would like to know how do I add a stoploss formula in the Enhanced system tester(EST),not using the basic stoploss function given. Like for eg : I want to buy when a:=Mov(C,10,S); b:=Mov(C,20,S); Cross (a,b); Now,in the 1st case-I want to add a stop loss at the lowest price of the bar,on which this buy signal gets generated and in the 2nd case-I want to add a stop loss 2 points below the lowest bollinger bands. I would also like to know is there any way i could change the settings of the trailing stop loss preloaded in the EST,because it seems to favour the best price which is practically not possible in realtime,as it only gives good returns if the trailing stoploss is kept to the minimal. As I am currently using the EST for intraday charts,can I set the EST in such a way that if a buy signal is generated at 3:00pm ,it automatically squares it off at 3:30pm when the market closes or the closing price of that day and opens the trade again the next morning if an opposite trade is not generated.
I am using intraday charts with a 5min bar .
Hoping to get some good answers.
Thanks
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Hi Schumii7,
Welcome to the forum.
Notice in the top right hand corner of just about every page on the forum is a small text box where you can enter some criteria on which to search the forum for existing posts. Try doing a search for "stops" or "stop loss" and see what comes up: there has been a lot of recent traffic on the subject so I'd be surprised if you cannot find something which will help you.
wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 4/26/2009(UTC) Posts: 7
|
Hi wabbit !
Well I have checked almost all posts regarding stop losses in this forum but couldnt find anything specificly related to my problem.I am still learning the metastock language hence facing a lot of issues finding these specific formulas. I have seen your posts and replies relating to all problems,I am surprised by the knowledge you have about metastock and its programming language. I would really be thankful to you if you could help me out here with the specific formulas. Thanks.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
schumii7 wrote:1st case-I want to add a stop loss at the lowest price of the bar,on which this buy signal gets generated In the EST, you will need to use the forum.Ref function and the simulation.currentpositionage to find the value of LOW. If you want to do this as an indicator, you'll need a PREV based latch. schumii7 wrote:2nd case-I want to add a stop loss 2 points below the lowest bollinger bands. BBandBot(), simulation.currentpositionage and forum.hhv will come into play here. schumii7 wrote:I would also like to know is there any way i could change the settings of the trailing stop loss preloaded in the EST,because it seems to favour the best price which is practically not possible in realtime,as it only gives good returns if the trailing stoploss is kept to the minimal. You can only take charge of the trailing stops by coding them yourself -- what you see on the Stops dialogue in the EST is all the settings to which you have access. schumii7 wrote:As I am currently using the EST for intraday charts,can I set the EST in such a way that if a buy signal is generated at 3:00pm ,it automatically squares it off at 3:30pm when the market closes or the closing price of that day and opens the trade again the next morning if an opposite trade is not generated. Although MS doesn't know what time it is (have a look for a recent post about trading at/near the close of a time period) for the purposes of the EST you can use the standard Hour() and Minute() functions to identify the correct time of the current day and forward reference it by one bar using Ref(). Have a go at writing these things for yourself. Start with whatever you think the simplest component is and work on from there. If you get stuck, post the code and an explanation of what the code is supposed to be doing and why you think it's not doing it and someone will lend you some of their time to help you sort it out. wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 4/26/2009(UTC) Posts: 7
|
schumii7:1st case-I want to add a stop loss at the lowest price of the bar,on which this buy signal gets generated wabbit :In
the EST, you will need to use the forum.Ref function and the
simulation.currentpositionage to find the value of LOW. If you want to
do this as an indicator, you'll need a PREV based latch. Hi wabit ! Thanks for quick reply but as I mentioned I am still new to the metastock programming language,so could you please help me out with the exact formula only for the 1st case,after which I will try and work out the rest on my own. That is the formula for placing the stop loss at the lowest point of the bar on which the buy signal gets generated using the cross function. Thanks again.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
If the EST is configured to enter on the next bar, use a delay of one
i.e. a signal is generated on a bar and the trade is entered on the
next bar; otherwise configure as you need and set the corresponding
value for the delay.
Code:
{sell}
C < extfml("forum.ref", ref(L,-1), simulation.currentpositionage);
NOTE: If you're using limit or stop orders, this may not work for you as the EST does not play nicely with these types of orders, only really works with market orders. Hope this helps. wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 4/26/2009(UTC) Posts: 7
|
Hi wabit !
I tried using this in the EST under Buy order in the form mentioned below :
a:=Mov(C,10,S); b:=Mov(C,20,S); Cross(a,b);
C < extfml("forum.ref", ref(L,-1), simulation.currentpositionage);
But I get the error message that " This DLL doesnot exist in the MSX DLL folder".
What am i doing wrong ?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
First, the stop loss condition goes under the sell tab not the buy tab in the EST.
Second, download the forum.dll from the files section of the forum, follow the instructions on how to download and where to download it to, and how to use. There is more than enough information on the forum to help you if you have troubles.
wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 4/26/2009(UTC) Posts: 7
|
I downloaded the Forum.dll and saved it.But the formula you mentioned doesnt seem to work.Maybe I am going wrong somewhere. schumii7:As I am currently
using the EST for intraday charts,can I set the EST in such a way that
if a buy signal is generated at 3:00pm ,it automatically squares it off
at 3:30pm when the market closes or the closing price of that day and
opens the trade again the next morning if an opposite trade is not
generated. Although MS doesn't know what time it is
(have a look for a recent post about trading at/near the close of a
time period) for the purposes of the EST you can use the standard
Hour() and Minute() functions to identify the correct time of the
current day and forward reference it by one bar using Ref(). I also tried the time formula which also dint work.In EST under Buy order below my cross formula,I wrote Hour()>9; Hour()<16; to only execute orders between 9am and 4 pm.Can you correct it for me please ? thanks.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
schumii7 wrote:I downloaded the Forum.dll and saved it.But the formula you mentioned doesnt seem to work.Maybe I am going wrong somewhere. Do you get any errors? If so, what errors? What part "doesn't seem to work"? schumii7 wrote:I also tried the time formula which also dint work.In EST under Buy order below my cross formula,I wrote Hour()>9; Hour()<16; to only execute orders between 9am and 4 pm.Can you correct it for me please ? After reading the MS Users Manual and working through the free Primer you'll be able to figure this out for yourself. wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 4/26/2009(UTC) Posts: 7
|
schumii7:I downloaded the Forum.dll and saved it.But the formula you mentioned doesnt seem to work.Maybe I am going wrong somewhere. wabbit:Do you get any errors? If so, what errors? What part "doesn't seem to work"? I dont get any errors but it doesnot seem to place the stop loss at the lowest point of the same bar on which the buy signal was generated. And also if the EST takes more than about 10secs to test,the error pops up "metastock encountered a problem" and then closes down. schumii7: I
also tried the time formula which also dint work.In EST under Buy order
below my cross formula,I wrote Hour()>9; Hour()<16; to only
execute orders between 9am and 4 pm.Can you correct it for me please ? wabbit:After reading the MS Users Manual and working through the free Primer you'll be able to figure this out for yourself. It was only after reading the MS User manual and the formula primer,I could write the above formula.But in both of them not much of the Hour Minute function is mentioned. I donot know how do i place the specific timings of 10am to 4pm.Can you help please ?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
schumii7 wrote:I dont get any errors but it does not seem to place the stop loss at the lowest point of the same bar on which the buy signal was generated. And also if the EST takes more than about 10secs to test,the error pops up "metastock encountered a problem" and then closes down. From here, it is very hard to diagniose the problem without seeing the exact codes you are trying, all the settings of the EST and the contents of your External Function DLLs folder. schumii7 wrote:It was only after reading the MS User manual and the formula primer,I could write the above formula.But in both of them not much of the Hour Minute function is mentioned. I do not know how do i place the specific timings of 10am to 4pm.Can you help please ? AND wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 4/26/2009(UTC) Posts: 7
|
Can you atleast me how to write 9am and 55 minutes ? Is it Hour()9 AND Minute()55 ?
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..
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.