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
|
||||
- `volumeaveragegroups.mq5`
|
||||
|
||||
---
|
||||
> Made with ❤️ for the trading community.
|
||||
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 |
+50
@@ -0,0 +1,50 @@
|
||||
// Learn how to manage the volume data, separate it in groups for comparison.
|
||||
// Why is it important? Volume indicates commitment of the traders with the price movement.
|
||||
// it may help you create strategies based on volume trading, trend and momentum.
|
||||
|
||||
// We separate this code in functions to help you understand it easily and apply it for your own use.
|
||||
|
||||
input int volQtyGroupOne = 3; // Quantity of Volume bars to consider for group one
|
||||
input int volQtyGroupTwo = 6; // Quantity of Volume bars to consider Starting from the end of group one
|
||||
|
||||
|
||||
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnTick()
|
||||
{
|
||||
int avgVolGroupOne = getVolAgv(1, volQtyGroupOne);
|
||||
int avgVolGroupTwo = getVolAgv(volQtyGroupOne+1, volQtyGroupTwo);
|
||||
|
||||
Comment("Vol Avg G1: ", avgVolGroupOne,
|
||||
"\nVol Avg G2: ", avgVolGroupTwo);
|
||||
}
|
||||
|
||||
|
||||
// This function below gets as parameter the quantity of bars you want to consider and return its average
|
||||
int getVolAgv(int volQtyOfBarsStart, int volQtyOfBarsEnd)
|
||||
{
|
||||
double myPriceArray[];
|
||||
int VolumeDefinition = iVolumes(_Symbol, _Period, VOLUME_TICK);
|
||||
ArraySetAsSeries(myPriceArray, true);
|
||||
int qtyVolumeToGetFromBuffer = volQtyOfBarsStart+volQtyOfBarsEnd+1;
|
||||
CopyBuffer(VolumeDefinition,0,0,qtyVolumeToGetFromBuffer,myPriceArray);
|
||||
double volAverage = 0;
|
||||
int iVolAvg = 0;
|
||||
|
||||
for(int i = volQtyOfBarsStart; i <= volQtyOfBarsEnd; i++)
|
||||
{
|
||||
volAverage += (myPriceArray[i]);
|
||||
}
|
||||
|
||||
if(volQtyOfBarsStart == 1)
|
||||
volAverage /= volQtyOfBarsEnd;
|
||||
else
|
||||
volAverage /= (1+volQtyOfBarsEnd-volQtyOfBarsStart);
|
||||
|
||||
iVolAvg = MathFloor(volAverage);
|
||||
|
||||
return iVolAvg;
|
||||
}
|
||||
Reference in New Issue
Block a user