Skip to content

Instantly share code, notes, and snippets.

View mamirjamali's full-sized avatar

Amir Jamali mamirjamali

View GitHub Profile
@mamirjamali
mamirjamali / Python-Piviot-Points.py
Last active June 12, 2023 19:09
Python - Pivot-Points for 200 past candels integrated with MQL API
import datetime
import pandas as pd
import MetaTrader5 as mt5
import re
mt5.initialize()
account=###Your Acount######
authorized= mt5.login(account)
first_date = datetime.datetime(1970, 1, 1)
@mamirjamali
mamirjamali / Last-Order-Open-Price-MQL.cpp
Last active January 4, 2023 09:31
MQL - Get the last order open price of the history and print it
double MylastOrderOpenPrice()
{
// retrieving info from trade history
double LastOrderOpenPrice = 0;
int i, hstTotal = OrdersHistoryTotal();
for (i = 0; i < hstTotal; i++)
{
//---- check selection result
OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
@mamirjamali
mamirjamali / Last-Order-Profit-MQL.cpp
Created January 4, 2023 09:15
Get the last oder profit of the History
double MylastOrderProfit()
{
// retrieving info from trade history
double LastOrderProfit = 0;
int i, hstTotal = OrdersHistoryTotal();
for (i = 0; i < hstTotal; i++)
{
//---- check selection result
OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
if (i == OrdersHistoryTotal() - 1)
@mamirjamali
mamirjamali / Last-Order-Type-MQL.cpp
Last active January 4, 2023 09:32
MQL - Get the last order type in the history
string MyLastOrderType()
{
// retrieving info from trade history
string LastOrderType = "None";
int i, hstTotal = OrdersHistoryTotal();
for (i = 0; i < hstTotal; i++)
{
//---- check selection result
OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
if (i == OrdersHistoryTotal() - 1)
@mamirjamali
mamirjamali / Delete-Pending-Orders-MQL.cpp
Last active January 4, 2023 09:31
MQL - Delete pending orders after 5 minutes
void DeletePendingOrders()
{
if (OrdersTotal() >= 1)
{
if (OrderSelect(0, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLLIMIT)
{
if ((((TimeHour(OrderOpenTime())*60)+TimeMinute(OrderOpenTime())) - ((Hour()*60)+Minute()))>5)
{
@mamirjamali
mamirjamali / Daily-Profit-MQL.cpp
Created January 4, 2023 09:03
Stop EA based on daily profit
double DailyProfit()
{
double profit = 0;
int i, hstTotal = OrdersHistoryTotal();
for (i = 0; i < hstTotal; i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) == TRUE)
{
if (OrderType() > 1)
continue;