Jesse Livermore Secret Market Key
The Jesse Livermore Secret Market Key AFL might be inspired by Jesse Livermore’s trading principles or strategies. It could offer unique insights or indicators derived from Livermore’s trading philosophy. With an Amibroker data feed, this AFL aids traders by providing signals or tools aligned with Livermore’s methodologies for market analysis.
///------------------------------------------------------------------------------ // Formula Name : Project Freedom - Jesse Livermore Secret Market Key // Author : KH Tang // Date Updated : 30 Apr 2007 // Origin : Personal Study and Understanding of Livermore's work // Version : 1.0 // Blog : http://blessedfool.gaia.com/blog //------------------------------------------------------------------------------ /* //------------------------------------------------------------------------------ Program Overview This program classifies price action into the following states based upon rules his book - "How to Trade in Stocks" StateNo1 - Up Trend StateNo2 - Nat Rally StateNo3 - Sec Rally StateNo4 - Dn Trend StateNo5 - Nat React StateNo6 - Sec React State change is determined by a user specified threshold of price change. The program also determines a number of pivot points: UpTrendPP - Peak Up Trend Price NatRallyPP - Peak Nat Rally Price DnTrendPP - Bottom Dn Trend Price NatReactPP - Bottom Nat React Price This program may be used as a basis for a number of studies: - trend paint bars, - pivot price indicator lines - strategies (trend following AND/OR breakout/breakDn) For detailed explanation of the system Jesse Livermore Orginal Work. Note: Livermore's system used a threshold of 6 points for stocks priced over $30. For modern Market, due to different markets has wide range of prices. The threshold price is set in Percentage...(default 10%) //------------------------------------------------------------------------------ */ // General Graphic Control GraphXSpace = 15; SetChartBkGradientFill( ParamColor("BgTop", colorSkyblue), ParamColor("BgBottom", colorWhite),ParamColor("titleblock",colorWhite)); ThresholdPercentValue = Param("Threshold in Percent units",10,4,15,1); for( i=0; i=C[i-1]) {//Price Move Up if(C[i]>UpTrend[i]) { StateNo[i]=1;//Remain in UpTrend - 1111111111111111111111111111111 InUpTrend[i]=True; InDnTrend[i]=False; UpTrend[i]=C[i]; } }//End of Price Move Up else {//Price Move Dn if((InDnTrend[i] AND C[i] C[i-1]) {//Price Move Up if( (InUpTrend[i] AND C[i]>UpTrendPP[i]) OR (InDnTrend[i] AND C[i]> DnTrend[i]*(1+2*ThresholdPct[i])) ) {//Price move to UpTrend - 1111111111111111111111111111111111111111111 StateNo[i]=1; InUpTrend[i]=True; InDnTrend[i]=False; UpTrend[i]=C[i]; }//End of Price Move to UpTrend else { if(C[i]>NatRally[i]) {//Price Continue to move to higher NatRally StateNo[i]=2;//Remain in NatRally - 222222222222222222222222222 NatRally[i]=C[i]; NatRallyReset[i]=False; }//End of Price Continue to move to higher NatRally } }//End of Price Move Up else //of(C[i]>C[i-1]) {//Price Move Dn if((InDnTrend[i] AND C[i] C[i-1]) {//Price Move Up if( (InUpTrend[i] AND C[i]>UpTrendPP[i]) OR (InDnTrend[i] AND C[i]> DnTrend[i]*(1+2*ThresholdPct[i])) ) {//Price move to UpTrend - 1111111111111111111111111111111111111111111 StateNo[i]=1; InUpTrend[i]=True; InDnTrend[i]=False; UpTrend[i]=C[i]; }//End of Price Move to UpTrend else { if(C[i]>NatRally[i]) {//Price Continue to move to higher NatRally StateNo[i]=2;//Remain in NatRally - 222222222222222222222222222 NatRally[i]=C[i]; NatRallyReset[i]=False; }//End of Price Continue to move to higher NatRally else {//Remain at SecRally State if(C[i]>SecRally[i]) {//New Higher Sec Price - 3333333333333333333333333333333333333 StateNo[i]=3;//Remain in SecRally State SecRally[i]=C[i];//Update new higher price }//End of New Higher Sec Price }//End of Remain at Sec State } }//End of Price Move Up else //of(C[i]>C[i-1]) {//Price Move Dn if((InDnTrend[i] AND C[i] C[i-1]) {//Price Move Up if( (InUpTrend[i] AND C[i]>UpTrendPP[i]) OR (InDnTrend[i] AND C[i]> DnTrend[i]*(1+2*ThresholdPct[i])) ) {//Price move to UpTrend - 1111111111111111111111111111111111111111111 StateNo[i]=1; InUpTrend[i]=True; InDnTrend[i]=False; UpTrend[i]=C[i]; }//End of Price Move to UpTrend else { if(C[i]>(SecReact[i]*(1+ThresholdPct[i]))) {//Raise Above Current State React if(C[i]>NatRally[i]) { StateNo[i]=2;//Move to NatRally - 2222222222222222222222 NatRally[i]=C[i]; NatRallyReset[i]=False; } else {//Raise to SeconaryRally StateNo[i]=3;//Raise to SecRally - 333333333333333333333 SecRally[i]=C[i]; }//End of Raise to SecRally }// End of Raise Above Current State React } }//End of Price Move Up else //of(C[i]>C[i-1]) {//Price Move Dn if((InDnTrend[i] AND C[i] C[i-1]) {//Price Move Up if( (InUpTrend[i] AND C[i]>UpTrendPP[i]) OR (InDnTrend[i] AND C[i]> DnTrend[i]*(1+2*ThresholdPct[i])) ) {//Price move to UpTrend - 1111111111111111111111111111111111111111111 StateNo[i]=1; InUpTrend[i]=True; InDnTrend[i]=False; UpTrend[i]=C[i]; NatReactPP[i]=NatReact[i]; }//End of Price Move to UpTrend else { if(C[i]>(NatReact[i]*(1+ThresholdPct[i]))) {//Raise Above Current State React if(NatRallyReset[i] OR C[i]>NatRally[i]) { StateNo[i]=2;//Move to NatRally - 2222222222222222222222 NatRallyReset[i]=False; NatRally[i]=C[i]; NatReactPP[i]=NatReact[i]; } else {//Raise to SeconaryRally StateNo[i]=3;//Raise to SecRally - 333333333333333333333 SecRally[i]=C[i]; NatReactPP[i]=NatReact[i]; }//End of Raise to SecRally }// End of Raise Above Current State React } }//End of Price Move Up else //of(C[i]>C[i-1]) - Common with State 1 {//Price Move Dn if((InDnTrend[i] AND C[i] C[i-1]) {//Price Move Up if( (InUpTrend[i] AND C[i]>UpTrendPP[i]) OR (InDnTrend[i] AND C[i]> DnTrend[i]*(1+2*ThresholdPct[i])) ) {//Price move to UpTrend - 1111111111111111111111111111111111111111111 StateNo[i]=1; InUpTrend[i]=True; InDnTrend[i]=False; UpTrend[i]=C[i]; DnTrendPP[i]=DnTrend[i]; }//End of Price Move to UpTrend else { if(C[i]>(DnTrend[i]*(1+ThresholdPct[i]))) {//Raise Above Current State React if(NatRallyReset[i] OR C[i]>NatRally[i]) { StateNo[i]=2;//Move to NatRally - 2222222222222222222222 NatRallyReset[i]=False; NatRally[i]=C[i]; DnTrendPP[i]=DnTrend[i]; } else {//Raise to SeconaryRally StateNo[i]=3;//Raise to SecRally - 333333333333333333333 SecRally[i]=C[i]; DnTrendPP[i]=DnTrend[i]; }//End of Raise to SecRally }// End of Raise Above Current State React } }//End of Price Move Up else //of(C[i]>C[i-1]) - Common with State 1 {//Price Move Dn if(C[i] DnTrend[i]*(1+2*ThresholdPct[i]) ) { NatRallyReset[i]=True; } } //end; //{main} } //End of For i Loop! //Plotting Section - Just for testing //InUpTrend WeightNo= IIf(StateNo==1,5, // UpTrend IIf(InUpTrend AND StateNo==5,1, // and NatReact IIf(InUpTrend AND StateNo==2,4, // and NatRally IIf(InUpTrend AND StateNo==4,2, // and SecReact IIf(InUpTrend AND StateNo==3,3, // and SecRally IIf(StateNo==6,-5, // DownTrend IIf(InDnTrend AND StateNo==2,-1, // and NatRally IIf(InDnTrend AND StateNo==5,-4, // and NatReact IIf(InDnTrend AND StateNo==3,-2, // and SecRally -3 // and SecReact ))))))))); Plot(WeightNo,"Livermore Secret Market Key Stage Diagram",IIf(WeightNo>0 AND WeightNo==5,colorGreen, IIf(WeightNo>0,colorBlue, IIf(WeightNo<0 AND WeightNo==-5,colorRed,colorPink))),styleStaircase); Plot(0,"",colorBlack,styleNoLabel); //End of Livermore Market Key Section