Initial commit: MQL5 Scripts Collection (MetaTrader 5)
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@@ -0,0 +1,21 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||

|
||||

|
||||

|
||||
|
||||
## Source Files
|
||||
- `demo_create_obj_bitmap_script.mq5`
|
||||
|
||||
---
|
||||
> Made with ❤️ for the trading community.
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Demo_Create_OBJ_BITMAP_Script.mq5 |
|
||||
//| Copyright 2011, MetaQuotes Software Corp. |
|
||||
//| http://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2011, MetaQuotes Software Corp."
|
||||
#property link "http://www.mql5.com"
|
||||
#property version "1.00"
|
||||
#property script_show_inputs
|
||||
//--- input parameters
|
||||
input string picture_filename="\\Images\\mql5_logo.bmp";
|
||||
//--- object name
|
||||
string bitmap_name="Demo_Bitmap"; // OBJ_BITMAP object name
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//--- create the object of OBJ_BITMAP type, if not found
|
||||
if(ObjectFind(0,bitmap_name)<0)
|
||||
{
|
||||
double high_price=ChartGetDouble(0,CHART_PRICE_MAX);
|
||||
double low_price=ChartGetDouble(0,CHART_PRICE_MIN);
|
||||
long first_bar=ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR);
|
||||
datetime time[];
|
||||
int copied=CopyTime(_Symbol,PERIOD_CURRENT,0,(int)first_bar+1,time);
|
||||
if(copied<0)
|
||||
{
|
||||
PrintFormat("Error in CopyTime call. Error code %d",GetLastError());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ArraySetAsSeries(time,true);
|
||||
}
|
||||
double price=high_price-(high_price-low_price)*0.1;
|
||||
//--- try to create an object of OBJ_BITMAP type
|
||||
bool created=ObjectCreate(0,bitmap_name,OBJ_BITMAP,0,time[(int)first_bar],price);
|
||||
if(created)
|
||||
{
|
||||
ResetLastError();
|
||||
//--- load image from the specified file
|
||||
bool set=ObjectSetString(0,bitmap_name,OBJPROP_BMPFILE,0,picture_filename);
|
||||
//--- check result
|
||||
if(!set)
|
||||
{
|
||||
PrintFormat("Error loading image from file %s. Error code %d",picture_filename,GetLastError());
|
||||
}
|
||||
ResetLastError();
|
||||
//--- redraw the chart to draw the button immediately
|
||||
ChartRedraw(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- error in object creation, print it
|
||||
PrintFormat("Error creating the object of OBJ_BITMAP type. Error code %d",GetLastError());
|
||||
}
|
||||
}
|
||||
Sleep(10000);
|
||||
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Reference in New Issue
Block a user