Hey guy, help me check code alligators

#1
I am rookie in trader.
I am very interesting alligator system
I am adaptive code alligators of bill williams


#####code######
//Robot-Alligators
/* Edit 12/09/2016
Name: nEw*/
/* include 9 part
0.Money Mangaement
1.Alligators
2. Fractals
3. AO&AC
4. MFI Definition
5.Gator Oscillator
6.ZONE Definition
7.Exploration
8.Position Size AND Position Score

*/
//-----------------0.Money Mangaement -------------------------------
// Initial Capital
/*SetOption("InitialEquity", 1000000 );*/
SetOption("InitialEquity", 50000 );
// Commission is set to 0.1%
SetOption("CommissionMode",1);
SetOption("CommissionAmount",0.1);

// Buy/Sell at ATO one day after the signals are triggered
SetTradeDelays(1,1,0,0);
RoundLotSize = 100;
BuyPrice = Open;
SellPrice = Open;

// Maximum position sizes
MaxPos = 30;/*amout stock at buy per signal */
SetOption("MaxOpenPositions", MaxPos);

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

//-----------------1.Alligators -------------------------------
_SECTION_BEGIN("Alligator");

/*** The trend indicators ***/

P=ParamList("Price", "Close|(H+L)/2|(H+C+L)/3",1);

if
(P=="Close")

A = C;

else

if
(P=="(H+C+L)/3")

A = (H+C+L)/3;

else

A = (H+L)/2;

AlligatorJaw =Ref(Wilders(A,13),-8);

AlligatorTeeth =Ref(Wilders(A,8), -5);

AlligatorLips =Ref(Wilders(A,5), -3);

/*plot 3 alligators*/
PlotAlligator=ParamToggle("Plot Alligator?","NO|YES",1);
if(PlotAlligator)
{
Plot(AlligatorJaw, "Jaw", ParamColor("Jaw's Color",colorBlue),ParamStyle("Jaw's Style", styleThick));

Plot(AlligatorTeeth,"Teeth", ParamColor("Teeth's Color",colorRed),ParamStyle("Teeth's Style", styleThick));

Plot(AlligatorLips, "Lips", ParamColor("Lips's Color",colorGreen),ParamStyle("Lips's Style", styleThick));

//require entry ws3 : open>AlligatorRed
AlligatorEntry=0>AlligatorTeeth ;
}

_SECTION_END();

//-----------------2. Fractals -------------------------------
_SECTION_BEGIN("Fractal");
UpFractal=ValueWhen(
(Ref(H,-2) > Ref(H,-4)) AND
(Ref(H,-2) > Ref(H,-3)) AND
(Ref(H,-2) > Ref(H,-1)) AND
(Ref(H,-2) > H),Ref(H,-2));

DownFractal=ValueWhen(
(Ref(L,-2) <= Ref(L,-4)) AND
(Ref(L,-2) <= Ref(L,-3)) AND
(Ref(L,-2) <= Ref(L,-1)) AND
(Ref(L,-2) <= L),Ref(L,-2));

/*plot alligator Fractal Up and Fractal Down*/
PlotFractalUp=ParamToggle("Plot Fractal Up?","NO|YES",1);
if (PlotFractalUp)
{
Plot(UpFractal,"UF",ParamColor("Up Fractal Color",colorBlue),ParamStyle("Up Fractal Style",styleThick|styleDashed));
}
PlotFractalDown=ParamToggle("Plot Fractal Down?","NO|YES",1);
if (PlotFractalDown)
{
Plot(DownFractal,"DF",ParamColor("Down Fractal Color",colorRed),ParamStyle("Up Fractal Style",styleThick|styleDashed));
}
UF=UpFractal;
DF=DownFractal;
_SECTION_END();


//-----------------3.AO&AC -------------------------------
_SECTION_BEGIN("AO&AC");
AOFast = MA( A, 5 );
AOSlow = MA( A, 34 );
AO = AOFast - AOSlow;
AC = AO - MA( AO, 5 );
AOUB = AO > Ref( AO, -1 );
AODB = AO < Ref( AO, -1 );
ACUB = AC > Ref( AC, -1 );
ACDB = AC < Ref( AC, -1 );

// Determine UpBar and DownBar
GrnBar = AOUB AND ACUB;
RedBar = AODB AND ACDB;

// Determine UpBar and DownBar
AOUpBar =AO > Ref(AO ,-1);
AODownBar = AO < Ref(AO ,-1);

//requirement Fractal Up&Down
AboveFractalUp = C > UF;
BelowFractalDown = C < DF;

//Requirement Sourcer BUY and SELL
SoucerUp = ( Ref(AO ,-2) > Ref(AO ,-1) AND Ref(AO ,-1) < AO ) AND AboveFractalUp;
SoucerDown = (Ref(AO ,-2) < Ref(AO ,-1) AND Ref(AO ,-1) > AO ) AND BelowFractalDown ;

SoucerBuy = (SoucerUp AND (AO > 0 AND Ref(AO ,-1) > 0 AND Ref(AO ,-2) > 0) ) AND AboveFractalUp;
SoucerSell = (SoucerDown AND (AO < 0 AND Ref(AO ,-1) < 0 AND Ref(AO ,-2) < 0)) AND BelowFractalDown ;

// Syarat AO Cross
CrossBuy = ( AO > 0 AND Ref(AO ,-1) < 0 ) AND AboveFractalUp;
CrossSell = (AO < 0 AND Ref(AO ,-1) > 0 ) AND BelowFractalDown ;

// Menampilkan Sinyal Sourcer dan AO Cross
PlotShapes( IIf(SoucerBuy ,shapeDigit1,0) ,colorBlue, 0, L,-20);
PlotShapes( IIf(CrossBuy ,shapeDigit2,0) ,colorBlue, 0, H, 20);

// Menentukan TwinPeaks Buy
LatestLowPeak = IIf(AO < 0, Ref(LowestSince(CrossSell, AO , 1), -1), 0);
TwinPeaksBuy = AO < 0 AND Ref(AODownBar, -1) AND AOUpBar AND Ref(AO ,-1) > LatestLowPeak;

LatestLowPeak = IIf(TwinPeaksBuy, Ref(AO ,-1), LatestLowPeak);

PlotShapes( IIf(TwinPeaksBuy AND BelowFractalDown ,shapeDigit3,0) ,colorBlue, 0, 0,12);

//nentukan TwinPeaks Sell
LatestHighPeak = IIf(AO > 0, Ref(HighestSince(CrossBuy, AO, 1), -1), 0);
TwinPeaksSell = AO > 0 AND Ref(AOUpBar, -1) AND AODownBar AND Ref(AO,-1) < LatestHighPeak ;

LatestHighPeak = IIf(TwinPeaksSell, Ref(AO,-1), LatestHighPeak );

PlotShapes( IIf(TwinPeaksSell ,shapeDigit3,0) ,colorOrange, 0, 0,-12);

//Determine Super AO(ws2) Buy and Sell
SuperAOBuy=Ref(AODownBar,-3) AND Ref(AOUpBar,-2) AND Ref(AOUpBar,-1) AND AOUpBar;
SuperAOSell=Ref(AODownBar,-3) AND Ref(AODownBar,-2) AND Ref(AODownBar,-1) AND AODownBar;
BuySuperAO=SuperAOBuy;
SellSuperAO=SuperAOSell;

BuyAO=GrnBar OR SoucerBuy OR CrossBuy OR TwinPeaksBuy OR BuySuperAO;
SellAO=RedBar OR CrossSell OR SoucerSell OR TwinPeaksSell OR SellSuperAO;

/*
Bill William's Alligator System II Awesome Oscillator, modified from williamAlligator2.
Reference Website:
==================
http://www.alpari-idc.com/en/market-analysis-guide/chaos-theory/alligator-and-gator.html

Modified from http://www.amibroker.com/library/detail.php?id=100, by Steve Wiser - [email protected]
Modified by TohMz on June 9th, 2008
*/





SetChartOptions( 0, chartShowArrows|chartShowDates );

GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/6 );
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ParamColor( "alli", colorLightGrey ) );
GfxSetBkMode(0); // transparent

_SECTION_END();



//-----------------4. MFI Definition -------------------------------
_SECTION_BEGIN("MFI");
D0 = (High-Low)/Volume>= Ref((High-Low)/Volume,-1) AND Volume >= Ref( Volume, -1 );// Green
D1 = (High-Low)/Volume< Ref((High-Low)/Volume,-1) AND Volume <Ref( Volume, -1 );// Red
D2 = (High-Low)/Volume>= Ref((High-Low)/Volume,-1) AND Volume < Ref( Volume, -1 );// Blue
D3 = (High-Low)/Volume< Ref((High-Low)/Volume,-1) AND Volume >= Ref( Volume, -1 );// Pink

dynamic_color = IIf( D0, colorBrightGreen, IIf( D3, colorPink, IIf( D1, colorRed, colorBlue)));

AlligatorMFI=IIf(D0,1,IIf(D1,2,IIf(D2,3,IIf(D3,4,0))));

Plot (4, "MFI", dynamic_color, styleOwnScale|styleArea|styleNoLabel|styleNoTitle, -0.5, 100 );
_SECTION_END();


_SECTION_BEGIN("Gator Oscillator");
//------- 5.Gator Oscillator-------------------
AlligatorJaw = Ref(Wilders(A,13),-8);
AlligatorTeeth = Ref(Wilders(A,8), -5);
AlligatorLips = Ref(Wilders(A,5), -3);

Gatorabove=AlligatorLips-AlligatorTeeth;
Gatorbelow=AlligatorJaw-AlligatorTeeth;
Gatorabovecolor=IIf(Gatorabove>Ref(Gatorabove,-1),colorGreen,colorRed);
Gatorbelowcolor=IIf(Gatorbelow>Ref(Gatorbelow,-1),colorGreen,colorRed);

/*
Plot(Gatorabove,"GatorLT",Gatorabovecolor,styleHistogram|styleThick, maskHistogram);
Plot(Gatorbelow,"GatorJT",Gatorbelowcolor,styleHistogram|styleThick, maskHistogram);*/
_SECTION_END();


//------- 6.ZONE Definition -------------------
_SECTION_BEGIN("Zone Definition");

// WiseMan

WM1L = L < Ref( L, -1 ) AND C > ( ( H + L ) / 2 ) AND AODB AND AO < 0 AND ( O < Ref( AlligatorTeeth, -5 ) AND C < Ref( AlligatorTeeth, -5 ) ) AND ( L < Ref( AlligatorTeeth, -5 ) AND H < Ref( AlligatorTeeth, -5 ) );
WM1S = H > Ref( H, -1 ) AND C < ( ( H + L ) / 2 ) AND AOUB AND AO > 0 AND ( O > Ref( AlligatorTeeth, -5 ) AND C > Ref( AlligatorTeeth, -5 ) ) AND ( L > Ref( AlligatorTeeth, -5 ) AND H > Ref( AlligatorTeeth, -5 ) );
WM2L = Ref( AODB, -3 ) AND Ref( AOUB, -2 ) AND Ref( AOUB, -1 ) AND AOUB;
WM2S = Ref( AOUB, -3 ) AND Ref( AODB, -2 ) AND Ref( AODB, -1 ) AND AODB;
WM3L = Cross( C, UF );
WM3S = Cross( DF, C );
//PlotShapes( IIf( WM2L AND WM3L, shapeDigit4, IIf( WM1L, shapeDigit1, IIf( WM2L, shapeDigit2, IIf( WM3L, shapeDigit3, 0 ) ) ), colorGreen, 0, L, -10 );

PlotShapes( IIf( WM1L, shapeDigit1, IIf( WM2L, shapeDigit2, IIf( WM3L, shapeDigit3, 0 ) ) ), colorGreen, 0, L, -10 );
//PlotShapes( IIf( WM1S, shapeDigit1, 0 ) , colorRed, 0, H, 10 );
PlotShapes( IIf( WM1S, shapeDigit1, IIf( WM2S, shapeDigit2, IIf( WM3S, shapeDigit3, 0 ) ) ), colorRed, 0, H, 10 );

//PlotShapes( IIf( WM2S AND WM3S, shapeDigit4, IIf( WM1S, shapeDigit1, IIf( WM2S, shapeDigit2, IIf( WM3S, shapeDigit3, 0 ) ) ) ), colorOrange, 0, H, 10 );
//PlotShapes( IIf( WM1L, shapeDigit1, 0 ), colorGreen, 0, L, -10 );
//PlotShapes( IIf( WM1S, shapeDigit1, 0 ), colorRed, 0, H, 10 );
BuyWM=WM1L OR WM2L OR WM3L;
SellWM=WM1S OR WM2S OR WM3S ;

AO=MA(A,5)-MA(A,34); //2nd Wise Man

AORed=AO<=Ref(AO,-1);
AORed1=Ref(AO,-1)<=Ref(AO,-2); AORed2=Ref(AO,-2)<=Ref(AO,-3); AORed3=Ref(AO,-3)<=Ref(AO,-4); AORed4=Ref(AO,-4)<=Ref(AO,-5);

AOGreen=AO>Ref(AO,-1);
AOGreen1=Ref(AO,-1)>Ref(AO,-2); AOGreen2=Ref(AO,-2)>Ref(AO,-3); AOGreen3=Ref(AO,-3)>Ref(AO,-4); AOGreen4=Ref(AO,-4)>Ref(AO,-5);

AOabove0=AO>0; AObelow0=AO<0;

AC=AO-MA(AO,5);// Accelerator/Decelerator

ACRed=AC<Ref(AC,-1);
ACRed1=Ref(AC,-1)<Ref(AC,-2); ACRed2=Ref(AC,-2)<Ref(AC,-3); ACRed3=Ref(AC,-3)<Ref(AC,-4); ACRed4=Ref(AC,-4)<Ref(AC,-5);

ACGreen=AC>Ref(AC,-1);
ACGreen1=Ref(AC,-1)>Ref(AC,-2); ACGreen2=Ref(AC,-2)>Ref(AC,-3); ACGreen3=Ref(AC,-3)>Ref(AC,-4); ACGreen4=Ref(AC,-4)>Ref(AC,-5);

// Zone Definition
GreenZone=AOGreen AND ACGreen;
GreenZ5=GreenZone AND (AOGreen1 AND ACGreen1) AND (AOGreen2 AND ACGreen2) AND (AOGreen3 AND ACGreen3) AND (AOGreen4 AND ACGreen4);
GreenZ4=GreenZone AND (AOGreen1 AND ACGreen1) AND (AOGreen2 AND ACGreen2) AND (AOGreen3 AND ACGreen3);
GreenZ3=GreenZone AND (AOGreen1 AND ACGreen1) AND (AOGreen2 AND ACGreen2);
GreenZ2=GreenZone AND (AOGreen1 AND ACGreen1);
Greenbar=IIf(greenz5,5,IIf(greenz4,4,IIf(greenz3,3,IIf(greenz2,2,IIf(greenzone,1,0)))));
RedZone=AORed AND ACRed;
RedZ5=RedZone AND (AORed1 AND ACRed1) AND (AORed2 AND ACRed2) AND (AORed3 AND ACRed3) AND (AORed4 AND ACRed4);
RedZ4=RedZone AND (AORed1 AND ACRed1) AND (AORed2 AND ACRed2) AND (AORed3 AND ACRed3);
RedZ3=RedZone AND (AORed1 AND ACRed1) AND (AORed2 AND ACRed2);
RedZ2=RedZone AND (AORed1 AND ACRed1);
Redbar=IIf(redz5,5,IIf(redz4,4,IIf(redz3,3,IIf(redz2,2,IIf(redzone,1,0)))));

GreyZone= (AOGreen AND ACRed) OR (AORed AND ACGreen);
GreyZ2=GreyZone AND ((AOGreen1 AND ACRed1) OR (AORed1 AND ACGreen1));
GreyZ3=GreyZ2 AND ((AOGreen2 AND ACRed2) OR (AORed2 AND ACGreen2));
GreyZ4=GreyZ3 AND ((AOGreen3 AND ACRed3) OR (AORed3 AND ACGreen3));
GreyZ5=GreyZ4 AND ((AOGreen4 AND ACRed4) OR (AORed4 AND ACGreen4));
Greybar=IIf(greyz5,5,IIf(greyz4,4,IIf(greyz3,3,IIf(greyz2,2,IIf(greyzone,1,0)))));

Zonecolor= IIf(GreenZone,colorBrightGreen,IIf(RedZone,colorRed,colorGrey50));

Plot(2," Zone",Zonecolor,styleOwnScale|styleArea|styleNoLabel|styleNoTitle, -0.5, 100 );
BuyZone= GreenZone;
SellZone= RedZone;
_SECTION_END();


_SECTION_BEGIN("Exploration");
//------- 7.Exploration -------------------

// Liquidity is larger than 10 MB per day (on average)
Liquid = MA(C*V,60) > 10e6;
// The market is in a good condition trade
SetForeign("SET",True);
SETBuyCon = RSI()>EMA(RSI(),20) ;
RestorePriceArrays();

Buy=AlligatorEntry AND SETBuyCon AND Liquid AND BuyZone OR BuyWM OR BuyAO ;
Sell=SellZone AND SellWM OR SellAO;


VP = Param("Period for Avg Vol" , 10, 50, 240, 1); // sets the period for the average volume calculation


Filter = Cross(C,(Ref(HHV(H,20),-1)))
//AND Bull

AND (MA((V*C),20)>1000000)
AND ((ROC(C,20)- ROC(Foreign("SET", "Close"),20))>0)
AND ((ROC(C,60)- ROC(Foreign("SET", "Close"),60))>0)
AND ((ROC(C,130)- ROC(Foreign("SET", "Close"),130))>0)
AND V > Ref(V,-1) AND V > Ref(V,-2) AND V > Ref(V,-3) AND V > Ref(V,-4)
AND V > Ref(V,-5) AND V > Ref(V,-6) AND V > Ref(V,-7) AND V > Ref(V,-8)
AND V > Ref(V,-9) AND V > Ref(V,-10) ;




/**Add column of data scan in table*/

Action = WriteIf(Buy, "BUY", WriteIf(Sell, "SELL", " "));
Result = WriteIf(Buy,"Buy",WriteIf(Sell,"Sell"," "));
AddTextColumn( WriteIf(Buy, "Buy" , "Sell" ) , "TRADE" , 5 , IIf(Buy,colorYellow, colorWhite), IIf(Buy, colorDarkGreen, colorRed) );
AddTextColumn(IndustryID(1) ,"Industry Sector ", 25.0, colorWhite, colorBlue, 125); // adds a column for the industry sector
AddColumn(C, "Close", 3.2, colorBlue, colorYellow, 55); // adds a column for today's close
AddColumn(Ref(Close,-1),"Y-Close",1.2, IIf( ROC(Ref(C,-1),1)>=0,colorDarkGreen, colorRed ),50 );
AddColumn( ROC( Close, 1 ), "ROC(1)", 1.2, IIf( ROC(C, 1 ) >= 0,colorDarkGreen, colorRed));
//AddColumn(BuyPrice, "BuyPrice" ,3.1, colorWhite,colorDarkGreen);
//AddColumn(SellPrice, "SellPrice",3.1, colorYellow, colorDarkBlue, 75); // adds a column for the close as a % from the prior close
AddColumn(V, "VOLUME",8.0, colorYellow, colorDarkGreen, 75); // adds a column for today's volume
//AddColumn( Ref(MA(V,VP),-1), WriteVal(VP, 2.0)+ " dMA", 8.0, colorWhite, colorBlue, 75); // adds a column for the average volume

// Remove extra buy / sell signals

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

/*Plot Arrow Signal to Buy&Sell**/

PlotShapes(IIf(Buy,shapeUpArrow,Null),colorBrightGreen,0,L,-24);
PlotShapes(IIf(Sell,shapeDownArrow,Null),colorRed,0,H,-24);


_SECTION_END();

_SECTION_BEGIN("Position");

/******* 8.Position Size AND Position Score ****/

// Invest equally in each stock
PositionSize = -100/MaxPos;

// If there are more than one buy signals at a given time,
// the priority of the Buy is based on the ranking from
// position score. Here, our criterion is the ratio of
// today's value with respect to the average past value
PositionScore = C*V/MA(C*V,60) ;


// Stop Loss ***************************************
// Exit next day if the loss is larger than 10 %
ApplyStop(stopTypeLoss,stopModePercent,10,2);
/*Max loss stop optimization */
_SECTION_END();
##########################################

I want to exchange idea code for edit .
Please help me check condition to buy/sell .
 
Thread starter Similar threads Forum Replies Date
Casey55 Introductions 9
S Introductions 0
L Introductions 0
T Introductions 1
T Brokers & Trading Platforms 4

Similar threads