FREENOTE
Sign up
Login
New paste
Home
Trending
Archive
English
English
Sign up
Login
New Paste
Browse
//+------------------------------------------------------------------+ //| Cuongitl_EA.mq4 | //| Copyright 2020, Cuongitl. | //| https://t.me/Cuongitl | //+------------------------------------------------------------------+ // Bot này tính làm hiển thị PnL trên chart thôi!! #property copyright "Copyright 2020, Cuongitl." #property link "https://t.me/Cuongitl" #property version "1.00" #property strict extern int BuyMagicNumber = 202002101; //Buy ID extern int SellMagicNumber = 202002102; //Sell ID //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+ //| Buy Market Profit Function | //+------------------------------------------------------------------+ double Profit; int Counter = 0; double BuyMarketProfit(string argSymbol, int argMagicNumber) { Profit = 0.0; for(Counter = 0; Counter <= OrdersTotal() - 1; Counter++) { if(OrderSelect(Counter, SELECT_BY_POS) == true) { if(OrderMagicNumber() == argMagicNumber && OrderSymbol() == argSymbol && OrderType() == OP_BUY) { Profit = Profit + OrderProfit() + OrderCommission() + OrderSwap(); // 2019.04.25 } } } return(Profit); } //+------------------------------------------------------------------+ //| Sell Market Profit Function | //+------------------------------------------------------------------+ double SellMarketProfit(string argSymbol, int argMagicNumber) { Profit = 0.0; for(Counter = 0; Counter <= OrdersTotal() - 1; Counter++) { if(OrderSelect(Counter, SELECT_BY_POS) == true) { if(OrderMagicNumber() == argMagicNumber && OrderSymbol() == argSymbol && OrderType() == OP_SELL) { Profit = Profit + OrderProfit() + OrderCommission() + OrderSwap(); // 2019.04.25 } } } return(Profit); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ string EA_Ver; double BuyProfit, SellProfit; void PrintDetails() { EA_Ver = AccountName() + ". ID: " + IntegerToString(AccountNumber()); BuyProfit = BuyMarketProfit(Symbol(), BuyMagicNumber); SellProfit = SellMarketProfit(Symbol(), SellMagicNumber); double Drawdown = (1 - AccountEquity() / AccountBalance()) * 100; //if(Drawdown > MaxDrawdown) // MaxDrawdown = Drawdown; string EquityProtection_Active = "No"; datetime nextCandleTime = (Period() * 60) - (TimeCurrent() - iTime(NULL, 0, 0)); string text0 = EA_Ver; string text1 = "Balance: " + DoubleToStr(AccountBalance(), 2) + " | Equity: " + DoubleToStr(AccountEquity(), 2); string text2; //if(UseEquityProtection) // { // EquityProtection_Active = ":"; // text2 = "Equity Protection " + EquityProtection_Active + " " + DoubleToStr(EquityProtectionPercent, 0) + "% ~ " + DoubleToStr(EquityAmount, 2) + "$"; // } //else // text2 = "Equity Protection: " + EquityProtection_Active; //string text22; //if(UseBasketGoal && Basket_StopLoss > 0) // text22 = "PnL: " + DoubleToStr(TotalProfit, 2) + " | " + DoubleToStr(Basket_StopLoss, 0); //---------------------------------------------- string text3 = "-===== Parameter Settings =====-"; string text4 = "Auto: " + EA_Activated + ". Lot: " + DoubleToStr(LOT(), 2) + ". MaxOrders: " + IntegerToString(MaxOrdersTotal); string text5 = "Target($): " + IntegerToString(OrderProfitGoal) + "/" + IntegerToString(TotalProfitGoal); string text6 = "BE: " + DoubleToStr(BreakEvenAfterPip, 0) + "/" + DoubleToStr(ProfitLockPip, 0) + "/" + IntegerToString(FixedStepTS); string text7; if(SellGrid && BuyGrid) text7 = "Sell Step: " + IntegerToString(InpSellGridStep) + " | " + "Buy Step: " + IntegerToString(InpBuyGridStep); else if(SellGrid && !BuyGrid) text7 = "Sell Step: " + IntegerToString(InpSellGridStep) + " | " + IntegerToString(GridStepMultiRound); else if(BuyGrid && !SellGrid) text7 = "Buy Step: " + IntegerToString(InpBuyGridStep) + " | " + IntegerToString(GridStepMultiRound); string text8 = "Spread: " + DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD) / 10, 2) + " | " + DoubleToStr(MaxSpread, 2); //---------------------------------------------- string text9 = "-===== Trade Information =====-"; string text10 = "Market: " + DoubleToStr(MarketOrdersTotal, 0); // + "(Size=" + DoubleToStr(MarketOrdersTotal*LOT(),2) + ")"; string text11; string text12; //if(UseStopOrders) // text11 = "Buy:" + DoubleToStr(BuyOrdersTotal,0) + " Active:" + DoubleToStr(BuyMarketOrdersTotal,0) + " | Limit: " + DoubleToStr(BuyLimitOrdersTotal,0) + " | Stop: " + DoubleToStr(BuyStopOrdersTotal,0); //else text11 = "Buy:" + DoubleToStr(BuyOrdersTotal, 0) + " Active:" + DoubleToStr(BuyMarketOrdersTotal, 0) + " | Limit: " + DoubleToStr(BuyLimitOrdersTotal, 0); //if(UseStopOrders) // text12 = "Sell:" + DoubleToStr(SellOrdersTotal,0) + " Active:" + DoubleToStr(SellMarketOrdersTotal,0) + " | Limit: " + DoubleToStr(SellLimitOrdersTotal,0) + " | Stop: " + DoubleToStr(SellStopOrdersTotal,0); //else text12 = "Sell:" + DoubleToStr(SellOrdersTotal, 0) + " Active:" + DoubleToStr(SellMarketOrdersTotal, 0) + " | Limit: " + DoubleToStr(SellLimitOrdersTotal, 0); string text13 = "Total Orders: " + DoubleToStr(OrdersTotal(), 0) + "(MaxSize=" + DoubleToStr(SizeTotal, 2) + ")"; string text14 = "-- Buy Profit: " + DoubleToStr(BuyProfit, 2); string text15 = "-- Sell Profit: " + DoubleToStr(SellProfit, 2); // if(BuyGrid && SellGrid && BuyProfit != 0.0 && SellProfit != 0.0) // { // double TempProfit = BuyProfit + SellProfit; // if(TempProfit <= MaxPnL) // MaxPnL = TempProfit; // } // else // if(BuyGrid && !SellGrid && BuyProfit <= MaxPnL) // { // MaxPnL = BuyProfit; // } // else // if(SellGrid && !BuyGrid && SellProfit <= MaxPnL) // { // MaxPnL = SellProfit; // // } // string text17 = "PnLlog: " + DoubleToStr(MaxPnL, 2); // string text18 = "MDDlog: " + DoubleToStr(MaxDrawdown, 2) + "%"; // string text19 = "Next candle: " + TimeToStr(nextCandleTime, TIME_SECONDS); // string text20 = "Sell highest: " + DoubleToStr(highestMarketSellPrice, Digits); // string text21 = "Buy lowest: " + DoubleToStr(lowestMarketBuyPrice, Digits); string name0 = "iDebug0"; string name1 = "iDebug1"; string name2 = "iDebug2"; string name3 = "iDebug3"; string name4 = "iDebug4"; string name5 = "iDebug5"; string name6 = "iDebug6"; string name7 = "iDebug7"; string name8 = "iDebug8"; string name9 = "iDebug9"; string name10 = "iDebug10"; string name11 = "iDebug11"; string name12 = "iDebug12"; string name13 = "iDebug13"; string name14 = "iDebug14"; string name15 = "iDebug15"; string name16 = "iDebug16"; string name17 = "iDebug17"; string name18 = "iDebug18"; string name19 = "iDebug19"; string name20 = "iDebug20"; string name21 = "iDebug21"; string name22 = "iDebug22"; //Basket // ---- Object Section: string sObjName; int WhichCorner = 1; //0,1,2 or 3 int x_pos = 0; int y_pos = 0; string obj_text; sObjName = name0; obj_text = text0; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, text0, textsize + 2, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist);//left to right ObjectSet(sObjName, OBJPROP_YDISTANCE, y_dist);//top to bottom sObjName = name1; obj_text = text1; y_pos = y_pos + y_dist + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); sObjName = name2; obj_text = text2; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); //-- if(UseBasketGoal && Basket_StopLoss > 0) { sObjName = name22; obj_text = text22; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); } sObjName = name3; obj_text = text3; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); sObjName = name4; obj_text = text4; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); sObjName = name5; //Target($) obj_text = text5; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); sObjName = name6; //BE obj_text = text6; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); sObjName = name7; //SellGrid or BuyGrid Step obj_text = text7; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); sObjName = name8; //Spread obj_text = text8; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); sObjName = name9; //Trade Information obj_text = text9; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); sObjName = name10; //Number of Active obj_text = text10; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); if(OrdersTotal() > 0) { if(BuyGrid) { sObjName = name11; obj_text = text11; // Buy Order y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); } if(SellGrid) { sObjName = name12; obj_text = text12; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); } sObjName = name13; //Total Orders obj_text = text13; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); if(BuyGrid) { sObjName = name14; // Buy Profit obj_text = text14; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); } if(SellGrid) { sObjName = name15; //Sell Profit obj_text = text15; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); } } sObjName = name17; //MaxPnL obj_text = text17; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); sObjName = name18; //MaxDrawDown obj_text = text18; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); if(SellGrid) { sObjName = name20; //max price obj_text = text20; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); } if(BuyGrid) { sObjName = name21; //max price obj_text = text21; y_pos = y_pos + 15; ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); ObjectSetText(sObjName, obj_text, textsize, "Arial", DisplayColor); ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); } //if(NextCandleCountDown) // { // sObjName = name19; // obj_text = text19; // y_pos = y_pos + 30; // ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); // ObjectSetText(sObjName, obj_text, textsize, "Arial", clrYellow); // ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner); // ObjectSet(sObjName, OBJPROP_XDISTANCE, x_dist); // ObjectSet(sObjName, OBJPROP_YDISTANCE, y_pos); // } //if(Period() == PERIOD_M5) // { // sObjName = "TimeFrame"; // obj_text = CurrentTimeFrame() + " Chart"; // ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); // ObjectSet(sObjName, OBJPROP_XDISTANCE, 545); // ObjectSet(sObjName, OBJPROP_YDISTANCE, 4); // ObjectSet(sObjName, OBJPROP_COLOR, Red); // ObjectSetText(sObjName, obj_text); // ObjectSet(sObjName, OBJPROP_FONTSIZE, 15); // } //else // { // sObjName = "TimeFrame"; // obj_text = "=== " + CurrentTimeFrame() + " Chart ==="; // ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0); // ObjectSet(sObjName, OBJPROP_XDISTANCE, 545); // ObjectSet(sObjName, OBJPROP_YDISTANCE, 4); // ObjectSet(sObjName, OBJPROP_COLOR, Red); // ObjectSetText(sObjName, obj_text); // ObjectSet(sObjName, OBJPROP_FONTSIZE, 15); // } } //+------------------------------------------------------------------+
Paste Settings
Paste Title :
[Optional]
Paste Folder :
[Optional]
Select
Syntax Highlighting :
[Optional]
Select
Markup
CSS
JavaScript
Bash
C
C#
C++
Java
JSON
Lua
Plaintext
C-like
ABAP
ActionScript
Ada
Apache Configuration
APL
AppleScript
Arduino
ARFF
AsciiDoc
6502 Assembly
ASP.NET (C#)
AutoHotKey
AutoIt
Basic
Batch
Bison
Brainfuck
Bro
CoffeeScript
Clojure
Crystal
Content-Security-Policy
CSS Extras
D
Dart
Diff
Django/Jinja2
Docker
Eiffel
Elixir
Elm
ERB
Erlang
F#
Flow
Fortran
GEDCOM
Gherkin
Git
GLSL
GameMaker Language
Go
GraphQL
Groovy
Haml
Handlebars
Haskell
Haxe
HTTP
HTTP Public-Key-Pins
HTTP Strict-Transport-Security
IchigoJam
Icon
Inform 7
INI
IO
J
Jolie
Julia
Keyman
Kotlin
LaTeX
Less
Liquid
Lisp
LiveScript
LOLCODE
Makefile
Markdown
Markup templating
MATLAB
MEL
Mizar
Monkey
N4JS
NASM
nginx
Nim
Nix
NSIS
Objective-C
OCaml
OpenCL
Oz
PARI/GP
Parser
Pascal
Perl
PHP
PHP Extras
PL/SQL
PowerShell
Processing
Prolog
.properties
Protocol Buffers
Pug
Puppet
Pure
Python
Q (kdb+ database)
Qore
R
React JSX
React TSX
Ren'py
Reason
reST (reStructuredText)
Rip
Roboconf
Ruby
Rust
SAS
Sass (Sass)
Sass (Scss)
Scala
Scheme
Smalltalk
Smarty
SQL
Soy (Closure Template)
Stylus
Swift
TAP
Tcl
Textile
Template Toolkit 2
Twig
TypeScript
VB.Net
Velocity
Verilog
VHDL
vim
Visual Basic
WebAssembly
Wiki markup
Xeora
Xojo (REALbasic)
XQuery
YAML
HTML
Paste Expiration :
[Optional]
Never
Self Destroy
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Status :
[Optional]
Public
Unlisted
Private (members only)
Password :
[Optional]
Description:
[Optional]
Tags:
[Optional]
Encrypt Paste
(
?
)
Create New Paste
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Site Languages
×
English
Do you like cookies?
🍪 We use cookies to ensure you get the best experience on our website.
Learn more
I agree