Initial commit: MQL5 Scripts Collection (MetaTrader 5)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# 🚀 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
|
||||
- `chartnavigate.mq5`
|
||||
|
||||
---
|
||||
> Made with ❤️ for the trading community.
|
||||
@@ -0,0 +1,80 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ChartNavigate.mq5 |
|
||||
//| Copyright © 2011, MetaQuotes Software Corp. |
|
||||
//| http://www.metaquotes.net |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
|
||||
#property link "http://www.metaquotes.net"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//--- get handle of the current chart
|
||||
long handle=ChartID();
|
||||
string comm="";
|
||||
if(handle>0) // if successful, configure it
|
||||
{
|
||||
//--- disable autoscroll
|
||||
ChartSetInteger(handle,CHART_AUTOSCROLL,false);
|
||||
//--- set chart shift
|
||||
ChartSetInteger(handle,CHART_SHIFT,true);
|
||||
//--- show as candles
|
||||
ChartSetInteger(handle,CHART_MODE,CHART_CANDLES);
|
||||
//--- show tick volumes
|
||||
ChartSetInteger(handle,CHART_SHOW_VOLUMES,CHART_VOLUME_TICK);
|
||||
|
||||
//--- prepare text for Comment()
|
||||
comm="Let's scroll the chart 10 bars right from the beggining of the history)";
|
||||
//--- print comment
|
||||
Comment(comm);
|
||||
//--- scroll 10 bars right
|
||||
ChartNavigate(handle,CHART_BEGIN,10);
|
||||
//--- get first bar index (indexing as timeseries)
|
||||
long first_bar=ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
|
||||
//--- add CR/LF
|
||||
comm=comm+"\r\n";
|
||||
//--- add to comment
|
||||
comm=comm+"First bar has index "+IntegerToString(first_bar)+"\r\n";
|
||||
//--- print comment
|
||||
Comment(comm);
|
||||
//--- wait 5 seconds to see how ChartNavigate works
|
||||
Sleep(5000);
|
||||
|
||||
//--- add to comment
|
||||
comm=comm+"\r\n"+"Scroll 10 bars left (from the right border of the chart)";
|
||||
Comment(comm);
|
||||
//--- scroll 10 bars left
|
||||
ChartNavigate(handle,CHART_END,-10);
|
||||
//--- get first bar index (indexing as timeseries)
|
||||
first_bar=ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
|
||||
comm=comm+"\r\n";
|
||||
comm=comm+"First bar has index "+IntegerToString(first_bar)+"\r\n";
|
||||
Comment(comm);
|
||||
//--- wait 5 seconds to see how ChartNavigate works
|
||||
Sleep(5000);
|
||||
|
||||
//--- new scrolling
|
||||
comm=comm+"\r\n"+"Scroll 1000 bars right from the beggining of the history";
|
||||
Comment(comm);
|
||||
//--- scroll 1000 bars right
|
||||
ChartNavigate(handle,CHART_BEGIN,1000);
|
||||
first_bar=ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
|
||||
comm=comm+"\r\n";
|
||||
comm=comm+"First bar has index "+IntegerToString(first_bar)+"\r\n";
|
||||
Comment(comm);
|
||||
//--- wait 5 seconds to see how ChartNavigate works
|
||||
Sleep(5000);
|
||||
|
||||
//--- new demo
|
||||
comm=comm+"\r\n"+"Scroll 1000 bars left from the right border of the chart";
|
||||
Comment(comm);
|
||||
//--- scroll -100 bars left from the right border of the chart
|
||||
ChartNavigate(handle,CHART_END,-1000);
|
||||
first_bar=ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
|
||||
comm=comm+"\r\n";
|
||||
comm=comm+"First bar has index "+IntegerToString(first_bar)+"\r\n";
|
||||
Comment(comm);
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.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