You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
#include <Expert\Signal\SignalMA.mqh>
CSignalMA SignalMA;
int TickCount;
string Str;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
TickCount=0;
SignalMA.Symbol(Symbol());
SignalMA.Period(PERIOD_H1);
SignalMA.Weight(0.5);
SignalMA.PeriodMA(20);
SignalMA.Shift(0);
SignalMA.Method(MODE_SMA);
SignalMA.Applied(PRICE_CLOSE);
return(0);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
TickCount++;
Str = "LongCondition = " + IntegerToString(SignalMA.LongCondition())+"; "+IntegerToString(TickCount)+ "\n";
Str = Str + "ShortCondition = " + IntegerToString(SignalMA.ShortCondition())+"; "+IntegerToString(TickCount);
Comment(Str);
}
//+------------------------------------------------------------------+
2011.11.29 15:36:27 1234 (EURUSD,M1) CExpertBase::Period: changing of timeframe is forbidden
2011.11.29 15:36:27 1234 (EURUSD,M1) CExpertBase::Symbol: changing of symbol is forbidden
Can I use trading signal modules separately from Wizard EAs? For testing purposes, I wrote
#include <Expert\Signal\SignalMA.mqh>
CSignalMA SignalMA;
int TickCount;
string Str;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
TickCount=0;
SignalMA.Symbol(Symbol());
SignalMA.Period(PERIOD_H1);
SignalMA.Weight(0.5);
SignalMA.PeriodMA(20);
SignalMA.Shift(0);
SignalMA.Method(MODE_SMA);
SignalMA.Applied(PRICE_CLOSE);
return(0);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
TickCount++;
Str = "LongCondition = " + IntegerToString(SignalMA.LongCondition())+"; "+IntegerToString(TickCount)+ "\n";
Str = Str + "ShortCondition = " + IntegerToString(SignalMA.ShortCondition())+"; "+IntegerToString(TickCount);
Comment(Str);
}
//+------------------------------------------------------------------+
2011.11.29 15:36:27 1234 (EURUSD,M1) CExpertBase::Period: changing of timeframe is forbidden
2011.11.29 15:36:27 1234 (EURUSD,M1) CExpertBase::Symbol: changing of symbol is forbidden
The following code:
Calls the constructor for label each time the function is called.
With the following code: in the first case the indicator is set, in the second case it is not (switched with slashes).
The second option in this library outputs 0. All other functions seem to work.
For the next code: in the first case indicator is set, in the second case it is not (switched with slashes).
As far as I understand, at the moment all three parameters are mandatory.
Therefore, you must specify the window number (variants: 0 - main window, ChartIndicatorsTotal() - new window, 0 toChartIndicatorsTotal()-1 - an existing window).
That's what does not give out errors is not good.
For this library for the second option outputs 0. All other functions seem to work.
Most likely before getting the price you should use refreshes (at least RefreshRates).
The right variant should look like this
Thank you. It did work with Bid, after specifying refresh.
But the indicator output, using the library, requires 2 parameters, a subwindow and a handle. Otherwise it says the number of parameters is wrong. I can't figure it out, because the library uses the same ChartIndicatorAdd, so it works directly, but calling through the library does not.
Thank you. It did work with Bid, after specifying refresh.
But the indicator output, using the library, requires 2 parameters, a subwindow and a handle. Otherwise it says the number of parameters is wrong. I can't figure it out, because the library uses the same ChartIndicatorAdd, so it works directly, but calling through the library does not.
Using the library requires 2 parameters. Chart and subwindow.
Without a Handle? And how will the system know what turntable to use? ..So far I've trusted what's written :) The substrate and the handle.
Without a handle? How will the system know which indicator to use? I have trusted the texts so far :) Subwindow and handle.
About the library (from class help)
IndicatorAdd
Adds an indicator with the specified handle to the specified chart window.
Regarding the ChartIndicatorAdd direct work.
ChartIndicatorAdd
Adds an indicator with the specified handle to the specified chart window.
As for the CChart class.
In order to avoid unnecessary questions, we try to follow three basic rules:
1. We look at the source code, if something is not clear refer to the documentation (the source code will always tell the "truth", but the documentation can also lie);
2. If OOP implementation is important to us, we start with a description of a particular class and go as far as "direct implementers". If "real work" is important, OOP should be studied last (downward/upward examination of code);
3. if after reading the documentation and sources something is not clear, we go to the forum.
Directly on the implementation of the IndicatorAdd method in a class
If you look at source code it becomes clear that method gets subwindow and handle (as noted in help), and the third parameter is taken from data stored in the class itself (I mean the graph ID).