RC Stochastic
RC Stochastic
RC Stochastic
//| RC-Stochastic.mq5 |
//| Antonio Guglielmi |
//| RobotCrowd - Crowdsourcing para trading automatizado |
//| https://www.robotcrowd.com.br |
//| |
//+------------------------------------------------------------------+
// Copyright 2017 Antonio Guglielmi - RobotCrowd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "include/RCCommon.mqh"
#include "TradeWatch.mqh"
#include "TradeFilter.mqh"
enum StoTradeModeType {
STO_MODE_POP, // Estocastico Pop
STO_MODE_OB_OS, // Sobrecompra/Sobrevenda
STO_MODE_BOTH // Ambos
};
enum StoExitSignalType {
STO_EXIT_CROSS, // Cruzamento principal/sinal
STO_EXIT_PERCENT, // Superacao percentual SC/SV
STO_EXIT_PARTIAL, // 50% cruzando 50% percentual
STO_EXIT_NONE // Nenhum - usa o stop movel
};
bool runOnce;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
ArraySetAsSeries(mrate,true);
ArraySetAsSeries(stoMainVal,true);
ArraySetAsSeries(stoSignalVal,true);
// Inicializa a biblioteca de gerenciamento de trades
int r = initTradeWatch();
tradew.checkSetFile(inEAName);
// Inicializa a biblioteca de filtros
initTradeFilter();
if (!filter.checkFilterHandles()) {
Print("Erro na inicializacao de filtros!!");
}
runOnce = false;
return(r);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
IndicatorRelease(stoHandle);
deinitTradeWatch();
deinitTradeFilter();
void OnTimer() {
tradew.processTimer();
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick() {
#ifndef RC_SKIP_WFO
if (inWFOEnable) {
int wfo = wfo_OnTick();
if(wfo == -1) {
// Janela de negociacao ainda nao iniciada
return;
}
else if(wfo == +1) {
// Janela de negociacao ja finalizada
return;
}
}
#endif
tradew.checkPosition();
if (tradew.checkTradeTime()) {
runOnce = true;
if (inStoTradeMode != STO_MODE_OB_OS) {
// Modo de operacao POP
if (inStoTradeMode != STO_MODE_POP) {
// Modo de operacao Sobrecompra/Sobrevenda
return;
}