in Search

Simple Formula Need Help

Last post 01-18-2005, 19:22 by Patrick. 12 replies.
Sort Posts: Previous Next
  •  01-06-2005, 2:40 327

    Simple Formula Need Help

    i'd like to use MA as trend and oscillator as time to enter market.

    For example, if 5d MA line cross above 20d and 10d MA line, it's a bull trend,
    then i know i'll enter the market on long instead of short and i'll use oscillator to time the entry. if osc is 50% and pointing up then enter market and when osc fall below 70% exit the market. actually i wanted to set my exit rule to as long as it's reversing then exit, but i'm not sure the sytem support it and also the line is pointing up and down thing. Can anyone help to write something above?

    besides, i'm not sure metastock can do alert like when there's a reversal patterns based on candlestick at certain fibonacci retracement? pls tel me whether i can set it using the expert system or explorer...If so, how?

    I've come across another back test system giving above 100% return. Im not sure if the back test system I set is wrong coz mine only giving the most 10% return when i back tested with formulas like above...

    And how can i incur commision in back test system?
  •  01-07-2005, 19:59 328 in reply to 327

    Re: Simple Formula Need Help

    [quote user="MORE" button, unless you are not using metastock version 9.

    For your first formula, it should be pretty simple.
    You may want to try the following in either an expert, a system or an exploration :

    {EnterLong}

    BullTrend:=Cross(Mov(C,5,S),Max(Mov(C,10,S),Mov(C,20,S)));
    BearTrend:=Cross(Min(Mov(C,10,S),Mov(C,20,S)),Mov(C,5,S));
    Trend:=If(Barssince(Ref(BullTrend,-1))<Barssince(Ref(BearTrend,-1)),1,-1);
    EnterLong:=Trend=1 and {your oscillator condition here};
    ExitLong:=Trend=1 and {your oscillator condition here};
    EnterShort:=Trend=-1 and {your oscillator condition here};
    ExitShort:=Trend=-1 and {your oscillator condition here};
    EnterLong and Barssince(ref(EnterLong,-1))>Min(Barssince(Ref(ExitLong,-1)),Min(Barssince(Ref(EnterShort,-1)),Barssince(Ref(ExitShort,-1))))

    This is an example and might not be completely accurate but it should help you create your system/expert.

    Let me know if you need any help with it.

    Regarding the system based on fibonnacci lines, I unfrotunately do not have any idea on how to do it
    My Site
  •  01-12-2005, 6:20 330 in reply to 327

    Re:

    [quote user="MORE" button, unless you are not using metastock version 9.


    I'm not using version 9, u meant only version 9 can do it?


    {EnterLong}

    BullTrend:=Cross(Mov(C,5,S),Max(Mov(C,10,S),Mov(C,20,S)));
    BearTrend:=Cross(Min(Mov(C,10,S),Mov(C,20,S)),Mov(C,5,S));
    Trend:=If(Barssince(Ref(BullTrend,-1))<Barssince(Ref(BearTrend,-1)),1,-1);
    EnterLong:=Trend=1 and {your oscillator condition here};
    ExitLong:=Trend=1 and {your oscillator condition here};
    EnterShort:=Trend=-1 and {your oscillator condition here};
    ExitShort:=Trend=-1 and {your oscillator condition here};
    EnterLong and Barssince(ref(EnterLong,-1))>Min(Barssince(Ref(ExitLong,-1)),Min(Barssince(Ref(EnterShort,-1)),Barssince(Ref(ExitShort,-1))))


    Can you help me on writing the oscillator condition formula?
    My condition is

    Buy signals occur when both SI values have been below 25 and then cross above it.
    Sell signals occur when both SI values have been above 75 and then cross below it.

    If a sell occurs and both SI values cross back above 75, then
    another buy signal occurs and vice versa for sell signals
  •  01-12-2005, 15:49 333 in reply to 327

    Re: Re:

    If you have the formula in another language, yes post it here and we will try to convert it to MetaStock's language.
    Especially if it gives 100% return :D


    I'm not using version 9, u meant only version 9 can do it?


    No other versions can do it but it is done differently, I think you need to click on tools, system tester and then options.


    Can you help me on writing the oscillator condition formula?


    Is this the same as the one you are going to post in another
    language or is it different request ? sorry if I'm being thick :oops:
    My Site
  •  01-13-2005, 3:10 335 in reply to 327

    Re: Re:

    Haha...I'm sure u know there's no 100% guarantee winning formula, what I meant was the return in high percentage as per the amount you invested. :wink:

    I got this from a book, in fact it's saying that it gives more than 400% return when back tested. I'm not sure if this's because the system works differently for other software and the number they give is higher. Maybe you can help to verify for me and pls post it back to me in metastock language after you've translate it. :oops:

    btw, can you help me to write the oscillator condition formula that I posted earlier? It's not the 100% formula but a friend told me that a simple formula work best and I just wan't to see if this's true.

    Thanks.
  •  01-13-2005, 16:06 337 in reply to 327

    Re: Re:

    ouch, looks like an easy one ...
    let me take a look at it and I will post the formulae sometime tomorrow. 8)
    My Site
  •  01-14-2005, 2:03 343 in reply to 327

    Re: Re:

    Thanks. Awaiting your posting then.

    Can you help me on 1 more formula? Sorry, because I in learning process now so will have a lot of questions and need to try out a lot of the formulas.

    Is it possible to do a formula/writing in system that to say if the
    Stochastic's %K cross %D and %D cross %K?

    Thanks.
  •  01-14-2005, 18:42 349 in reply to 327

    Re: Re:

    Is it possible to do a formula/writing in system that to say if the Stochastic's %K cross %D and %D cross %K?


    I'm using 14,3,3 but you can replace these values.

    {Cross %k Above %D}
    K:=14;
    Kslowing:=3;
    D:=3;
    StoK:=Stoch(K,Kslowing);
    stoD:=Mov(Stoch(K,Kslowing),D,S);
    Cross(StoK,StoD)

    {Cross %D Above %K}
    K:=14;
    Kslowing:=3;
    D:=3;
    StoK:=Stoch(K,Kslowing);
    stoD:=Mov(Stoch(K,Kslowing),D,S);
    Cross(StoD,StoK)
    My Site
  •  01-14-2005, 18:46 350 in reply to 327

    Re: Re:

    in your file there is actually 2 systems.
    I worked on the first one, but it won't be possible to make it exactly the same without version 9. As there are entry prices variables.

    What the system does is buy when this happens :

    RANGE BREAKOUT

    ATRBars:=3; {Length of Average TrueRange}
    ATRMult:=0.62; {Multiplier for ATR (Volatility Factor)}
    MOMBars:=28; {Length of Momentum Indicator}
    MOMBack:=10; {Length of Momentum LookBack Period}
    ATRVal:=ATR(ATRBars)*ATRMult;
    MOMVal:=Mom(C,MOMBars);
    MOMTrnd:=If(MOMVal>Ref(MOMVal,-MOMBack),1,-1);
    lePrice:=If(MOMTrnd>0,H+ATRVal,C+ATRVal);
    sePrice:=If(MOMTrnd<0,L-ATRVal,C-ATRVal);
    Cross(MOMTrnd,0)

    AND buys at the value of the lePrice variable

    Also it tells you to sell when this happens :

    ATRBars:=3; {Length of Average TrueRange}
    ATRMult:=0.62; {Multiplier for ATR (Volatility Factor)}
    MOMBars:=28; {Length of Momentum Indicator}
    MOMBack:=10; {Length of Momentum LookBack Period}
    ATRVal:=ATR(ATRBars)*ATRMult;
    MOMVal:=Mom(C,MOMBars);
    MOMTrnd:=If(MOMVal>Ref(MOMVal,-MOMBack),1,-1);
    lePrice:=If(MOMTrnd>0,H+ATRVal,C+ATRVal);
    sePrice:=If(MOMTrnd<0,L-ATRVal,C-ATRVal);
    Cross(0,MOMTrnd)

    AND sells at the value of the sePrice variable

    I will take a look at the other one later
    My Site
  •  01-14-2005, 19:10 352 in reply to 327

    Re: Re:

    To get back to the first request :oops:

    Buy signals occur when both SI values have been below 25 and then cross above it.
    Sell signals occur when both SI values have been above 75 and then cross below it.


    The problem I see with this is that your first condition is also a cross.
    Plus I might be having a bad day because I do not remember what SI stands for. Also make sure to provide me with the periods to use with that SI. ( Do you mean RSI ? )
    My Site
  •  01-15-2005, 2:35 354 in reply to 327

    Re: Re:

    Oops...I'm sorry, SI is Stochastic Indicator. :oops:

    As for the period, I cannot remember it now coz I've set it in my system and I'm not using my own system now. But I think I'm using the common 14-days.

    Thanks for the formulas, I'll test it out this weekend. :D
  •  01-18-2005, 15:48 356 in reply to 327

    Re: Re:

    {Enter Long}

    BullTrend:=Cross(Mov(C,5,S),Max(Mov(C,10,S),Mov(C,20,S)));
    BearTrend:=Cross(Min(Mov(C,10,S),Mov(C,20,S)),Mov(C,5,S));
    Trend:=If(BarsSince(Ref(BullTrend,-1))<BarsSince(Ref(BearTrend,-1)),1,-1);
    EnterLong:=Trend=1 AND Cross(Stoch(14,3),25);
    ExitLong:=Trend=1 AND Cross(75,Stoch(14,3));
    EnterShort:=Trend=-1 AND Cross(75,Stoch(14,3));
    ExitShort:=Trend=-1 AND Cross(Stoch(14,3),25);
    Status:=If(EnterLong,2,If(EnterShort,-2,If(ExitLong,1,If(ExitShort,-1,PREV))));
    EL:=Cross(Status,1.5);
    XL:=Cross(1.5,Status) AND Ref(Status,-1)=2;
    ES:=Cross(-1.5,Status);
    XS:=Cross(Status,-1.5) AND Ref(Status,-1)=-2;
    EL

    {Exit Long}

    BullTrend:=Cross(Mov(C,5,S),Max(Mov(C,10,S),Mov(C,20,S)));
    BearTrend:=Cross(Min(Mov(C,10,S),Mov(C,20,S)),Mov(C,5,S));
    Trend:=If(BarsSince(Ref(BullTrend,-1))<BarsSince(Ref(BearTrend,-1)),1,-1);
    EnterLong:=Trend=1 AND Cross(Stoch(14,3),25);
    ExitLong:=Trend=1 AND Cross(75,Stoch(14,3));
    EnterShort:=Trend=-1 AND Cross(75,Stoch(14,3));
    ExitShort:=Trend=-1 AND Cross(Stoch(14,3),25);
    Status:=If(EnterLong,2,If(EnterShort,-2,If(ExitLong,1,If(ExitShort,-1,PREV))));
    EL:=Cross(Status,1.5);
    XL:=Cross(1.5,Status) AND Ref(Status,-1)=2;
    ES:=Cross(-1.5,Status);
    XS:=Cross(Status,-1.5) AND Ref(Status,-1)=-2;
    XL

    {Enter Short}

    BullTrend:=Cross(Mov(C,5,S),Max(Mov(C,10,S),Mov(C,20,S)));
    BearTrend:=Cross(Min(Mov(C,10,S),Mov(C,20,S)),Mov(C,5,S));
    Trend:=If(BarsSince(Ref(BullTrend,-1))<BarsSince(Ref(BearTrend,-1)),1,-1);
    EnterLong:=Trend=1 AND Cross(Stoch(14,3),25);
    ExitLong:=Trend=1 AND Cross(75,Stoch(14,3));
    EnterShort:=Trend=-1 AND Cross(75,Stoch(14,3));
    ExitShort:=Trend=-1 AND Cross(Stoch(14,3),25);
    Status:=If(EnterLong,2,If(EnterShort,-2,If(ExitLong,1,If(ExitShort,-1,PREV))));
    EL:=Cross(Status,1.5);
    XL:=Cross(1.5,Status) AND Ref(Status,-1)=2;
    ES:=Cross(-1.5,Status);
    XS:=Cross(Status,-1.5) AND Ref(Status,-1)=-2;
    ES

    {Exit Short}

    BullTrend:=Cross(Mov(C,5,S),Max(Mov(C,10,S),Mov(C,20,S)));
    BearTrend:=Cross(Min(Mov(C,10,S),Mov(C,20,S)),Mov(C,5,S));
    Trend:=If(BarsSince(Ref(BullTrend,-1))<BarsSince(Ref(BearTrend,-1)),1,-1);
    EnterLong:=Trend=1 AND Cross(Stoch(14,3),25);
    ExitLong:=Trend=1 AND Cross(75,Stoch(14,3));
    EnterShort:=Trend=-1 AND Cross(75,Stoch(14,3));
    ExitShort:=Trend=-1 AND Cross(Stoch(14,3),25);
    Status:=If(EnterLong,2,If(EnterShort,-2,If(ExitLong,1,If(ExitShort,-1,PREV))));
    EL:=Cross(Status,1.5);
    XL:=Cross(1.5,Status) AND Ref(Status,-1)=2;
    ES:=Cross(-1.5,Status);
    XS:=Cross(Status,-1.5) AND Ref(Status,-1)=-2;
    XS
    My Site
  •  01-18-2005, 19:22 357 in reply to 327

    Dual Orbit System

    I believe the Formula for the second system is :

    {Enter Long}

    HiVal:=Mo(H,10);
    LoVal:=Mo(L,10);
    RnVal:=Mo(H-L,6);
    BC:=Cross(Min(HiVal,LoVal),RnVal);
    SC:=Cross(RnVal,Max(HiVal,LoVal));
    BC AND BarsSince(Ref(BC,-1))>BarsSince(Ref(SC,-1))

    {Enter Short}


    HiVal:=Mo(H,10);
    LoVal:=Mo(L,10);
    RnVal:=Mo(H-L,6);
    BC:=Cross(Min(HiVal,LoVal),RnVal);
    SC:=Cross(RnVal,Max(HiVal,LoVal));
    SC AND BarsSince(Ref(BC,-1))<BarsSince(Ref(SC,-1))

    They also use a trailing stop at 10%
    My Site
View as RSS news feed in XML