in Search

Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

Last post 04-27-2009, 23:01 by schumii7. 12 replies.
Sort Posts: Previous Next
  •  04-26-2009, 9:28 29553

    Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    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
  •  04-26-2009, 20:36 29554 in reply to 29553

    Re: Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    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 Big Smile [:D]


    Please update your thread status:

    FREE Equis Formula Primer : http://forum.equis.com/files/19673/download.aspx
    To post code, *code* your code */code*
    To post links, [URL] URL goes here [/URL]
    For custom MetaStock and DLL programming : http://www.wabbit.com.au
    Contact via SkyPE
  •  04-26-2009, 22:27 29555 in reply to 29554

    Re: Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    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.
  •  04-26-2009, 23:19 29557 in reply to 29553

    Re: Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    schumii7:
    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:
    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:
    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:
    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 Big Smile [:D]


    Please update your thread status:

    FREE Equis Formula Primer : http://forum.equis.com/files/19673/download.aspx
    To post code, *code* your code */code*
    To post links, [URL] URL goes here [/URL]
    For custom MetaStock and DLL programming : http://www.wabbit.com.au
    Contact via SkyPE
  •  04-27-2009, 2:26 29558 in reply to 29557

    Re: Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    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.
  •  04-27-2009, 3:20 29559 in reply to 29558

    Re: Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    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 Big Smile [:D]


    Please update your thread status:

    FREE Equis Formula Primer : http://forum.equis.com/files/19673/download.aspx
    To post code, *code* your code */code*
    To post links, [URL] URL goes here [/URL]
    For custom MetaStock and DLL programming : http://www.wabbit.com.au
    Contact via SkyPE
  •  04-27-2009, 4:17 29560 in reply to 29559

    Re: Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    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 ?

  •  04-27-2009, 5:37 29561 in reply to 29560

    Re: Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    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 Big Smile [:D]


    Please update your thread status:

    FREE Equis Formula Primer : http://forum.equis.com/files/19673/download.aspx
    To post code, *code* your code */code*
    To post links, [URL] URL goes here [/URL]
    For custom MetaStock and DLL programming : http://www.wabbit.com.au
    Contact via SkyPE
  •  04-27-2009, 11:34 29562 in reply to 29561

    Re: Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    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.
  •  04-27-2009, 18:39 29565 in reply to 29562

    Re: Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    schumii7:
    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:
    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 Big Smile [:D]





    Please update your thread status:

    FREE Equis Formula Primer : http://forum.equis.com/files/19673/download.aspx
    To post code, *code* your code */code*
    To post links, [URL] URL goes here [/URL]
    For custom MetaStock and DLL programming : http://www.wabbit.com.au
    Contact via SkyPE
  •  04-27-2009, 22:23 29566 in reply to 29565

    Re: Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    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 ?

  •  04-27-2009, 22:41 29567 in reply to 29566

    Re: Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    schumii7:
    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:
    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 Big Smile [:D]


    Please update your thread status:

    FREE Equis Formula Primer : http://forum.equis.com/files/19673/download.aspx
    To post code, *code* your code */code*
    To post links, [URL] URL goes here [/URL]
    For custom MetaStock and DLL programming : http://www.wabbit.com.au
    Contact via SkyPE
  •  04-27-2009, 23:01 29568 in reply to 29567

    Re: Stop loss and trailing stop loss in Enhanced system tester ?? Help plz..

    Can you atleast me how to write 9am and 55 minutes ?
    Is it Hour()9 AND Minute()55 ?
View as RSS news feed in XML