Board logo

标题: Amibroker AFL code by Markos Katsanos — November 2018 [打印本页]

作者: 龙听    时间: 2018-11-27 10:55     标题: 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[源码]
  1. //STIFFNESS INDICATOR
  2. //Copyright Markos Katsanos 2018
  3. Period = Param("Stiffness Period", 60, 2, 1000, 1 );
  4. MAB=Param("Moving Average Period",100,2,1000,1); // MA DAYS
  5. SM=Param("Smooth Coeff.",3,1,20,1); //
  6. STIFFCRIT=Param("STIFFCritical",90,70,100,5);  // STIFFNESS CRITICAL
  7. NSTD=Param("Min SD",.2,0,2,.5); //Number of Standard Deviations
  8. //STIFFNESS
  9. MA2=MA(C,MAB)-NSTD*StDev(C,MAB);
  10. CLMA=C>MA2;
  11. PENS=Sum(CLMA,PERIOD);
  12. STIF=PENS*100/PERIOD; STIFFNESS=EMA(STIF,SM);

  13. Plot(stiffness,"STIFFNESS",colorRed ,styleHistogram );
  14. Plot(STIFFCRIT,"STIFFCritical",colorGreen,styleThick);
复制代码



Stiffness Strategy

  1. //STIFFNESS STRATEGY
  2. //Copyright Markos Katsanos 2018

  3. PosQty = 500;
  4. SetOption( "MaxOpenPositions", PosQty );
  5. SetPositionSize( 10000, spsValue );  

  6. SetTradeDelays( 1, 1, 1, 1 );
  7. BuyPrice = OPEN;
  8. SellPrice = OPEN;

  9. timeexit =Optimize("exit",4,4,4,1); //MONTHS
  10. MAB=Optimize("MAB",100,50,120,10); // MA DAYS
  11. PERIOD=Optimize(" STIFF PERIOD",60,40,80,10); // STIFFNESS PERIOD
  12. STIFFCRIT=Optimize("STIFFCRIT",90,90,95,5);  // STIFFNESS CRITICAL
  13. STIFFSELL=Optimize("STIFFSELL",50,50,60,10);  // stiffness sell

  14. //STIFFNESS
  15. MA2=MA(C,MAB)-.2*StDev(C,MAB);
  16. CLMA=C>MA2;
  17. PENS=Sum(CLMA,PERIOD);
  18. STIF=PENS*100/PERIOD; STIFFNESS=EMA(STIF,3);

  19. SPY = Foreign("SPY","C");

  20. BUY = EMA(SPY,100)>=Ref(EMA(SPY,100),-2)  AND Cross(STIFFNESS,STIFFCRIT) ;

  21. Sell =Cross(STIFFSELL,STIFFNESS);
  22. ApplyStop( stopTypeNBar, stopModeBars, timeexit*21 ); // time exit
复制代码



Stiffness Exploration

  1. //STIFFNESS EXPLORATION
  2. //Copyright Markos Katsanos 2018

  3. MAB=100; // MA DAYS
  4. PERIOD=60;// STIFFNESS PERIOD
  5. STIFFCRIT=90;// STIFFNESS CRITICAL

  6. //STIFFNESS
  7. MA2=MA(C,MAB)-.2*StDev(C,MAB);
  8. CLMA=C>MA2;
  9. PENS=Sum(CLMA,PERIOD);
  10. STIF=PENS*100/PERIOD; STIFFNESS=EMA(STIF,3);

  11. SPY = Foreign("SPY","C");
  12.         
  13. FILTER = EMA(SPY,100)>=Ref(EMA(SPY,100),-2) AND Cross(STIFFNESS,STIFFCRIT) ;

  14. AddColumn(C,"Price",1.2);               
  15. AddColumn(Volume,"Volume",1.0);
  16. AddColumn(MA(Volume,2)/MA(Volume,50),"V/Vave",1.2);
  17. AddColumn(RSI(6),"RSI",1);
  18. AddColumn(STIFFNESS,"STIFFNESS",1.2);
  19. AddColumn(C+8*ATR(50),"PROFIT TARGET",1.2);
复制代码

作者: 获嘉小马哥    时间: 2019-3-27 12:03

感谢分享




欢迎光临 龙听期货论坛 (http://www.qhlt.cn/) Powered by Discuz! 7.2