Nhờ các bác sửa code Pattern Reco - chỉ báo xu hướng

Thảo luận trong 'Thảo luận chung' bắt đầu bởi ĐỖ TRUNG, 2/5/23.

Lượt xem : 988

  1. ĐỖ TRUNG

    ĐỖ TRUNG New Member

    Tham gia ngày:
    15/8/21
    Bài viết:
    3
    Đã được thích:
    0
    Giới tính:
    Nam
    upload_2023-5-2_10-26-56.png

    FormulaName = "PE - Chart Pattern Recognition 1";

    SetChartOptions(0,chartShowDates|chartLogarithmic|chartWrapTitle);
    #pragma nocache
    #include_once <\PEInc\PatternExplorer_f0.afl>
    #Include_once "C:\Program Files (x86)\AmiBroker\Formulas\PatternExplorer\#Defaults & Mods\PE - Defaults.afl"
    #Include_once "C:\Program Files (x86)\AmiBroker\Formulas\PatternExplorer\#Defaults & Mods\PE - Mods.afl"
    def_GraphXSpace = 10;
    /*******************************************************************************************/
    AddCustomCodeBeforePE();
    /*******************************************************************************************/
    AddAlertParam(def_AudioAlert,def_EmailAlert,def_BarComplete);
    /*******************************************************************************************/
    _SECTION_BEGIN("Alerts");
    SRbS = ParamToggle("S/R broken","Off,On",1);
    SRcS = ParamToggle("S/R confirmed","Off,On",1);
    PjabS = ParamToggle("Price just above/below","Off,On",1);
    _SECTION_END();
    /*******************************************************************************************/
    _SECTION_BEGIN("Main Parameters");
    AddparamUsefromChart(def_UseFromChart);
    PatternPriceBasis = ParamToggle("Pattern Price Basis","Close|High & Low",def_PatternPriceBasisCPR);
    Sensitivity = Param("Sensitivity",15,1,100,1);
    if(InChart)StaticVarSet("UO3443",PatternPriceBasis);if(inAA AND Usefromchart) PatternPriceBasis = StaticVarGet("UO3443");
    if(InChart)StaticVarSet("D4Q5T6",Sensitivity);
    if(inAA AND Usefromchart) Sensitivity = StaticVarGet("D4Q5T6");
    PatternPriceBasis = ParamToggle("Pattern Price Basis","Close|High & Low",def_PatternPriceBasisCPR);
    PlotP1P2 = ParamToggle("Plot P1/P2 Shapes","Off,On",def_Plot_P1P2_Shapes);
    P1Shape = Param("P1 Shape Typ",35,0,50,1);
    P2Shape = Param("P2 Shape Typ",37,0,50,1);
    Parallellinesswitch = ParamToggle("Plot Parallel Lines","Off,On");
    DisRange = Param("Plot Parallel Lines Trigger",3,0.0,10,0.5);
    _SECTION_END();
    /*******************************************************************************************/
    _SECTION_BEGIN("Styles");
    Style_SL= ParamStyle("Support",styleLine+styleThick,maskDefault)+styleNoRescale;
    Style_RL= ParamStyle("Resistance",styleLine+styleThick,maskDefault)+styleNoRescale;
    Style_PHL= ParamStyle("Parallel Support",styleLine,maskDefault)+styleNoRescale;
    Style_PLL= ParamStyle("Parallel Resistance",styleLine,maskDefault)+styleNoRescale;
    _SECTION_END();
    /*******************************************************************************************/
    _SECTION_BEGIN("Colors");
    Color_SL= ParamColor("Support",def_Color1);
    Color_RL= ParamColor("Resistance",colorRed);
    Shadowcolor = ParamColor("Shadow",def_Shadowcolor);
    Color_PLL= Color_RL; //ParamColor("Resistance",colorRed);
    Color_PHL= Color_SL; //ParamColor("Support",def_Color1);
    _SECTION_END();
    /*******************************************************************************************/
    if(inAA)
    {
    _SECTION_BEGIN("Pattern Selection");
    AscTs = ParamToggle("Ascending Triangle","Off,On",1);
    DscTs = ParamToggle("Descending Triangle","Off,On",1);
    STs = ParamToggle("Symmetrically Triangle","Off,On",1);
    ETs = ParamToggle("Expanding Triangle","Off,On",1);
    RWs = ParamToggle("Rising Wedge","Off,On",1);
    FWs = ParamToggle("Falling Wedge","Off,On",1);
    UTs = ParamToggle("Up Trend","Off,On",1);
    DTs = ParamToggle("Down Trend","Off,On",1);
    Rectangles = ParamToggle("Rectangle","Off,On",1);
    NonDefinedPatterns = ParamToggle("Not defined Patterns","Off,On",0);
    _SECTION_END();
    }
    /*******************************************************************************************/
    #include_once <\PEInc\Lib\PatternExplorer_f06.afl>
    #include_once <\PEInc\PatternExplorer_1.afl>
    /*******************************************************************************************/
    GraphZOrder = 0;
    Plot(TRS," SL" ,Color_SL,Style_SL+styleNoTitle);
    Plot(TRR," RL" ,Color_RL,Style_RL+styleNoTitle);
    PlotOHLC(Null,TRR,TRS,Null,"",Shadowcolor,styleCloud+styleNoLabel);
    Plot(IIf(Parallellinesswitch,PLL_plot,-1e10)," PLL",Color_PLL,Style_PLL+styleNoTitle);
    Plot(IIf(Parallellinesswitch,PHL_plot,-1e10)," PHL",Color_PHL,Style_PHL+styleNoTitle);
    /*******************************************************************************************/
    PlotShapes(IIf(BS & x>LastValue(x)-3,def_BuyShape,shapeNone),def_BuyShapeColor,0, Low,-def_BuyShapeOffset );
    PlotShapes(IIf(SS & x>LastValue(x)-3,def_SellShape,shapeNone),def_SellShapeColor,0, High,-def_SellShapeOffset );
    if(PlotP1P2)
    {
    PlotShapes(IIf(x==xa & NOT AnZ,P1Shape,shapeNone),Color_SL,0,SL,-13 );
    PlotShapes(IIf(x==xb & NOT AnZ,P2Shape,shapeNone),Color_SL,0,SL,-13 );
    PlotShapes(IIf(x==xc & NOT AnZ,P1Shape,shapeNone),Color_RL,0,H,13 );
    PlotShapes(IIf(x==xd & NOT AnZ,P2Shape,shapeNone),Color_RL,0,H,13 );
    }
    /*******************************************************************************************/
    Buy = def_Buy AND BS; Sell = def_Sell AND SS;
    /*******************************************************************************************/
    if(inAA){
    CPRFilter =
    (AscT AND AscTs)|(DscT AND DscTs)| (ST AND STs)|
    (ET AND ETs)| (RW AND RWs)| (FW AND FWs)|
    (UT AND UTs)| (DT AND DTs)|(Rectangle AND Rectangles)|
    (SupSignals AND NonDefinedPatterns AND NOT DefinedPatterns)|
    (ResSignals AND NonDefinedPatterns AND NOT DefinedPatterns);
    Filter = def_Filter AND BarIndex()==LastValue(BarIndex()) AND NOT GroupID()==253;
    Filter = Filter AND CPRFilter;
    /*******************************************************************************************/
    Addefaultcolumns();
    Adddefaultcolumns(2,1);
    AddTextColumn(WriteIf(Sup_pricejustabove,"Price just above",
    WriteIf(Sup_confirmed,"Confirmed",
    WriteIf(Sup_break,"Break",""))),"Support Line",1.2, IIf(Sup_pricejustabove OR sup_confirmed,colorGreen,colorRed));
    AddTextColumn(
    WriteIf(Res_pricejustbelow,"Price just below", WriteIf(Res_confirmed,"confirmed",
    WriteIf(Res_break,"Break",""))),"Resistance Line",1.2, IIf(Res_pricejustbelow OR Res_confirmed,colorRed,colorGreen));
    /*******************************************************************************************/
    patterncolor =
    IIf(AscT|FW|UT,colorGreen,
    IIf(DscT|RW|DT,colorRed,
    IIf(ST|ET|Rectangle,colorBlue,colorBlack)));
    AddTextColumn(PatternText,"Pattern",0,patterncolor);
    AddTextColumn(FullName(),"Full name");
    }
    /*******************************************************************************************/
    /*
    AddTextColumn(
    WriteIf(PLL_pricejustabove,"price just above",
    WriteIf(PLL_confirmed,"confirmed",
    WriteIf(PLL_break,"break",""))),"Parallel support line");

    AddTextColumn(
    WriteIf(PHL_pricejustbelow,"price just below",
    WriteIf(PHL_confirmed,"confirmed",
    WriteIf(PHL_break,"break",""))),"Parallel resistance line");
    */
    /*******************************************************************************************/
    if(SRbS){
    AddAlert(Res_break,Audio,Email,"Resistance broken",1,BarComplete,def_BuySound1);
    AddAlert(Sup_break,Audio,Email,"Support broken",2,BarComplete,def_SellSound1);
    }
    if(SRcS){
    AddAlert(Sup_confirmed,Audio,Email,"Support confirmed",1,BarComplete,def_BuySound2);
    AddAlert(Res_confirmed,Audio,Email,"Resistance confirmed",2,BarComplete,def_SellSound2);
    }
    if(PjabS){
    AddAlert(Sup_pricejustabove AND PatternDirection ==1,Audio,Email,"Price just above Support",1,BarComplete,def_BuySound3);
    AddAlert(Res_pricejustbelow AND PatternDirection ==-1,Audio,Email,"Price just below Resistance",2,BarComplete,def_SellSound3);
    AddAlert(Sup_pricejustabove AND PatternDirection ==0,Audio,Email,"Price just above Support",5,BarComplete,def_BuySound3);
    AddAlert(Res_pricejustbelow AND PatternDirection ==0,Audio,Email,"Price just below Resistance",5,BarComplete,def_SellSound3);
    }
    /*******************************************************************************************/
    /*******************************************************************************************/
    AddCustomCodeAfterPE();
    /*******************************************************************************************/
    Title = "PatternExplorer.com - Chart Pattern Recognition 1 "
    + default_priceTitle +", " + EncodeColor(def_Text3)+"Pattern: "+ PatternText
    + EncodeColor(IIf(NOT AnZ,def_Text2,colorRed))+", Sensitivity = " + WriteVal(Sensitivity,1)+ " "+EncodeColor(colorRed)+WriteIf(NOT AnZ,""," NO POINTS AVAILABLE -> REDUCE SENSITIVITY ");
    /*******************************************************************************************/
    ST = LastValue(ST);
    AscT = LastValue(AscT);
    DscT = LastValue(DscT);
    ET = LastValue(ET);
    RW = LastValue(RW);
    FW = LastValue(FW);
    UT = LastValue(UT); ParamToggle("Up Trend","Off,On",1);
    DT = LastValue(DT); ParamToggle("Down Trend","Off,On",1);
    Rectangles = LastValue(Rectangle); ParamToggle("Rectangle","Off,On",1);
    /*******************************************************************************************/
    ToolTip = def_ToolTip;

    if(ST)
    {
    ToolTip = ToolTip +
    "\n\n"+
    "Current Pattern = Symmetrical Triangle" + "\n"+
    " ";
    }

    if(AscT)
    {
    ToolTip = ToolTip +
    "\n\n"+
    "Current Pattern = Ascending Triangle" + "\n"+
    " ";
    }

    if(DscT)
    {
    ToolTip = ToolTip +
    "\n\n"+
    "Current Pattern = Descending Triangle" + "\n"+
    " ";
    }

    if(ET)
    {
    ToolTip = ToolTip +
    "\n\n"+
    "Current Pattern = Expanding Triangle" + "\n"+
    " ";
    }

    if(RW)
    {
    ToolTip = ToolTip +
    "\n\n"+
    "Current Pattern = Rising Wedge" + "\n"+
    " ";
    }

    if(FW)
    {
    ToolTip = ToolTip +
    "\n\n"+
    "Current Pattern = Falling Wedge" + "\n"+
    " ";
    }

    if(UT)
    {
    ToolTip = ToolTip +
    "\n\n"+
    "Current Pattern = Up Channel" + "\n"+
    " ";
    }

    if(DT)
    {
    ToolTip = ToolTip +
    "\n\n"+
    "Current Pattern = Down Channel" + "\n"+
    " ";
    }

    if(Rectangles)
    {
    ToolTip = ToolTip +
    "\n\n"+
    "Current Pattern = Rectangle" + "\n"+
    " ";
    }


    Em cài phần mềm lên thì ra code như thế này. Bác nào hiểu về viết code viết lại giúp em cho đỡ phải cài phần mềm mà chỉ cần add file AFL với ạ.
    Zalo: 0963678668
    mail: materialdt@gmail.com

    Thanks!
     

    Các file đính kèm:

Lượt bình luận : 0

Chia sẻ trang này