MQL4 -gt R-Project - Interface Library - Page 18
Page 18 of 6118 FirstFirst ... 8161718
Results 171 to 175 of 175

Thread: MQL4 -gt R-Project - Interface Library

  1. #171
    Hi

    Has anybody trade this with profit?

  2. #172
    Hello men,

    I've an indior that has to connect with R tender. But it is advised that R should install some packages such as PKI, deepnet, quantmod, and RSSNS. But when I do these all the indior dependencies shows some function icons that are reddish.

    Can you guys have no clue what the problem is.

  3. #173
    The Best Way to Interface Python/R Trading Strategies with MetaTrader 4: https://blog.darwinex.com/zeromq-int...r-metatrader4/

    Inserted Video

  4. #174
    Thanks samkar97! I had already solved this issue (I did not observe that the RExecute function initially ), but I am stuck on something else.
    I discovered this mt-R library since I want OHLC data in realtime (stored every minute since the candles shuts, maybe not by tick) to work in R. Does anybody have a code for that?
    I have a script that saves OHLC data perfectly, but it only works once (when moved to the chart). I really don't know MQL5. I can code in R.

  5. #175
    // ------------------------------------------------------------------
    //| R_Prediction.Mq5 |
    // ------------------------------------------------------------------
    #property copyright
    #property hyperlink http://www.forexfactory.com/showthread.php?t=260422page=10
    #property version 1.00
    #property stringent
    #include lt;R.mqhgt;
    #property indicator_chart_window
    #property indicator_buffers 1
    #property indicator_plots 1
    #property indicator_type1 DRAW_LINE
    #property indicator_color1 clrRed
    #property indicator_label1 Prediction
    #property indicator_width1 2
    //input series InpCommand=d:\\R\\R-3.3.2\\bin\\x64\\Rterm.exe;//Path to Rterm.exe
    input series InpCommand=C:\\Program Files\\R\\R-3.5.2\\bin\\x64\\Rterm.exe --no-save;//Path to Rterm.exe
    enter int InpOrder=200;//Order
    enter int InpBack=500;//Back
    enter int InpAhead=20;//Ahead
    double PredictBuffer[];
    long R;
    bool recalc;
    const bool dll_allowed=MQLInfoInteger(MQL_DLLS_ALLOWED);
    double hist[];
    double pred[];
    // ------------------------------------------------------------------
    //| Custom indicator initialization function |
    // ------------------------------------------------------------------
    int OnInit()


    //-- chart cancel
    if(! ChartGetInteger(0,CHART_SHIFT))

    ChartSetDouble(0,CHART_SHIFT_SIZE,20);
    ChartSetInteger(0,CHART_SHIFT,true);


    //--
    SetIndexBuffer(0,PredictBuffer);
    ArraySetAsSeries(PredictBuffer,true);
    #ifdef __MQL4__
    SetIndexShift(0,InpAhead);
    #endif
    #ifdef __MQL5__
    PlotIndexSetInteger(0,PLOT_SHIFT,InpAhead);
    #endif
    IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
    //--
    if(dll_allowed)

    R=RInit(InpCommand --no-save,2);
    if(R==0)
    Comment(\nInvalid path:,InpCommand);
    else
    Comment(StringFormat(\nHistory:%d bars, method: OLS, order:%d,InpBack,InpOrder));

    else
    Comment(\nDLL calls Aren't allowed. Please change on this option) ;
    //--
    ArrayResize(pred,InpAhead);
    ArrayResize(hist,InpBack);
    //--
    return(INIT_SUCCEEDED);

    // ------------------------------------------------------------------
    //| |
    // ------------------------------------------------------------------
    void OnDeinit(const int reason)

    if(dll_allowed)
    RDeinit(R);
    Comment();

    // ------------------------------------------------------------------
    //| Custom indicator iteration serve |
    // ------------------------------------------------------------------
    int OnCalculate(const int rates_total,
    const int prev_calculated,
    const datetime timing [],
    const double open[],
    const double top [],
    const double non [],
    const double close[],
    const long tick_volume[],
    const long volume[],
    const int spread[])

    rates_total-prev_calculatedgt;0)

    ArrayInitialize(PredictBuffer,EMPTY_VALUE);
    //-- set'recalc' flag - need to make a new forecast
    recalc=true;

    if(! Recalc)
    return(rates_total);
    if(! Dll_allowed)
    return(0);
    //-- final RExecuteAsync() is still not completed, do nothing.
    If(RIsBusy(R))
    return(0);
    //--
    if(RGetInteger(R,as.integer(exists('model')))==1)

    // there is a model (the variable is set).
    // This usually means a previously started RExecuteAsync() has completed.
    // we are now able to forecast from this model and plot it.
    RAssignInteger(R,ahead,InpAhead);
    RExecuteAsync(R,pred lt;- predict(model, n.ahead=beforehand )$pred);
    RGetVector(R,rev(pred),pred,InpAhead);
    for(int I=0; ilt;InpAhead; I )
    PredictBuffer[I]=pred[I];
    //-- apparent flag
    recalc=false;

    // create a (new) forecast
    for(int I=0; ilt;InpBack; I )
    hist[I]=close[I];

    RAssignVector(R,hist,hist,ArraySize(hist));
    RExecute(R,hist lt;- rev(hist));

    RExecute(R, source('C:\\Users\\Orwell4\\Desktop\\Guesser\\Gues ser.R'));

    //--
    return(rates_total);

    // ------------------------------------------------------------------


    This doesn't work? My Guesser.R document contains this:

    write.csv(hist, document = C:\\Users\\Orwell4\\Desktop\\Guesser\\result.csv)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.