1. Welcome back! Thank you for being a part of this Traders Community. Let's discuss and share :)
    Selamat datang kembali! Trimakasih telah menjadi bagian dari Komunitas Trader ini. Mari berdiskusi dan berbagi :)
    Dismiss Notice

Suggestion Changes in Programming Skills

Discussion in 'Belajar MQL dari Nol' started by PCWalker, 29 Nov 2016.

  1. PCWalker

    PCWalker Member Credit Hunter

    Equity
    Credit
    Ref Point
    Here is some code that will lead to much gain.

    But do you know what it will take to put it into action? Not MQL for sure, And you know why?
    It is time you start studying a new level of programming, one that will enable you real money making. And more then MT4, you will need to study some math.


    from statsmodels.tsa.stattools import acf, pacf
    from statsmodels.tsa.arima_model import ARMA
    import numpy as np
    import pandas as pd
    import scipy.stats as st
    import statsmodels as sm
    import statsmodels.api as smapi
    from sklearn.decomposition import PCA
    from sklearn.covariance import OAS
    from scipy.optimize import minimize
    from cvxopt import matrix, solvers

    def initialize(context):
    context.freq = 1
    context.stocks = None
    context.screen = 45
    context.X = None
    context.MRO = sid(5035)
    schedule_function(compute,date_rules.week_start(),time_rules.market_open(minutes=10))
    schedule_function(trade,date_rules.week_start(),time_rules.market_open(minutes=15))

    def handle_data(context, data):
    pass

    def trade(context, data):
    if context.X is None:
    return

    context.freq = 0
    prices = data.history(context.stocks, "price", 300, "1d").resample('W').last()
    prices = prices.dropna(axis=1)
    prices = prices.drop(context.MRO, axis=1)
    copy = prices.copy(True)

    for sid in copy:
    if not data.can_trade(sid):
    prices = prices.drop([sid], axis=1)

    ret = prices.pct_change().dropna().values
    ret = np.log1p(ret)
    R = np.dot(ret, context.X)

    sign = 0
    for j in range(0, 3):
    for i in range(1, 3):
    try:
    arma = ARMA(R, (j, i))
    model = arma.fit(method='css')
    sign = np.sum(arma.predict(model.params, len(R), len(R)))
    break
    except:
    continue

    W = {}
    for i, sid in enumerate(prices):
    val = np.sign(sign) * context.X * context.portfolio.portfolio_value * 2
    W[sid] = val

    wsum = 0
    for sid in context.portfolio.positions:
    if sid not in context.stocks:
    if data.can_trade(sid):
    order_target(sid, 0)

    for sid in context.stocks:
    if sid in W:
    if data.can_trade(sid):
    wsum += W[sid]
    if not np.isnan(W[sid]):
    order_target_value(sid, W[sid])
    else:
    order_target_value(sid, 0)

    def compute(context, data):
    prices = data.history(context.stocks, "price", 300, "1d").resample('W').last()
    prices = prices.dropna(axis=1)
    prices = prices.drop(context.MRO, axis=1)
    copy = prices.copy(True)

    for sid in copy:
    if not data.can_trade(sid):
    prices = prices.drop([sid], axis=1)

    ret = prices.pct_change().dropna().values
    ret = np.log1p(ret)
    x0 = [1. / np.shape(ret)[1]] * np.shape(ret)[1]
    cons = []
    cons.append({'type':'ineq', 'fun': lambda x: pacf(np.dot(ret, x), nlags=1)[1] - 0.3 })
    cons.append({'type':'eq', 'fun': lambda x: np.sum(x)})
    res = minimize( myfunc, x0, args=(ret), constraints=cons, method='SLSQP', options={'maxiter':1000})
    if not res['success']:
    print res['message']
    context.X = [0] * len(res.x)
    return

    res.x = res.x / np.sum(np.abs(res.x))
    context.X = res.x

    def myfunc(x, ret):
    R = np.dot(ret, x)
    ac = pacf(R, nlags=8)[2:]
    return np.sum(ac**2)

    def before_trading_start(context, data):
    if context.screen < 45:
    return
    else:
    context.screen = 0
    fundamental_df = get_fundamentals(query(fundamentals.valuation.market_cap)
    .filter(fundamentals.asset_classification.morningstar_sector_code == 309)
    .filter(fundamentals.valuation.market_cap != None)
    .filter(fundamentals.company_reference.primary_exchange_id != "OTCPK")
    .filter(fundamentals.share_class_reference.security_type == 'ST00000001')
    .filter(~fundamentals.share_class_reference.symbol.contains('_WI'))
    .filter(fundamentals.share_class_reference.is_primary_share == True)
    .filter(fundamentals.share_class_reference.is_depositary_receipt == False)
    .order_by(fundamentals.valuation.market_cap.desc()).limit(30)).T
    context.stocks = fundamental_df.index
     
    Last edited: 29 Nov 2016
    • Like Like x 1
  2. PCWalker

    PCWalker Member Credit Hunter

    Equity
    Credit
    Ref Point
    Zorro Trader, will enable who ever wants to put time into real matters and stop the craziness of chasing a Free EA that will make Thousands or Millions in a short Time. And Enable results like these to be part of reality.

    55548799156.jpg
     
    • Like Like x 1
  3. PCWalker

    PCWalker Member Credit Hunter

    Equity
    Credit
    Ref Point
    • Like Like x 1
  4. PCWalker

    PCWalker Member Credit Hunter

    Equity
    Credit
    Ref Point
    Thank you Jeff, Yes, The reason I shared the Quantopian Code, because users should know, that working with all these free EA, not having any serious math within it, just common indicators, will not make any money. And Zorro Trader comes very close to Python, and Enables serious algo trading ideas that are being used at most institutions.
     
    • Like Like x 2
  5. Luis Carlos

    Luis Carlos Member Credit Hunter

    Equity
    Credit
    Ref Point
    Mr Walker, is it really possible to run Zorro within MT4 through MT4 Bridge? And is it free?
     
  6. PCWalker

    PCWalker Member Credit Hunter

    Equity
    Credit
    Ref Point
    Sure, Luis, I am not suggesting it without using it. I am running it right now. And it is Free, But after you have felt that you are pro with it, and you want to use it on a real account with more then 7000 USD, you will need to subscribe for 20 USD per month. But If you have already mastered it, and reached a confidence of running your algos with more then 7000 USD, then 20 USD for the developers that have worked hard to enable home traders use this kind of software and technology, it is worth while. Don't you think so?
     
    Last edited: 30 Nov 2016
    • Agree Agree x 1
  7. PCWalker

    PCWalker Member Credit Hunter

    Equity
    Credit
    Ref Point
    Thank you, ionone2, I am so happy that you have taken action, Now after you use it and enjoy the new possibilities with short and simple code, you could share with all of your friends over here, some of your ideas so that they could also see why it is important to stop all this MT4/MQL Addiction with no results.
     
  8. PCWalker

    PCWalker Member Credit Hunter

    Equity
    Credit
    Ref Point
    There is no problem with Brokers, or the possibilities when you can study in less then 4 hours to use a API for HTTP requests, and enable your Robots to trade with any Broker that offers API trading, and Zorro Trader will surely solve your problem.
     
    • Like Like x 1

Share This Page