Simple Coding Help - No Promise.

amitrandive

Well-Known Member
Amibrokers Default Zigzag tool and the tool from your 2nd link is not like in my image.
It doesnt draw a line on candles.
Depends on what percentage of price you define in the parameters.:D



Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("ZIG - Zig");
P = ParamField( "Price field" );
change = Param("% change",5,0.1,25,0.1);
Plot( Zig(P, change), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
 

amitrandive

Well-Known Member
Amibrokers Default Zigzag tool and the tool from your 2nd link is not like in my image.
It doesnt draw a line on candles.

Another version of it :D



Code:
_SECTION_BEGIN("ZIG-ZAG");
Z=Param("zig",1,0,10,0.1);
Plot( z1 = Zig(C,z), "Zig-zag Indicator" + _PARAM_VALUES(), ParamColor("Zig-zag color", colorOrange ), ParamStyle("Zig-zag style") );
 
Buy = Cover = Zig(C,z)>Ref(Zig(C,z),-1) AND Ref(Zig(C,z),-2)>Ref(Zig(C,z),-1);
Sell = Short = Zig(C,z)<Ref(Zig(C,z),-1) AND Ref(Zig(C,z),-2)<Ref(Zig(C,z),-1);
 
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
 
Filter = Buy OR Sell;
 
PlotShapes(IIf(Buy, shapeCircle, shapeNone),colorGreen, 0,BuyPrice, 0);
PlotShapes(IIf(Sell, shapeCircle, shapeNone),colorRed, 0,SellPrice, 0);
 
dist = 1.5*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy[i] ) PlotText( "BUY\n"+C[ i ], i, BuyPrice[i]-dist[i],colorWhite, colorGreen );
if( Sell[i] ) PlotText( "SELL\n"+C[ i ], i, SellPrice[i]+dist[i],colorWhite, colorRed );
//if( Short[i] ) PlotText( "Short\n@" + C[ i ], i, H[ i ]+dist[i], colorRed, colorYellow );
//if( Cover[i] ) PlotText( "Cover\n@" + C[ i ], i, L[ i ]-dist[i],colorGreen );
}
 

Mungus

Well-Known Member
Depends on what percentage of price you define in the parameters.:D



Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("ZIG - Zig");
P = ParamField( "Price field" );
change = Param("% change",5,0.1,25,0.1);
Plot( Zig(P, change), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
What value did you use here?
 

bapu4

Well-Known Member
Hi,
Can some one give me exploration AFL for exploration of hammer/long pinbar near top of bollinger/out of top of bollinger and similarly at bottom of bollinger or out of bottom bollinger . This is for probable trend reversal
so the parameters should be for the reversal condition.TF 30MTF,60MTF,EOD,WKLY.Period three months.
If its not available can someone write it for me ?
 
Last edited:
Hello all. and thanks and appreciate that, any one can help me please convert this code from tradestation to amibroker , this is very easy for you . thanks and appreciate that . this is one of the main my indicator for trading reversal in tradestation . thanks .
Code:
//---------------------------------------------------------------------------------------------
inputs:PriceH( High ), PriceL( Low ),  PriceC( Close ), StochLength( 14 ), 
SmoothingLength1( 3 ), SmoothingLength2( 3 ), SmoothingType( 1 ), 
OverSold( 10 ), OverBought( 90 ),OverSColor( Green ), 
OverBColor( Magenta ), MinMaxPeriod(50) ;

variables: MySto(0), min(0), max(0), range(0),oFastK( 0 ), 
oFastD(0), oSlowK(0), oSlowD(0) ;

value1 = Stochastic( PriceH, PriceL, PriceC, StochLength, SmoothingLength1,
SmoothingLength2, SmoothingType, oFastK, oFastD, oSlowK, oSlowD ) ;

MySto  = oSlowK;
min = 100;
max = 0;
for value1=0 to MinMaxPeriod-1 begin
	if min>MySto[value1] then min=MySto[value1];
	if max<MySto[value1] then max=MySto[value1];
end;

range = max-min;
Plot1( MySto, "Stochastic" ) ;
Plot2( min+range*OverSold/100  , "OverSold" ) ;
Plot3( min+range*OverBought/100, "OverBought" ) ;

if MySto < plot2 then 
SetPlotColor( 1, OverSColor ) 
else 
if MySto > plot3 then 
SetPlotColor( 1, OverBColor ) ;
//-------------------------------------------------------------------------------------
 
Last edited:

oldtrader

Well-Known Member
Hi

Since you guys are into testing systems and optimization etc, using SAR type of systems . . .

Using a stop Loss ......

But using Profit Stops wit...

But the profit booking sho...

try this code for range
Code:
//PROFITSTOP
Profit = Optimize("Profit", 500,0,1250,50);
PS = IIf(Buy OR Short,Null,IIf(Flip(Buy,Sell),ValueWhen(Buy,Close)+Profit,ValueWhen(Short,Close)-Profit));
Plot(PS,"",colorLightGrey,styleNoRescale|styleDashed|styleStaircase);
ApplyStop(stopTypeProfit,stopModePoint,Profit);
A word about ..........
Thanks

Happy :)

Hi Happy Singh,

Need your help very badly to run optimization with profit code included. I need a little change in the profit parameters. Instead of the profit range of 0 to 1250 points , I would like to check as percentage of trigger price. I would prefer a percentage range of 0 to 10. Please suggest the necessary changes to the code.

Thinking in percentage wise to accomodate the change in NF rate over a period of time.

Regards,
Oldtrader
Please look into this
 
Hello all. and thanks and appreciate that, any one can help me please convert this code from tradestation to amibroker , this is very easy for you . thanks and appreciate that . this is one of the main my indicator for trading reversal in tradestation . thanks .
Code:
//---------------------------------------------------------------------------------------------
inputs:PriceH( High ), PriceL( Low ),  PriceC( Close ), StochLength( 14 ), 
SmoothingLength1( 3 ), SmoothingLength2( 3 ), SmoothingType( 1 ), 
OverSold( 10 ), OverBought( 90 ),OverSColor( Green ), 
OverBColor( Magenta ), MinMaxPeriod(50) ;

variables: MySto(0), min(0), max(0), range(0),oFastK( 0 ), 
oFastD(0), oSlowK(0), oSlowD(0) ;

value1 = Stochastic( PriceH, PriceL, PriceC, StochLength, SmoothingLength1,
SmoothingLength2, SmoothingType, oFastK, oFastD, oSlowK, oSlowD ) ;

MySto  = oSlowK;
min = 100;
max = 0;
for value1=0 to MinMaxPeriod-1 begin
	if min>MySto[value1] then min=MySto[value1];
	if max<MySto[value1] then max=MySto[value1];
end;

range = max-min;
Plot1( MySto, "Stochastic" ) ;
Plot2( min+range*OverSold/100  , "OverSold" ) ;
Plot3( min+range*OverBought/100, "OverBought" ) ;

if MySto < plot2 then 
SetPlotColor( 1, OverSColor ) 
else 
if MySto > plot3 then 
SetPlotColor( 1, OverBColor ) ;
//-------------------------------------------------------------------------------------
i think , this is very easy for yours , please look at this one .
 

amitrandive

Well-Known Member
Hello Friends

I am starting this thread for helping anyone who requires small changes in AFLs or AFL coding done for small / simple requirements that can be clearly defined.

What does not go is conversion . . . from Amibroker to anything else . . . or from anything else to Amibroker . . .

Debugging requested for copy/paste AFLs, Please don't post huge AFLs with zillions of lines of code for debugging

I will not be available for any conversions and I am not interested in debugging some-one else's copy/pasted work and lastly . . .
Not interested in hacking/craking any ones work . . .

Only if have a clearly definable task to be coded I maybe able to help . . . No Promises but will try within my limitations . . .


As an example, recently one of our friends wanted a motivational message to be included in his Charts,
I enjoyed doing that, as i could easily empathize with why he wanted that . . .


Cheers

:) Happy
Hello all. and thanks and appreciate that, any one can help me please convert this code from tradestation to amibroker , this is very easy for you . thanks and appreciate that . this is one of the main my indicator for trading reversal in tradestation . thanks .
Code:
//---------------------------------------------------------------------------------------------
inputs:PriceH( High ), PriceL( Low ),  PriceC( Close ), StochLength( 14 ), 
SmoothingLength1( 3 ), SmoothingLength2( 3 ), SmoothingType( 1 ), 
OverSold( 10 ), OverBought( 90 ),OverSColor( Green ), 
OverBColor( Magenta ), MinMaxPeriod(50) ;

......
//-------------------------------------------------------------------------------------
Only small help and modifications,as specified by the thread owner

Similar Stochastic code,courtesy wisestocktrader site......................

http://www.wisest ocktra der.com/indicators/1149-stochastic
Code:
_SECTION_BEGIN("Stochastic");
 
periods = Param( "Periods", 15, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
myStochD=StochD( periods , Ksmooth, DSmooth );
myStochK=StochK( periods , Ksmooth);
Overbought=80;
Oversold=20;
 
Buy = Cross(myStochK, myStochD );
Sell = Cross( myStochD, myStochK );
 
Plot( myStochD, "Stochastic %D"+_PARAM_VALUES(), ParamColor( "ColorD", colorRed ), ParamStyle("StyleD") );
Plot( myStochK, "Stochastic %K", ParamColor( "ColorK", colorGreen ), ParamStyle("StyleK") );
 
PlotShapes(IIf(Sell, shapeHollowDownArrow , shapeNone), colorRed);
PlotShapes(IIf(Buy, shapeHollowUpArrow , shapeNone), colorBlue);
 
Plot(Overbought,"Overbought Level",colorRed);
Plot(Oversold,"Oversold Level",colorGreen); 
 
 
PlotOHLC( myStochK,myStochK,50,myStochK, "", colorRed, styleCloud | styleClipMinMax, 20, 80 );
PlotOHLC( myStochD,myStochD,50,myStochD, "", colorYellow, styleCloud | styleClipMinMax, 20, 80 );
 
PlotOHLC( Null,myStochD,myStochK,Null, "", colorBlue, styleCloud); 
 
 
_SECTION_END();
 
Last edited:

Similar threads