in Search

Close<Ref(Close,-1) not working properly :(

Last post 06-27-2009, 8:56 by STNewbie. 10 replies.
Sort Posts: Previous Next
  •  06-25-2009, 23:07 29996

    Close<Ref(Close,-1) not working properly :(

    Hi i am testing a system where the Short exit is a simple formula that

    close
    However metastock is not taking this simple formula properly. Following is the chart.

    http://i41.tinypic.com/6yih3n.jpg

    Kindly note the system enters/exits on the next day of getting the signal.

    As you can see that the problem is in 5th signal, it shouldn't have exited, 6th signal is the right one, where it exited according to the rule. I have looked everywhere but i couldn't find a similar error.

    Could someone help me out in telling what could be the problem?

    Thanks is advance.
  •  06-26-2009, 5:31 29999 in reply to 29996

    Re: Close<Ref(Close,-1) not working properly :(

    Huh?

    I am guessing your code is incomplete?



    wabbit Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  06-26-2009, 10:13 30000 in reply to 29999

    Re: Close<Ref(Close,-1) not working properly :(

    No, thats my Short exit condition. Its the simplest exit condition that i have used.

    If you are referring to the Short Entry code...then its something like:


    Ref(Close,-2)> Ref(Close,-3) and

    (
    Ref(High,-1)-Ref(Low,-1) > 1.0*(Ref(High,-2)-Ref(Low,-2)) and
    Ref(Close,-1)) and

    (
    (Ref(Volume,-1) > Mov(Ref(Volume,-1),OPT2,S)) OR ( Ref(Volume,-1) > Mov(Ref(Volume,-1),OPT2+1,S)) or (Ref(Volume,-1) > Mov(Ref(Volume,-1),OPT2+2,S))

    )

    and

    (

    (High-Low)
    (
    Volume )

    OR

    (
    Close Mov(Volume,OPT2,S)
    )

    )

    and

    Mov(Close,OPT4,E)>Close


    ...

    I guess that was not the problem. Problem was that it was exiting where it shouldn't have. In some cases it was exiting properly and in other cases it was exiting improperly.


    i am confused why is it doing such thing.

    I have posted the link of the JPG image in which you can see the wrong and right both things.

    I am banging my head against this problem for last 1 week. Can you help me out?

  •  06-26-2009, 11:00 30001 in reply to 30000

    Re: Close<Ref(Close,-1) not working properly :(

    By providing the exit signal simply as "CLOSE" so long as this is not zero, MS will interpret this as TRUE and exit on the first bar after the entry of the trade (this depends on what delays have been set in the EST); do some research on how MS does its Boolean analysis.  Do you want to compare the CLOSE price with something else?

    Also, dealing with incomplete codes and "something like" snippets which contain errors does very little to assist us in finding the cause of your code problems.  Please post the whole code to the forum as exactly as it appears in your formula editor so that we can try to identify the root of the problem instead of wasting our time trying to fill-in the gaps of the pieces of code you have purposely omitted.

    I have seen the jpg in the link you have provide, and by my brief glance at the unadorned chart, the EST has done exactly what you have told it to do in the one, short line of code you provided for the buy-to-cover criteria.  Had you provided a word-description of what your system should be doing, we could have compared the word-description with the code-description to identify the shortcomings; you could have annotated the chart with some embellishment in the form of textual descriptions highlighting the errors because the casual peruse of the chart shows no errors what-so-ever.


    wabbit Big Smile [:D]



    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  06-26-2009, 14:13 30002 in reply to 30001

    Re: Close<Ref(Close,-1) not working properly :(

    Hi wabbit,

    First of all i apologize for the casual description of the problem.

    The code and EST is perfectly following the logic in the short entry criteria.

    The short exit criteria, however was that it should close when the previous close is lower than the the current close. Close is less than ref(Close,-1).

    ( For some reasons i am not able to post the formula, should have read the forums rules with a coffee cup in my hand, with coffee in it. )

    ( the formula, BTW, is the subject line of the thread)

    Now this is the link of the new chart, With the error mentioned in the chart

    http://i43.tinypic.com/9ftf5t.jpg

    The thing is that i have "checked" the realistic market prices. So each signal get executed on the next day. In the chart, however, if you see that the 5th signal exit is incorrect one.

    The exit should not have been there since the close ( on the day prior to the exit signal ) is > Ref(Close,-1) thats the close just before the short entry signal.

    The 6th signal, is working perfectly fine with the close ( Close) of the day prior to exit is lower than the close of the day( Ref(Close,-1) just before that.

    Again, i apologize for the earlier lousy description of the problem and hope that i have made my problem clear.

    Peace.
    STNewbie.
  •  06-26-2009, 18:03 30006 in reply to 30002

    Re: Close<Ref(Close,-1) not working properly :(

    STNewbie:
    The short exit criteria, however was that it should close when the previous close is lower than the the current close. Close is less than ref(Close,-1). ( For some reasons i am not able to post the formula, should have read the forums rules with a coffee cup in my hand, with coffee in it. )


    How to posts containing formula: http://forum.equis.com/forums/permalink/19754/20302/ShowThread.aspx#20302

    Code:
    This code is incomplete, contains errors, missing logic, mismatched brackets etc...

    {Short}
    Ref(Close,-2)> Ref(Close,-3) and
    (
    Ref(High,-1)-Ref(Low,-1) > 1.0*(Ref(High,-2)-Ref(Low,-2)) and Ref(Close,-1)) and
    (
    (Ref(Volume,-1) > Mov(Ref(Volume,-1),OPT2,S)) OR ( Ref(Volume,-1) > Mov(Ref(Volume,-1),OPT2+1,S)) or (Ref(Volume,-1) > Mov(Ref(Volume,-1),OPT2+2,S))
    )
    and
    (
    (High-Low)
    (Volume )
    OR
    (Close
    Mov(Volume,OPT2,S)
    )
    )
    and
    Mov(Close,OPT4,E)>Close


    Code:
    {Short Exit - Buy to cover}
    C < Ref(C,-1);


    STNewbie:
    Now this is the link of the new chart, With the error mentioned in the chart http://i43.tinypic.com/9ftf5t.jpg


    How post inline images: http://forum.equis.com/forums/permalink/19928/19928/ShowThread.aspx#19928

    STNewbie:
    The thing is that i have "checked" the realistic market prices. So each signal get executed on the next day. In the chart, however, if you see that the 5th signal exit is incorrect one. The exit should not have been there since the close ( on the day prior to the exit signal ) is > Ref(Close,-1) thats the close just before the short entry signal. The 6th signal, is working perfectly fine with the close ( Close) of the day prior to exit is lower than the close of the day( Ref(Close,-1) just before that.

    Have a look in the EST trades log as it will show when each "part" of the trade is considered, placed and executed.  If you want to have trades exiting on the same bar as they entered then you need to do some "tricks" with the delays, see Roy Larsen's post : http://forum.equis.com/forums/thread/18556.aspx  There are many other posts on the forum too.


    Hope this helps.

    wabbit Big Smile [:D]



    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  06-26-2009, 23:48 30009 in reply to 30006

    Re: Close<Ref(Close,-1) not working properly :(

    Hi wabbit,

    Thanks for replying again. If the short entry code is wrong i will try and fix that. But as i said i have no issues with that part of the code.

    I have problem with the exit. I am ok with the trades being exited one day later than when the signal was generated.

    The only problem that i think i have is that it is exiting on the wrong logic on the fifth exit.

    So, as my original question was is that the

    ---------
    C < Ref(C,-1)
    --------

     is it working properly in the buy to cover formula?

    Because, as i said in my last post, also the exit should not have been there since the close ( on the day prior to the exit signal ) is > Ref(Close,-1) thats the close just before the short entry signal. The 6th signal, is working perfectly fine with the close ( Close) of the day prior to exit is lower than the close of the day( Ref(Close,-1) just before that.

    So essentially, i am troubled with the buy to cover signal, doesn't matter whether it comes on the same day as of the enter short signal or one day after that. It should just follow the logic.

    So am i mistaken in logic? Am i not putting the formula correctly?


  •  06-27-2009, 0:43 30010 in reply to 30009

    Re: Close<Ref(Close,-1) not working properly :(

    What do the EST orders log say about the problematic 5th trade?

    Have you set any stops?


    wabbit Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  06-27-2009, 1:58 30011 in reply to 30010

    Re: Close<Ref(Close,-1) not working properly :(

    I assume by trade log you meant the Order log that you can see in each report?

    I see Margin call. Is that the problem, coz i cant see that thing anywhere else in the signals.

    i haven't put any stops.

    Still no correct answer.

    :(




  •  06-27-2009, 3:36 30012 in reply to 30011

    Re: Close<Ref(Close,-1) not working properly :(

    You're probably devoting 100% of your available equity to each trade? and then getting a margin call as soon as the price goes even slightly against you.  Just like in real life, if you don't have sufficient margin, your position will be automatically closed by the EST.

    Use a better position size algorithm.


    wabbit Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  06-27-2009, 8:56 30013 in reply to 30012

    Re: Close<Ref(Close,-1) not working properly :(

    wabbit:
    You're probably devoting 100% of your available equity to each trade? and then getting a margin call as soon as the price goes even slightly against you.  Just like in real life, if you don't have sufficient margin, your position will be automatically closed by the EST.

    Use a better position size algorithm.


    wabbit Big Smile [:D]



    Thats it. ! That was it. I changed my position sizing algorithm and it worked like a canary singing.

    Thank you wabbit.

    :D
View as RSS news feed in XML