Help Needed with Trade Station coding?

Discussion in 'Strategy Building' started by Aspen, Aug 21, 2003.

  1. Aspen


    I was hoping to get some feedback on a good way to add a filter to one system that I am working on for Trade Station. Currently, it runs on end of day data and has produced good results.

    I am hoping that someone has already developed a way to check a condition, say that the 'slope' of a moving average is xx, then you would begin the strategy?

    In this way, I am hoping to be able to 'filter' out trades that are produced when the market is going sideways.

    Any help or suggestions are appreciated - thanks!!!
  2. Maybe I'm missing something, but if you just coded:

    inputs: malength(20),slopemin(1);

    if (average(c,malength)-average(c[1],malength))>slopemin then begin

    {insert code here}


    Would this do the trick?
  3. Aspen


    Thank you for being so prompt with your response MYDemaray.

    I assume that "malength" = moving average length (bars), but when you are talking about "slopemin", do you mean that (1) = 45 degree angle or that the value must be greater than 1? How does that figure get incorporated into the logic? Basically, are you saying that "if the average close over the past 20 days minus the average close of the past 21 to 1 day ago is greater than 1, than start the code"? That sounds like it would only say that the close of today's bar is greater than the close of yesterday's bar?

    Please elaborate, and thanks again for working with me on this.
  4. ... Very Bad coding...

    Variable: MA(0), Slope(0);

    Input: Length(20);

    MA = Average(Close, Length);

    Slope = MA - MA[1];

    If Slope > XXXX{Put in what ever number} then Begin;
  5. For a mechanical system you can state that slope is greater or less than 1 (ie positive or negative) but you can't use a specific slope value as a filter. The reason for this is that by simply changing the increment values on the price axis you alter the degree of angle on your slope.

    A better way to quantify an accelerating market is ROC. Try using ROC on (MA - MA[1]) or something like that.

    Hope this helps
  6. Sorry this was so sloppy. Just slapped it up to give an idea of what you might try. Slopemin was supposed to be whatever slope minimum you were looking for. I guess the take away is, try nesting your trade commands in an if/then begin/end statement. You can put whatever parameters you want in there. Good luck,