Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Telegram !
Rejoignez notre page de fans
Un script intéressant ?
Poster un lien vers celui-ci -
laisser les autres l'évaluer
Vous avez aimé le script ? Essayez-le dans le terminal MetaTrader 5
Bibliothèque

Database Wrapper - bibliothèque pour MetaTrader 5

MoT
Publié par:
mot
Vues:
3765
Note:
(14)
Publié:
2021.01.30 09:28
Mise à jour:
2022.09.09 09:24
\MQL5\Include\
Database.mqh (131.18 KB) afficher
test.mq5 (4.08 KB) afficher
Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur 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