Hi all,
I've started a thread not long ago about my journey into programming due to COVID and having time in my hands.
My first program was about finding highest wick of a serious of candles.
Tnx to beerruns help that was a success.
Now I started a new challenge and I've already written the start of the program.
I want experienced coders to look at it and see if it can be made better, concise, clean etc.
As of now what the program does?;
The user chooses the amount of bars to check(lookback) at the beginning of the script(Yes I can only code scripts as I am too lazy to go on to my next lessons about creating indicators and EAs)
The code compares the range, body, upperwicksize, lowerwicksize and alerts if any of those values are equal between any of the bars chosen.
Later I will have the code check if all of the values for range,body,upperwick and lowerwick are all equal on any of the bars.
Basically I intend to make a code that finds replicas of candles. And to somewhat predict the next candle's move.
Of course I will need a lot of help in printing or pointing out candles that match on the chart and how best to go about doing that.
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//| findmatch.mq4 |
//| halil |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "halil"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property show_inputs
extern int k=20;
int multiplyer;
double rangetocheck;
double range;
double bodytocheck;
double body;
double wickhightocheck;
double wickhigh;
double wicklowtocheck;
double wicklow;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart() {
//-------------------------------------------------------------------+
Alert("");
for(int i=k;i>1;i--){
for(int j=i-1;j>0;j--){
//RANGE VALUE=============================================
//Get the first bars range value
rangetocheck=High[i]-Low[i];
multiplyer=Digits>=5?10000:100;
rangetocheck=rangetocheck*multiplyer;
rangetocheck=MathRound(rangetocheck);
rangetocheck=DoubleToStr(rangetocheck,0);
//Get the second bars range value
range=High[j]-Low[j];
multiplyer=Digits>=5?10000:100;
range=range*multiplyer;
range=MathRound(range);
range=DoubleToStr(range,0);
//print if there is a range match or not
if(rangetocheck==range)
{
Alert("we have a match for RANGE");
Alert("candle # ",i," = ",rangetocheck," candle # ",j," = ",range);
Alert("");
}
else
{
Alert("we dont have a match for RANGE");
Alert("");
}
//BODY VALUE==================================================
//Get the first bars body value
bodytocheck=Open[i]>Close[i]?Open[i]-Close[i]:Close[i]-Open[i];
multiplyer=Digits>=5?10000:100;
bodytocheck=bodytocheck*multiplyer;
bodytocheck=MathRound(bodytocheck);
bodytocheck=DoubleToStr(bodytocheck,0);
//Get the second bars body value
body=Open[j]>Close[j]?Open[j]-Close[j]:Close[j]-Open[j];
multiplyer=Digits>=5?10000:100;
body=body*multiplyer;
body=MathRound(body);
body=DoubleToStr(body,0);
//print if there is a body match or not
if(bodytocheck==body)
{
Alert("we have a match for BODY");
Alert("candle # ",i," = ",bodytocheck," candle # ",j," = ",body);
Alert("");
}
else
{
Alert("we dont have a match for BODY");
Alert("");
}
//WICK HIGH VALUE==================================================
//Get the first bars wick high value
wickhightocheck=Open[i]>Close[i]?High[i]-Open[i]:High[i]-Close[i];
multiplyer=Digits>=5?10000:100;
wickhightocheck=wickhightocheck*multiplyer;
wickhightocheck=MathRound(wickhightocheck);
wickhightocheck=DoubleToStr(wickhightocheck,0);
//Get the second bars wick high value
wickhigh=Open[j]>Close[j]?High[j]-Open[j]:High[j]-Close[j];
multiplyer=Digits>=5?10000:100;
wickhigh=wickhigh*multiplyer;
wickhigh=MathRound(wickhigh);
wickhigh=DoubleToStr(wickhigh,0);
//print if there is a wick high match or not
if(wickhightocheck==wickhigh)
{
Alert("we have a match for WICK HIGH");
Alert("candle # ",i," = ",wickhightocheck," candle # ",j," = ",wickhigh);
Alert("");
}
else
{
Alert("we dont have a match for WICK HIGH");
Alert("");
}
//WICK LOW VALUE==================================================
//Get the first bars wick low value
wicklowtocheck=Open[i]>Close[i]?Close[i]-Low[i]:Open[i]-Low[i];
multiplyer=Digits>=5?10000:100;
wicklowtocheck=wicklowtocheck*multiplyer;
wicklowtocheck=MathRound(wicklowtocheck);
wicklowtocheck=DoubleToStr(wicklowtocheck,0);
//Get the second bars wick low value
wicklow=Open[j]>Close[j]?Close[j]-Low[j]:Open[j]-Low[j];
multiplyer=Digits>=5?10000:100;
wicklow=wicklow*multiplyer;
wicklow=MathRound(wicklow);
wicklow=DoubleToStr(wicklow,0);
//print if there is a wick low match or not
if(wicklowtocheck==wicklow)
{
Alert("we have a match for WICK LOW");
Alert("candle # ",i," = ",wicklowtocheck," candle # ",j," = ",wicklow);
Alert("");
}
else
{
Alert("we dont have a match for WICK LOW");
Alert("");
}
}
//===========================================================
}
//+------------------------------------------------------------------+
}
I've started a thread not long ago about my journey into programming due to COVID and having time in my hands.
My first program was about finding highest wick of a serious of candles.
Tnx to beerruns help that was a success.
Now I started a new challenge and I've already written the start of the program.
I want experienced coders to look at it and see if it can be made better, concise, clean etc.
As of now what the program does?;
The user chooses the amount of bars to check(lookback) at the beginning of the script(Yes I can only code scripts as I am too lazy to go on to my next lessons about creating indicators and EAs)
The code compares the range, body, upperwicksize, lowerwicksize and alerts if any of those values are equal between any of the bars chosen.
Later I will have the code check if all of the values for range,body,upperwick and lowerwick are all equal on any of the bars.
Basically I intend to make a code that finds replicas of candles. And to somewhat predict the next candle's move.
Of course I will need a lot of help in printing or pointing out candles that match on the chart and how best to go about doing that.
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//| findmatch.mq4 |
//| halil |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "halil"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property show_inputs
extern int k=20;
int multiplyer;
double rangetocheck;
double range;
double bodytocheck;
double body;
double wickhightocheck;
double wickhigh;
double wicklowtocheck;
double wicklow;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart() {
//-------------------------------------------------------------------+
Alert("");
for(int i=k;i>1;i--){
for(int j=i-1;j>0;j--){
//RANGE VALUE=============================================
//Get the first bars range value
rangetocheck=High[i]-Low[i];
multiplyer=Digits>=5?10000:100;
rangetocheck=rangetocheck*multiplyer;
rangetocheck=MathRound(rangetocheck);
rangetocheck=DoubleToStr(rangetocheck,0);
//Get the second bars range value
range=High[j]-Low[j];
multiplyer=Digits>=5?10000:100;
range=range*multiplyer;
range=MathRound(range);
range=DoubleToStr(range,0);
//print if there is a range match or not
if(rangetocheck==range)
{
Alert("we have a match for RANGE");
Alert("candle # ",i," = ",rangetocheck," candle # ",j," = ",range);
Alert("");
}
else
{
Alert("we dont have a match for RANGE");
Alert("");
}
//BODY VALUE==================================================
//Get the first bars body value
bodytocheck=Open[i]>Close[i]?Open[i]-Close[i]:Close[i]-Open[i];
multiplyer=Digits>=5?10000:100;
bodytocheck=bodytocheck*multiplyer;
bodytocheck=MathRound(bodytocheck);
bodytocheck=DoubleToStr(bodytocheck,0);
//Get the second bars body value
body=Open[j]>Close[j]?Open[j]-Close[j]:Close[j]-Open[j];
multiplyer=Digits>=5?10000:100;
body=body*multiplyer;
body=MathRound(body);
body=DoubleToStr(body,0);
//print if there is a body match or not
if(bodytocheck==body)
{
Alert("we have a match for BODY");
Alert("candle # ",i," = ",bodytocheck," candle # ",j," = ",body);
Alert("");
}
else
{
Alert("we dont have a match for BODY");
Alert("");
}
//WICK HIGH VALUE==================================================
//Get the first bars wick high value
wickhightocheck=Open[i]>Close[i]?High[i]-Open[i]:High[i]-Close[i];
multiplyer=Digits>=5?10000:100;
wickhightocheck=wickhightocheck*multiplyer;
wickhightocheck=MathRound(wickhightocheck);
wickhightocheck=DoubleToStr(wickhightocheck,0);
//Get the second bars wick high value
wickhigh=Open[j]>Close[j]?High[j]-Open[j]:High[j]-Close[j];
multiplyer=Digits>=5?10000:100;
wickhigh=wickhigh*multiplyer;
wickhigh=MathRound(wickhigh);
wickhigh=DoubleToStr(wickhigh,0);
//print if there is a wick high match or not
if(wickhightocheck==wickhigh)
{
Alert("we have a match for WICK HIGH");
Alert("candle # ",i," = ",wickhightocheck," candle # ",j," = ",wickhigh);
Alert("");
}
else
{
Alert("we dont have a match for WICK HIGH");
Alert("");
}
//WICK LOW VALUE==================================================
//Get the first bars wick low value
wicklowtocheck=Open[i]>Close[i]?Close[i]-Low[i]:Open[i]-Low[i];
multiplyer=Digits>=5?10000:100;
wicklowtocheck=wicklowtocheck*multiplyer;
wicklowtocheck=MathRound(wicklowtocheck);
wicklowtocheck=DoubleToStr(wicklowtocheck,0);
//Get the second bars wick low value
wicklow=Open[j]>Close[j]?Close[j]-Low[j]:Open[j]-Low[j];
multiplyer=Digits>=5?10000:100;
wicklow=wicklow*multiplyer;
wicklow=MathRound(wicklow);
wicklow=DoubleToStr(wicklow,0);
//print if there is a wick low match or not
if(wicklowtocheck==wicklow)
{
Alert("we have a match for WICK LOW");
Alert("candle # ",i," = ",wicklowtocheck," candle # ",j," = ",wicklow);
Alert("");
}
else
{
Alert("we dont have a match for WICK LOW");
Alert("");
}
}
//===========================================================
}
//+------------------------------------------------------------------+
}