Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Libraries

Database Wrapper - library for MetaTrader 5

MoT
Published by:
mot
Views:
3698
Rating:
(14)
Published:
2021.01.30 09:28
Updated:
2022.09.09 09:24
\MQL5\Include\
Database.mqh (131.18 KB) view
test.mq5 (4.08 KB) view
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Introduction

SQLite locks are coarse-grained file locks. If multiple tables share a database, you need to pay attention to synchronization issues.
a. It is not recommended to define global variables for the classes in this class, otherwise 5605 errors will easily occur
b. After the query, the data should be retrieved and released as soon as possible to prevent other connections from being unable to obtain the reserved lock

c. Try to Execute in the transaction to avoid some 5605 errors



This is an encapsulation library of DatabaseXXX series functions, which realizes the automatic release of resources


//Open

CDatabase db( "test.db" );   //对象生命周期结束时,自动调用DatabaseClose

Print ( "db IsAvaliable=" , db.IsAvaliable());

// have table

 Print ( "table" ,db.HasTable( "tab" ) ? "exist" : "不存在" );

//implement

db.Execute("创建表tab(aa integer, bb double , cc string );");

for ( int i= 1 ;i< 10 ;i++)
{

db.Execute( StringFormat ("插入 (aa, bb, cc) 值(%d, %G, %s);", i, rand ()/ 100 , SQLiteTimeStr( TimeCurrent ())));

}

//read

CDatabaseRequest req = db.Query( "select * from tab" ); //对象生命周期结束时,自动调用DatabaseFinalize

int v;

req.GetInteger( 0 , v);

int v2 = req.GetIntegerOrDefault( "aa" );

 int v;

double d;

string  s;

bool rc = db.QueryFirst< int , double , string >(v, d, s, "select * from tab" );

 int v[];

double d[];

string s[];

bool rc = db.Query< int , double , string >(v, d, s, "select * from tab" );


Sell using amount instead of lots Sell using amount instead of lots

I find the lot calculation tedious so I just use this script and tell it the dollar amount to use. It then does the rest. This works for any currency.

Buy using amount instead of lots Buy using amount instead of lots

I find the lot calculation tedious so I just use this script and tell it the dollar amount to use. It then does the rest. This works for any currency.

Spread data collector Spread data collector

This EA collects information about the spreads and Shows the number of spreads in the specified range based on the ticks that occur each year.

INDICATOR Breakout Strength Meter - MT5 INDICATOR Breakout Strength Meter - MT5

The breakout strength meter is a trading tool that is used to identify which currencies are the strongest to breakout, and which currencies are the weakest to breakout