Hi all, due to coronavirus I'm staying home like everyone else. So I decided to learn a bit of Mt4 coding.
For my first script I decided to create a function that gets the average value of the last 14 bars. I was able to get the function working.
However it doesn't round the numbers.
I tried using Mathround command but than it returns 0.00.
Can someone help fix this?
Now to sum up the codes figures out first if its a bearish or bullish closing candle than figures out the high wick of that candle accordingly. Than it sums up all the highwicks than gets the average.
tnx.
+-------------------------------------------
//+------------------------------------------------------------------+
//| test.mq4 |
//| halil |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "halil"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
double wicklowtotal = 0;
double wickhightotal = 0;
double wickhigh =0 ;
double AtrWickhigh;
double AtrWicklow;
Alert("");
for(int i=1; i<14; i++)
{
if (Open [i] > Close [i])
{
//This is A bearish closing Candle
wickhigh = (High [i] - Open [i]);
wickhightotal = wickhightotal + wickhigh;
}
else
{
//This is A bullish closing Candle
wickhigh = (High [i] - Close [i]);
wickhightotal = wickhightotal + wickhigh;
}
}
AtrWickhigh =(wickhightotal/14);
Alert(AtrWickhigh);
}
For my first script I decided to create a function that gets the average value of the last 14 bars. I was able to get the function working.
However it doesn't round the numbers.
I tried using Mathround command but than it returns 0.00.
Can someone help fix this?
Now to sum up the codes figures out first if its a bearish or bullish closing candle than figures out the high wick of that candle accordingly. Than it sums up all the highwicks than gets the average.
tnx.
+-------------------------------------------
//+------------------------------------------------------------------+
//| test.mq4 |
//| halil |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "halil"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
double wicklowtotal = 0;
double wickhightotal = 0;
double wickhigh =0 ;
double AtrWickhigh;
double AtrWicklow;
Alert("");
for(int i=1; i<14; i++)
{
if (Open [i] > Close [i])
{
//This is A bearish closing Candle
wickhigh = (High [i] - Open [i]);
wickhightotal = wickhightotal + wickhigh;
}
else
{
//This is A bullish closing Candle
wickhigh = (High [i] - Close [i]);
wickhightotal = wickhightotal + wickhigh;
}
}
AtrWickhigh =(wickhightotal/14);
Alert(AtrWickhigh);
}