Simple Coding Help - No Promise.

Seniors,

Below is the basic Stochastic momentum indicator from Amibroker.

HTML:
_SECTION_BEGIN("Stochastic Momentum");
LookBack = Param("Lookback", 13, 2, 100 );
Smooth1 = Param("Smooth 1", 25, 1, 100 );
Smooth2 = Param("Smooth 2", 2, 1, 100 );

HH = HHV( H, LookBack );
LL = LLV( L, LookBack );

StoMom = 100 * EMA( EMA( C - 0.5 * ( HH + LL ), Smooth1 ), Smooth2 ) / 
( 0.5 * EMA( EMA( HH - LL, Smooth1 ), Smooth2 ) );

Plot(StoMom, _DEFAULT_NAME(), ParamColor("Color", ColorCycle ) );
_SECTION_END();
I need 3 lines in it :-
1. 1st line - at +50 level
2. 2nd line - at 0 level
3. 3rd line - at -50 level

Also, need an exploration(with buy and sell signals + arrows) based on Stochastic indicator as per below conditions:-
1. Buy when Stochastic momentum moves above -50 level.
2. Sell when Stochastic momentum moves below +50 level.

Thanks,
Ashish
 
NOT CORRECT but small effort: for above condition:

Code:
_SECTION_BEGIN("Stochastic Momentum");
LookBack = Param("Lookback", 13, 2, 100 );
Smooth1 = Param("Smooth 1", 25, 1, 100 );
Smooth2 = Param("Smooth 2", 2, 1, 100 );

HH = HHV( H, LookBack );
LL = LLV( L, LookBack );

StoMom = 100 * EMA( EMA( C - 0.5 * ( HH + LL ), Smooth1 ), Smooth2 ) / 
( 0.5 * EMA( EMA( HH - LL, Smooth1 ), Smooth2 ) );

Plot(StoMom, _DEFAULT_NAME(), ParamColor("Color", ColorCycle ) );
_SECTION_END();

Graph2=-50;
Graph3=50;
Graph4=-48;
Graph6=48;
Graph5=0;

Plot(Graph5,"",2,1);
Plot(Graph2,"",8,1);
Plot(Graph3,"",4,1);

Buy =  Cross(Graph2,StoMom); buy1=  StoMom > Graph4;
Sell= Cross( StoMom,Graph3 ); sell1=  StoMom <Graph6;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

Buy1 = ExRem(Buy1,Sell1);
Sell1 = ExRem(Sell1,Buy1);

PlotShapes( shapeUpArrow* Buy , colorBlue);
PlotShapes( shapeDownArrow* Sell ,colorRed);

Filter=1;

AddColumn(IIf(Buy ,Ref(c,0) ,Null),"Buy ",6.2,2,29);  
AddColumn(IIf(Sell ,-Ref(c,0),Null),"Sell ",6.2,2,4);
 
NOT CORRECT but small effort: for above condition:

Code:
_SECTION_BEGIN("Stochastic Momentum");
LookBack = Param("Lookback", 13, 2, 100 );
Smooth1 = Param("Smooth 1", 25, 1, 100 );
Smooth2 = Param("Smooth 2", 2, 1, 100 );

HH = HHV( H, LookBack );
LL = LLV( L, LookBack );

StoMom = 100 * EMA( EMA( C - 0.5 * ( HH + LL ), Smooth1 ), Smooth2 ) / 
( 0.5 * EMA( EMA( HH - LL, Smooth1 ), Smooth2 ) );

Plot(StoMom, _DEFAULT_NAME(), ParamColor("Color", ColorCycle ) );
_SECTION_END();

Graph2=-50;
Graph3=50;
Graph4=-48;
Graph6=48;
Graph5=0;

Plot(Graph5,"",2,1);
Plot(Graph2,"",8,1);
Plot(Graph3,"",4,1);

Buy =  Cross(Graph2,StoMom); buy1=  StoMom > Graph4;
Sell= Cross( StoMom,Graph3 ); sell1=  StoMom <Graph6;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

Buy1 = ExRem(Buy1,Sell1);
Sell1 = ExRem(Sell1,Buy1);

PlotShapes( shapeUpArrow* Buy , colorBlue);
PlotShapes( shapeDownArrow* Sell ,colorRed);

Filter=1;

AddColumn(IIf(Buy ,Ref(c,0) ,Null),"Buy ",6.2,2,29);  
AddColumn(IIf(Sell ,-Ref(c,0),Null),"Sell ",6.2,2,4);
Thanks a lot Manoj.. The problem here is it shows buy signal as soon as Stochastic indicator goes below -50 line, whereas correct buy signal should be when Stochastic indicator goes above -50 line. Vice-versa for sell signals..
Again thanks a lot for the afl..:thumb:
 

Nehal_s143

Well-Known Member
guys how to stop displaying the vales by any AFL on the top of the chart ? if there are too many afl applied the values on top of chart clutter too much space :(

Code:
Plot (EMA(RSI(34),9), "Smoothed RSI-5", colorGreen , styleNoLabel | styleThick);
Plot (EMA(RSI(34),20), "Smoothed RSI-14", colorRed , styleNoLabel | styleThick);
Above code will display value for Smoothed RSI-5 & Smoothed RSI-14

If you replace "Smoothed RSI-5" with " " then you will not get any value on top
 
Thanks a lot Manoj.. The problem here is it shows buy signal as soon as Stochastic indicator goes below -50 line, whereas correct buy signal should be when Stochastic indicator goes above -50 line. Vice-versa for sell signals..
Again thanks a lot for the afl..:thumb:
Try this

oversold = Cross(Graph2,StoMom);
buyTrigger = Cross(StoMom, Graph2);
Buy = buyTrigger AND BarsSince(oversold) > BarsSince(buyTrigger);
 
guys how to stop displaying the vales by any AFL on the top of the chart ? if there are too many afl applied the values on top of chart clutter too much space :(
EITHER

add | styleNoTitle for all of the plot statements that you feel are unnecessary

OR

remove the {{VALUES}} from the rvalue of the most recent Title line.

OR

follow the tip given by Nehal in post 3266
 
Last edited:

Similar threads