cleanup and apply typo fix ...
This commit is contained in:
@@ -1,238 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
// SaherElm IT Center MQL5 Indicator
|
||||
// -------------------------------------------
|
||||
// Name: XMidTest
|
||||
// Description: DONCHAIN Channel ...
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm XMidTest Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../Classes/Indicators/x-saherelm.mid.class.mq5"
|
||||
|
||||
//
|
||||
#define ShortName "XMidTest"
|
||||
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 1
|
||||
#property indicator_plots 1
|
||||
|
||||
//
|
||||
// Variables ...
|
||||
XSCMid *mMid;
|
||||
|
||||
//
|
||||
#property indicator_type1 DRAW_LINE
|
||||
double mainBuffer[];
|
||||
double mainColorBuffer[];
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// Initialize Indicator Class ...
|
||||
bool isInited = InitIndicatorClass();
|
||||
if (!isInited)
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Index Buffers ...
|
||||
DefineBuffers();
|
||||
|
||||
//
|
||||
// Set Indicator ShortName ...
|
||||
SetIndicatorName();
|
||||
|
||||
//
|
||||
// Init Succeed ...
|
||||
return INIT_SUCCEEDED;
|
||||
}
|
||||
|
||||
//
|
||||
// DeInitialization ...
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
//
|
||||
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
|
||||
// REASON_REMOVE 1 Program removed from a chart
|
||||
// REASON_RECOMPILE 2 Program recompiled
|
||||
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
|
||||
// REASON_CHARTCLOSE 4 Chart closed
|
||||
// REASON_PARAMETERS 5 Inputs changed by a user
|
||||
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
|
||||
// REASON_TEMPLATE 7 Another chart template applied
|
||||
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
|
||||
// REASON_CLOSE 9 Terminal closed
|
||||
|
||||
//
|
||||
mMid.DeInit(reason);
|
||||
delete mMid;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculating what we want ...
|
||||
int OnCalculate(
|
||||
const int rates_total, // Total Bars on Chart ...
|
||||
const int prev_calculated, // Total Calculated Bars on Charts ...
|
||||
const datetime &time[], // History of Open Time ...
|
||||
const double &open[], // History of Open Price ...
|
||||
const double &high[], // History of High Price ...
|
||||
const double &low[], // History of Low Price ...
|
||||
const double &close[], // History of Close Price ...
|
||||
const long &tick_volume[], // History of Tick Volumes on Bar ...
|
||||
const long &volume[], // History of Trade Volumes ...
|
||||
const int &spread[] // History of Spread Price ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// this counts Available Bars ...
|
||||
int limit;
|
||||
|
||||
//
|
||||
// because in some cases we may have more than one input for
|
||||
// calculation and we must prevent any calculation
|
||||
// untill we pass the biggest input length, here we get max Input length
|
||||
// and then wait until pass it ...
|
||||
int maxLength = mMid.GetInputs().Max();
|
||||
|
||||
//
|
||||
int midCalculatedBars = mMid.GetCalculatedBars();
|
||||
if (midCalculatedBars < 0)
|
||||
{
|
||||
return prev_calculated;
|
||||
}
|
||||
|
||||
//
|
||||
limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1;
|
||||
|
||||
//
|
||||
int midMainCopiedItems = mMid.CopyBufferValue(
|
||||
GetTitle(XSCMID_MAIN_LINE),
|
||||
mainBuffer,
|
||||
0,
|
||||
limit //
|
||||
);
|
||||
if (midMainCopiedItems <= 0)
|
||||
{
|
||||
return prev_calculated;
|
||||
}
|
||||
|
||||
//
|
||||
// Main Loop ...
|
||||
for (int i = limit - 1; i >= 0 && !IsStopped(); i--)
|
||||
{
|
||||
CalculateBuffers(i);
|
||||
}
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
|
||||
//
|
||||
// CUSTOM Functions ...
|
||||
|
||||
//
|
||||
// Validate Input Args for Initialization ...
|
||||
bool InitIndicatorClass()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Initialize and Prepare
|
||||
// Inputs of Indicator ...
|
||||
XSCMidInputs inputs;
|
||||
result = inputs.Init();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Instantiate Class ...
|
||||
mMid = new XSCMid(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
|
||||
//
|
||||
// Now Initialize Indicator Class using Given Inputs ...
|
||||
result = mMid.Init(
|
||||
inputs //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
// Start Styling and Indexing Buffers ...
|
||||
|
||||
//
|
||||
string bufferLabel = GetTitle(XSCMID_MAIN_LINE);
|
||||
int mainIDX = mMid.GetBufferIndexByLine(XSCMID_MAIN_LINE);
|
||||
XBuffer mainBufferStruct;
|
||||
mMid.GetBufferByLine(
|
||||
XSCMID_MAIN_LINE,
|
||||
mainBufferStruct //
|
||||
);
|
||||
|
||||
//
|
||||
int bufferIndex = 0;
|
||||
|
||||
//
|
||||
int max = mMid.GetInputs().Max();
|
||||
|
||||
//
|
||||
ArraySetAsSeries(mainBuffer, true);
|
||||
|
||||
//
|
||||
XBufferPlotStyle mainBufferStyle;
|
||||
mainBufferStyle.clr = clrAqua;
|
||||
mainBufferStyle.type = DRAW_LINE;
|
||||
mainBufferStyle.width = 3;
|
||||
|
||||
//
|
||||
SetIndexBuffer(
|
||||
bufferIndex,
|
||||
mainBuffer,
|
||||
mainBufferStyle,
|
||||
mainColorBuffer,
|
||||
bufferLabel,
|
||||
true,
|
||||
EMPTY_VALUE //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Set Indicator Short Name and also we can define Buffers Labels ...
|
||||
void SetIndicatorName()
|
||||
{
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
||||
}
|
||||
|
||||
//
|
||||
void CalculateBuffers(int barIndex)
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user