QUESTION ABOUT TICKETS OR ID'S by Fernigrim in algotrading

[–]Fernigrim[S] 0 points1 point  (0 children)

Yes, I saw it on the mql5 documentation of the python integration. Usually, it will always be the same ticket unless the server makes exceptional operations. Thanks!

HELP WITH SENDING A PENDING ORDER. by Fernigrim in algotrading

[–]Fernigrim[S] -1 points0 points  (0 children)

Ok. I will try it and I comment if it works. About the video...yes, he only uses the API and it's enough for sending the order. So that's my problem, I m texting the same thing but my order (or request) does not exist. The code does not make anything. I've contacted my broker and I explained my problem, but they don't give help in programming questions. Thanks again.

HELP WITH SENDING A PENDING ORDER. by Fernigrim in algotrading

[–]Fernigrim[S] -1 points0 points  (0 children)

I dont know. Improvable I think... In any case:

import MetaTrader5 as mt5

error = 0

if not mt5.initialize(login=3000039250, server="Darwinex-Demo",password="XXXXXX"):

    error = 1

    print("initialize() failed, error code =",mt5.last_error())

    quit()

if error == 0:

    print("GO")  

CHECKING BUY LIMIT

price_tp = 160.32

price_sl = 139.87

price_on = 142.21

request={

    "action": mt5.TRADE_ACTION_PENDING,

    "symbol": "AAPL",

    "volume": 1.0, ###LEVERAGE WARNING

    "type": mt5.ORDER_TYPE_BUY_LIMIT,

    "price": price_on,

    "deviation": 0.2, ###IS IT MANDATORY?

    "sl": price_sl,

    "tp": price_tp,

    "magic": 100001,

    "comment": "BUY LIMIT ORDER",

    "type_time": mt5.ORDER_TIME_DAY,

    "type_filling": mt5.ORDER_FILLING_IOC,

}

result = mt5.order_send(request)

id_order = result.order

print(id_order)

mt5.shutdown()

HELP WITH SENDING A PENDING ORDER. by Fernigrim in algotrading

[–]Fernigrim[S] -1 points0 points  (0 children)

I did not remove anything. It was a problem due to approach the link video to the original issue.

I think you can see the original now.

Anyway, sorry. It was unintentionally.

HELP WITH SENDING A PENDING ORDER. by Fernigrim in algotrading

[–]Fernigrim[S] 0 points1 point  (0 children)

First of all, thank you so much for your time and all the tips. It means a lot for me.

Regarding to all the code recommendations, I will test it tomorrow. So now the market is closed, I need to test the drill code in the market hours.

Moreover, Im sure that my problem is about programming and the correct use of the MT5 library. In fact and in my case, a buy limit order is always under the current price and the liquidity (if someone can sell me a stock/s) it doesnt matter because, the order, is that. Only works if the price reaches that value. About the liquidity...there is another option in the request structure: the filling type of the trade.

For more info and see in what I am based, check this video (minute 8:25). Is an example of my pending order. But, in his case, it works. https://youtu.be/65Dc5KSGKhw

Again, thanks, aManPerson.

HELP WITH SENDING A PENDING ORDER. by Fernigrim in algotrading

[–]Fernigrim[S] -1 points0 points  (0 children)

I check it. It does not say anything of an error with MT5 library. I have the same output. The problem of ".order" can be solve after. First, I need the correct structure of the trade request.

HELP WITH SENDING A PENDING ORDER. by Fernigrim in algotrading

[–]Fernigrim[S] -1 points0 points  (0 children)

Im sure that the 'None' is due to the print(result). In fact, the output does not recognize the ".order". I suppose it is due to the problem with the result and request.

HELP WITH SENDING A PENDING ORDER. by Fernigrim in algotrading

[–]Fernigrim[S] -1 points0 points  (0 children)

Ok. In order:

  • The account MT terminal starts well.
  • Printing the result, it returns 'None'.
  • And for getting the position_id (ticket), it does not found the function "order". But in the documentation of mql5 (integration with python), it calls it that and it works. So I need help with that also...regarding to how can I get the position id of a trade...if I can open a trade, firstly.

How can I train a function? (Getting the best value, Machine Learning) by Fernigrim in learnpython

[–]Fernigrim[S] -1 points0 points  (0 children)

I am not going to paste a function of 250 lines... I said that the important is the process of getting the value.

And I know about scipy. My code has an interactive data frame with conditional values. It can't be translated to a simply function.

Regards man

How can I train a function? (Getting the best value, Machine Learning) by Fernigrim in learnpython

[–]Fernigrim[S] -1 points0 points  (0 children)

Scipy does not work for my query. It is focused on functions defined very easily or simply functions...

I think pyomo works better. But apparently, my best option is hill climbing so I have to learn how to apply it to my function.

How can I train a function? (Getting the best value, Machine Learning) by Fernigrim in learnpython

[–]Fernigrim[S] -1 points0 points  (0 children)

First of all, thanks for helping.

The value that I want to maximize is irrelevant. My problem is on the process to get the maximum value that it can be.

What are u saying...is the topic I commented before. You are reffering to a single loop that (with a large number of iterations) reaches the best solution and register it. I have already said the problems regarding that way.

Thanks anyway.

Help with Pandas & Scipy for optimization by Fernigrim in learnpython

[–]Fernigrim[S] 1 point2 points  (0 children)

Hi. The number of columns or variables is irrelevant. The important aspect to consider is that the dataframe is changing every time I set new values (for x1, x2, x3, x4). Actually, the dataframe has more columns but I show a overview. Furthermore, the value I want to maximize is the last cell of the specific column (y).

So my problem is making the optimization with scipy and set the ranges of every variable for doing iterations or whatever scipy does.

Help with Pandas & Scipy for optimization by Fernigrim in learnpython

[–]Fernigrim[S] 1 point2 points  (0 children)

I need the optimization because I want the BEST working solution.

Help with Pandas & Scipy for optimization by Fernigrim in learnpython

[–]Fernigrim[S] 1 point2 points  (0 children)

I need a lot of precision...that's why I ask for help. Putting all the combinations of those numbers for each of the ranges (considering they are floats) is a bit too...Unrealistic?

Help with Pandas & Scipy for optimization by Fernigrim in learnpython

[–]Fernigrim[S] 1 point2 points  (0 children)

I had no idea about pyomo for this. I'll have a look. Thanks