Sorry, I should have offered a larger explanation of my Hammer example.
My definition of a Hammer (“Technical Analysis from A to Z “– Steven B. Achelis) is a japanese candlestick pattern resembling a hammer, that is to say, A head body along with a trailing shadow. This pattern is bullish when it is preceded by a significant downtrend. (I have paraphrased rather than quoted)
In a message , Monty Lenard, (9034) suggested a scan coding for a hammer which caught my eye, as a good exercise. In it he described the hammer formation in two lines:
If… Open ( i ) => low ( i ) + range ( i ) * .50 and close ( i ) => low ( i ) + range ( i ) * .50 and ….
I thought that it might work well if the preceding “significant downturn might be found by using a walking EMA scan. Therefore:
Last :=0; // initialize last For day = 0 to –30 step –1 do // walk back from today for 30 days Temp := EmovAvg (day, 26, cl) // get the EmovAvg value for current day. If temp < last then // check to see that we are on a down slope, if not, abort (note since we are walking backwards, each new value must be higher than the preceding one)
Flag := 0; // kill printing Day := -30; //Set day to end for loop Else Last := temp; // update last and continue.. endif; next day;
The only other part of the code that was of interest was in the criteria section, which specifies: MACD(0) <= 0 // which specifies that the 12 day EMA is below the 26 day EMA thus indicating (but not guaranteeing) a down trend.
Since the Hammer formation is specified for today only, it will not report them if they don't exist.. Fortunately when I tested this, I had several show up.. I suppose that to back test this, one could walk backward using the hammer formation test until a hammer was found, and then check it's bullish portent by testing to see if there was a significant down turn preceding it. Otherwise remove the price limiting criteria.
regards pete
The general code is organised If criteria is true ( a hammer is found and the stock is within price range and Macd is below 0 (which doesn't neccessarily suggest downturn although it does indicate it..) Then run a slope test for thirty days and if that indicates a slope, print it.
|