Trend Filter using Power Language

Discussion in 'App Development' started by Tahu, Jul 3, 2014.

  1. Tahu

    Tahu

    Hey fellow Quants and Programmers at Elite Trader,

    Short introduction of myself: I'm a (very) new and young trader who has his origin in quantum physics, vector analysis and electronics, but has grown extremley fond of trading stocks and have got most of my TA-theory from John J. Murphy - "Technical Analysis Of The Finachial Markets".

    I've been programming Java most of my life, and have just started to learn PL. I've learned to analyse a stock that is trending or somewhat to the verge of trending, but I'm having difficulties finding these from my live-feed from which I can collect +2200 stocks from different markets. I somehow need to filter out those which I find interesting.

    As trading software I'm one of few in my country who has a license to Multicharts, and have been using that together with some other candlestick-pattern recognition software.

    To my actual question: I need to construct some sort of filter to sort trending stocks from the non-trending stocks. To make it easy and to have some kind of start my programming logic will be the following:

    1. Recognize at least 3 consecutive candlestick ups.
    2. Check so RSI is under 80 to avoid extremes.

    Nothing more advanced than that to begin with. If these two conditions are met, then plot a 1 otherwise plot 0. My code turned out the following:

    Code:
    inputs:
    	Price ( Close ),
    	ConsecutiveBarsUp ( 3 ),
    	Length(14);
    	
    variables:
    	var0(0);
    	
    var0 = RSI(Price, Length);
    	
    if Price > Price[1] then
    	Value1 = Value1 + 1
    	
    else
    	Value1 = 0;
    	
    if Value1 >= ConsecutiveBarsUp and var0 < 80 then 
    	begin
    	Plot1( 1, "ConsecTrend" );
    	Alert;
    	end	
    else
    	NoPlot( 0 );
    The type of code is set as an indicator. It's not working but instead it is set as 1 all the time. I'm having a hard time understanding how return types work in PL, but it seems like this shouldn't be too hard to fix. Constructive feedback would be very apperciated, what needs to be changed in the code?

    As a second question regarding my approach of finding trending stocks, would ADX & DMI work better than consecutive ups?


    Kind Regards,
    Tahu
     
  2. Tahu

    Tahu

    Update! I solved the code issue. Wasn't a too big error.

    The thread will remain on the other topic though: Is ADX & DMI a better approach for finding trending signals than consecutive ups? (Both technical and programming speaking).


    All the best,
    Tahu
     
  3. jcl366

    jcl366

    If you have a quantum physics background, the answer will probably not surprise you: neither.

    Detecting trend early is a difficult task with no standard solution, especially since trend can be caused by several different reasons. But neither counting candles, not RSI or ADX are suited for solving that problem, and the book by Murphy is totally useless for algorithmic trading.

    What might help are books about market microstructure, and about practical analysis of price curves, such as the books by John Ehlers.
     
  4. Try using R or rapid miner to find patterns predating a trend.
     
  5. panzerman

    panzerman

    I like Ehlers work using DSP methods. His latest work on trends is in his new book "Cycle Analytics...." called the decycler.

    Of course an argument against using DSP in the markets is that there is no noise, it is all signal. Also, that while Ehlers concepts and math are sound, using DSP on financial data is a misapplication. You get to decide.
     
  6. A suggestion (that a lot of people don't seem to think about here) is to look for conditional responses of candidates. I.e. rather than screening for candidates that exhibit trend like tendencies, look for candidates that have persistent trends given a prior trending period, etc...

    Given your background, you are likely familiar with conditional probabilities.
     
  7. Sergio77

    Sergio77

    Is this power language the same as easylanguage?
     
  8. jcl366

    jcl366

    Yes.