[description = This indicator is designed to allow for a quick scan of a stock to decide today's action - BUY or SELL (or No Action - neither buy nor sell). It should therefore be possible to manage a portfolio in under a minute - hence One Minute Manager (OMM). It is designed to be used on a weekly chart;author=Bleakley, Des;target=price;] { **** DEFINE STATIC PARAMETERS **** } roc_bars := 52; emasmooth := 10; MA_OUT := 5; MA_IN := 5; MA_method := SIMPLE; TP_ATR_num := 3; close_hf := 6; max_bar_num := lastvalue(barnumber); lastbar := barnumber = max_bar_num; earlybar := barnumber < 65 ; { **** CALCULATE RAW AND SMOOTHED RATE OF CHANGE **** } boughtprice := hist(CLOSE, roc_bars); risetodate := CLOSE - boughtprice; risepc := (risetodate/boughtprice)*100; smoothpcS := ma( risepc, emasmooth, S); smoothpcE := ma( risepc, emasmooth, E); smoothpc_up_one := hist(smoothpcS,1) < smoothpcS; smoothpc_down_one := hist(smoothpcE,1) >= smoothpcE; smoothpc_up_two := hist(smoothpc_up_one,1) AND smoothpc_up_one; smoothpc_down_two := hist(smoothpc_down_one,1) AND smoothpc_down_one; { **** HAS BELL RUNG NEARBY? **** } roc_st := roc(CLOSE,14,PERCENT); bell := cross(roc_st,0); bell_nearby := barssince(bell) <6 AND roc_st >0; { **** DEFINE MA5 CALCULATIONS **** } MA_down_one := hist(ma(CLOSE,MA_OUT,MA_method),1) >= ma(CLOSE,MA_OUT,MA_method); MA_down_two := hist(MA_down_one,1) AND MA_down_one; MA_up_one := hist(ma(CLOSE,MA_IN,MA_method),1) < ma(CLOSE,MA_IN,MA_method); MA_up_two :=hist(MA_up_one,1) AND MA_up_one; { **** DEFINE HAPPY FACE CALCULATIONS **** } ATR_profit_line := (ma(CLOSE,13,SIMPLE) + TP_ATR_num*ATR(21)); happy_face := C >= ATR_profit_line; happy_face_nearby := barssince(happy_face)< close_HF; last_HF_value := if(earlybar, CLOSE, if(happy_face, CLOSE, prev)); first_HF := happy_face AND NOT hist(happy_face_nearby,1); { **** DEFINE UPTICK CALCULATIONS **** } up_tick := CLOSE > hist(CLOSE,close_HF)*1.2; up_tick_nearby := barssince(up_tick)< close_HF; last_UT_value := if(earlybar, 0, if(up_tick_nearby AND CLOSE>prev, CLOSE, prev)); { **** DEFINE EXIT CONDITIONS **** } ex_1 := MA_down_one AND smoothpc_down_one ; ex_2 := happy_face_nearby AND MA_down_one AND CLOSE= HHV(Close,close_HF); ex_3 := happy_face_nearby AND smoothpc_down_one AND CLOSE= HHV(Close,close_HF); ex_4 := up_tick_nearby AND MA_down_one AND NOT bell_nearby AND CLOSE= HHV(Close,close_HF); primaryexit := ex_1 OR ex_2 OR ex_3 OR ex_4; { **** DEFINE ENTER CONDITIONS **** } en_1 := TRUE; en_2 := MA_up_two AND smoothpc_up_two; en_3 := MA_up_two AND smoothpc_up_one AND bell_nearby; primaryentry := en_1 AND (en_2 OR en_3) ; good_candle := CLOSE>OPEN; { **** DEFINE ACTIONABLE ENTRY & EXIT CONDITIONS **** } exitcondition := NOT good_candle AND primaryexit; entercondition := good_candle AND NOT primaryexit AND primaryentry AND NOT first_HF; no_action := NOT (exitcondition OR entercondition); { **** ARE WE IN OR OUT OF THE MARKET? **** } INMKT := if( earlybar, FALSE, if( prev AND exitcondition, FALSE, if( NOT prev AND entercondition, TRUE, prev))); { **** CHANGE FROM INMKT TO NOT INMKT DEFINES BUY/SELL SIGNALS **** } buysignal := NOT hist(INMKT,1) AND INMKT; sellsignal := hist(INMKT,1) AND NOT INMKT; { **** DISPLAY PRIMARY ENTRY / EXIT ARROWS **** } [name=BUY;linestyle=marker;marker=type13;color=blue;]buysignal; [name=SELL;linestyle=marker;marker=type14;color=blue;]sellsignal; { **** DISPLAY INTERMEDIATE ARROWS - SELECT AT RUN TIME **** } [Name = SAPinlb; Linestyle = marker; color=green;marker = type13;size=large;visible=false;]; lastbar AND entercondition; [Name = SAPin;Linestyle = marker; color=green;marker = type13;size=tiny;visible=false;]; NOT lastbar AND entercondition; [Name = SAPoutlb;linestyle=marker;marker=type14;color=red;size=large;visible=false;]; lastbar AND exitcondition; [Name = SAPout;linestyle=marker;marker=type14;color=red;size=tiny;visible=false;]; NOT lastbar AND exitcondition; [Name = NO-ACTION;linestyle=marker;marker=type12;color=orange;size=large;visible=false;]; lastbar AND no_action; { **** DISPLAY BUY/SELL/HOLD COMMENTARY **** } [Linestyle = text; color=blue;font=14;fontstyle=bold;]; [Name = HOLD; color=orange]; if (lastbar AND no_action," HOLD "+security.symbol,undefined);close; [Name = BUY; color=green]; if (lastbar AND entercondition," BUY "+security.symbol,undefined);close; [Name = NO-ACTIONt3; color=red]; if (lastbar AND exitcondition, " SELL "+security.symbol+" NOW",undefined);close;