Cần chuyển đổi code MT4 (MQ4) sang Code (AFL) cho Amibroker

Chủ đề trong 'Thị trường chứng khoán' bởi cp2011, 22/03/2020.

58651 người đang online, trong đó có 629 thành viên. 21:16 (UTC+07:00) Bangkok, Hanoi, Jakarta
  1. 0 người đang xem box này (Thành viên: 0, Khách: 0)
Chủ đề này đã có 1511 lượt đọc và 0 bài trả lời
  1. cp2011

    cp2011 Thành viên gắn bó với f319.com

    Tham gia ngày:
    12/04/2010
    Đã được thích:
    1.822
    Chào các bác , các bạn. Mình đang muốn chuyển file trong MT4 sang dùng cho Amibroker, ai biết thì xin chỉ dẫn với ạ.
    Đây ví dụ cái này ạ: Là code vẽ đường thôi
    //+------------------------------------------------------------------+
    //| ZigZag.mq4 |
    //| Copyright 2006-2014, MetaQuotes Software Corp. |
    //| http://www.mql4.com |
    //+------------------------------------------------------------------+

    #property copyright "2006-2014, MetaQuotes Software Corp."
    #property strict

    #property indicator_chart_window
    #property indicator_buffers 1
    #property indicator_color1 Red
    //---- indicator parameters
    input int InpDepth=12; // Depth
    input int InpDeviation=5; // Deviation
    input int InpBackstep=3; // Backstep
    //---- indicator buffers
    double ExtZigzagBuffer[];
    double ExtHighBuffer[];
    double ExtLowBuffer[];
    //--- globals
    int ExtLevel=3; // recounting's depth of extremums
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function |
    //+------------------------------------------------------------------+
    int OnInit()
    {
    if(InpBackstep>=InpDepth)
    {
    Print("Backstep cannot be greater or equal to Depth");
    return(INIT_FAILED);
    }
    //--- 2 additional buffers
    IndicatorBuffers(3);
    //---- drawing settings
    SetIndexStyle(0,DRAW_SECTION);
    //---- indicator buffers
    SetIndexBuffer(0,ExtZigzagBuffer);
    SetIndexBuffer(1,ExtHighBuffer);
    SetIndexBuffer(2,ExtLowBuffer);
    SetIndexEmptyValue(0,0.0);
    //---- indicator short name
    IndicatorShortName("ZigZag("+string(InpDepth)+","+string(InpDeviation)+","+string(InpBackstep)+")");
    //---- initialization done
    return(INIT_SUCCEEDED);
    }
    //+------------------------------------------------------------------+
    //| |
    //+------------------------------------------------------------------+
    int OnCalculate(const int rates_total,
    const int prev_calculated,
    const datetime &time[],
    const double &open[],
    const double &high[],
    const double &low[],
    const double &close[],
    const long& tick_volume[],
    const long& volume[],
    const int& spread[])
    {
    int i,limit,counterZ,whatlookfor=0;
    int back,pos,lasthighpos=0,lastlowpos=0;
    double extremum;
    double curlow=0.0,curhigh=0.0,lasthigh=0.0,lastlow=0.0;
    //--- check for history and inputs
    if(rates_total=InpDepth)
    return(0);
    //--- first calculations
    if(prev_calculated==0)
    limit=InitializeAll();
    else
    {
    //--- find first extremum in the depth ExtLevel or 100 last bars
    i=counterZ=0;
    while(counterZ=0; i--)
    {
    ExtZigzagBuffer=0.0;
    ExtLowBuffer=0.0;
    ExtHighBuffer=0.0;
    }
    }
    }
    //--- main loop
    for(i=limit; i>=0; i--)
    {
    //--- find lowest low in depth of bars
    extremum=low[iLowest(NULL,0,MODE_LOW,InpDepth,i)];
    //--- this lowest has been found previously
    if(extremum==lastlow)
    extremum=0.0;
    else
    {
    //--- new last low
    lastlow=extremum;
    //--- discard extremum if current low is too high
    if(low-extremum>InpDeviation*Point)
    extremum=0.0;
    else
    {
    //--- clear previous extremums in backstep bars
    for(back=1; backextremum)
    ExtLowBuffer[pos]=0.0;
    }
    }
    }
    //--- found extremum is current low
    if(low==extremum)
    ExtLowBuffer=extremum;
    else
    ExtLowBuffer=0.0;
    //--- find highest high in depth of bars
    extremum=high[iHighest(NULL,0,MODE_HIGH,InpDepth,i)];
    //--- this highest has been found previously
    if(extremum==lasthigh)
    extremum=0.0;
    else
    {
    //--- new last high
    lasthigh=extremum;
    //--- discard extremum if current high is too low
    if(extremum-high>InpDeviation*Point)
    extremum=0.0;
    else
    {
    //--- clear previous extremums in backstep bars
    for(back=1; back=0; i--)
    {
    switch(whatlookfor)
    {
    case 0: // look for peak or lawn
    if(lastlow==0.0 && lasthigh==0.0)
    {
    if(ExtHighBuffer!=0.0)
    {
    lasthigh=High;
    lasthighpos=i;
    whatlookfor=-1;
    ExtZigzagBuffer=lasthigh;
    }
    if(ExtLowBuffer!=0.0)
    {
    lastlow=Low;
    lastlowpos=i;
    whatlookfor=1;
    ExtZigzagBuffer=lastlow;
    }
    }
    break;
    case 1: // look for peak
    if(ExtLowBuffer!=0.0 && ExtLowBufferlasthigh && ExtLowBuffer==0.0)
    {
    ExtZigzagBuffer[lasthighpos]=0.0;
    lasthighpos=i;
    lasthigh=ExtHighBuffer;
    ExtZigzagBuffer=lasthigh;
    }
    if(ExtLowBuffer!=0.0 && ExtHighBuffer[i]==0.0)
    {
    lastlow=ExtLowBuffer[i];
    lastlowpos=i;
    ExtZigzagBuffer[i]=lastlow;
    whatlookfor=1;
    }
    break;
    }
    }
    //--- done
    return(rates_total);
    }
    //+------------------------------------------------------------------+
    //| |
    //+------------------------------------------------------------------+
    int InitializeAll()
    {
    ArrayInitialize(ExtZigzagBuffer,0.0);
    ArrayInitialize(ExtHighBuffer,0.0);
    ArrayInitialize(ExtLowBuffer,0.0);
    //--- first counting position
    return(Bars-InpDepth);
    }
    //+------------------------------------------------------------------+[/i][/i][/i]
    [/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]

Chia sẻ trang này