82 lines
3.8 KiB
MQL5
82 lines
3.8 KiB
MQL5
#property copyright "Copyright 2023, M & Q Investment Group"
|
|
#property link "https://www.mql5.com"
|
|
#property version "1.00"
|
|
|
|
bool CheckfornewCandle (int CandleNumber)
|
|
{
|
|
|
|
static int LastCandleNumber;
|
|
|
|
bool IsNewCandle= false;
|
|
|
|
if (CandleNumber>LastCandleNumber)
|
|
{
|
|
|
|
IsNewCandle = true;
|
|
|
|
LastCandleNumber = CandleNumber;
|
|
|
|
Print("New Candle",
|
|
"\nLastOpenTime: ",iTime(_Symbol,PERIOD_CURRENT,1),
|
|
"\nLastOpen: ",iOpen(_Symbol,PERIOD_CURRENT,1),
|
|
"\nLastClose: ",iClose(_Symbol,PERIOD_CURRENT,1));
|
|
|
|
|
|
}
|
|
return IsNewCandle;
|
|
|
|
}
|
|
|
|
void OnTick()
|
|
{
|
|
|
|
int CandleNumber = Bars(_Symbol,_Period);
|
|
|
|
bool NewCandleAppeared;
|
|
|
|
NewCandleAppeared = CheckfornewCandle(CandleNumber);
|
|
|
|
if (NewCandleAppeared)
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
void OnTimer()
|
|
{
|
|
|
|
// create array for price data
|
|
MqlRates Priceinformation[];
|
|
|
|
//sort the array from the current candle downwards
|
|
ArraySetAsSeries(Priceinformation,true);
|
|
|
|
//fill the array with price data
|
|
int copied = CopyRates(_Symbol,PERIOD_M1,0,1440,Priceinformation);
|
|
|
|
|
|
|
|
double Pricedifference[];
|
|
int PriceinformationSize = ArraySize(Priceinformation);
|
|
ArrayResize(Pricedifference,PriceinformationSize,0);
|
|
|
|
for (int i = 0; i < PriceinformationSize - 1; i ++)
|
|
{
|
|
|
|
Pricedifference[i] = Priceinformation[i].close - Priceinformation[i+1].close;
|
|
|
|
}
|
|
|
|
Print("------------------------------------------",
|
|
"\n 2. Last Price: ", NormalizeDouble(Priceinformation[1].close,5));
|
|
|
|
Print("Last Difference: ", NormalizeDouble(Pricedifference[0],5));
|
|
|
|
Print("Last Price: ", NormalizeDouble(Priceinformation[0].close,5));
|
|
|
|
}
|
|
|