- UID
- 2
- 积分
- 2893117
- 威望
- 1396590 布
- 龙e币
- 1496527 刀
- 在线时间
- 13326 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-12-26
|
Amibroker AFL code by Markos Katsanos — November 2018
The Amibroker AFL code below is from Markos Katsanos’ November 2018 article “The Stiffness Indicator”:
Stiffness IndicatorAmibroker[源码]
- //STIFFNESS INDICATOR
- //Copyright Markos Katsanos 2018
- Period = Param("Stiffness Period", 60, 2, 1000, 1 );
- MAB=Param("Moving Average Period",100,2,1000,1); // MA DAYS
- SM=Param("Smooth Coeff.",3,1,20,1); //
- STIFFCRIT=Param("STIFFCritical",90,70,100,5); // STIFFNESS CRITICAL
- NSTD=Param("Min SD",.2,0,2,.5); //Number of Standard Deviations
- //STIFFNESS
- MA2=MA(C,MAB)-NSTD*StDev(C,MAB);
- CLMA=C>MA2;
- PENS=Sum(CLMA,PERIOD);
- STIF=PENS*100/PERIOD; STIFFNESS=EMA(STIF,SM);
- Plot(stiffness,"STIFFNESS",colorRed ,styleHistogram );
- Plot(STIFFCRIT,"STIFFCritical",colorGreen,styleThick);
复制代码
Stiffness Strategy
- //STIFFNESS STRATEGY
- //Copyright Markos Katsanos 2018
- PosQty = 500;
- SetOption( "MaxOpenPositions", PosQty );
- SetPositionSize( 10000, spsValue );
- SetTradeDelays( 1, 1, 1, 1 );
- BuyPrice = OPEN;
- SellPrice = OPEN;
- timeexit =Optimize("exit",4,4,4,1); //MONTHS
- MAB=Optimize("MAB",100,50,120,10); // MA DAYS
- PERIOD=Optimize(" STIFF PERIOD",60,40,80,10); // STIFFNESS PERIOD
- STIFFCRIT=Optimize("STIFFCRIT",90,90,95,5); // STIFFNESS CRITICAL
- STIFFSELL=Optimize("STIFFSELL",50,50,60,10); // stiffness sell
- //STIFFNESS
- MA2=MA(C,MAB)-.2*StDev(C,MAB);
- CLMA=C>MA2;
- PENS=Sum(CLMA,PERIOD);
- STIF=PENS*100/PERIOD; STIFFNESS=EMA(STIF,3);
- SPY = Foreign("SPY","C");
- BUY = EMA(SPY,100)>=Ref(EMA(SPY,100),-2) AND Cross(STIFFNESS,STIFFCRIT) ;
- Sell =Cross(STIFFSELL,STIFFNESS);
- ApplyStop( stopTypeNBar, stopModeBars, timeexit*21 ); // time exit
复制代码
Stiffness Exploration
- //STIFFNESS EXPLORATION
- //Copyright Markos Katsanos 2018
- MAB=100; // MA DAYS
- PERIOD=60;// STIFFNESS PERIOD
- STIFFCRIT=90;// STIFFNESS CRITICAL
- //STIFFNESS
- MA2=MA(C,MAB)-.2*StDev(C,MAB);
- CLMA=C>MA2;
- PENS=Sum(CLMA,PERIOD);
- STIF=PENS*100/PERIOD; STIFFNESS=EMA(STIF,3);
- SPY = Foreign("SPY","C");
-
- FILTER = EMA(SPY,100)>=Ref(EMA(SPY,100),-2) AND Cross(STIFFNESS,STIFFCRIT) ;
- AddColumn(C,"Price",1.2);
- AddColumn(Volume,"Volume",1.0);
- AddColumn(MA(Volume,2)/MA(Volume,50),"V/Vave",1.2);
- AddColumn(RSI(6),"RSI",1);
- AddColumn(STIFFNESS,"STIFFNESS",1.2);
- AddColumn(C+8*ATR(50),"PROFIT TARGET",1.2);
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|