Re: Coding Help

84

Code: Select all

//+------------------------------------------------------------------+
//| Exp_IBS_RSI_CCI_v4.mq5 |
//| Copyright © 2017, Nikolay Kositsin |
//| Khabarovsk, farria@mail.redcom.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2017, Nikolay Kositsin"
#property link "farria@mail.redcom.ru"
#property version "1.00"
#resource "\\Indicators\\IBS_RSI_CCI_v4.ex5"
//+----------------------------------------------+
// ???????? ????????? |
//+----------------------------------------------+
#include <TradeAlgorithms.mqh>
//+----------------------------------------------+
//| ???????????? ??? ????????? ??????? ???? |
//+----------------------------------------------+
/*enum MarginMode - ???????????? ????????? ? ????? TradeAlgorithms.mqh
{
FREEMARGIN=0, //MM ?? ????????? ??????? ?? ?????
BALANCE, //MM ?? ??????? ??????? ?? ?????
LOSSFREEMARGIN, //MM ?? ??????? ?? ????????? ??????? ?? ?????
LOSSBALANCE, //MM ?? ??????? ?? ??????? ??????? ?? ?????
LOT //??? ??? ?????????
}; */
//+----------------------------------------------+
//| ??????? ????????? ?????????? ???????? |
//+----------------------------------------------+
input double MM=0.1; //???? ?????????? ???????? ?? ???????? ? ??????
input MarginMode MMMode=LOT; //?????? ??????????? ??????? ????
input int StopLoss_=1000; //???????? ? ???????
input int TakeProfit_=2000; //?????????? ? ???????
input int Deviation_=10; //????. ?????????? ???? ? ???????
input bool BuyPosOpen=true; //?????????? ??? ????? ? ????
input bool SellPosOpen=true; //?????????? ??? ????? ? ????
input bool BuyPosClose=true; //?????????? ??? ?????? ?? ??????
input bool SellPosClose=true; //?????????? ??? ?????? ?? ??????
//+----------------------------------------------+
//| ??????? ????????? ?????????? |
//+----------------------------------------------+
input ENUM_TIMEFRAMES InpInd_Timeframe=PERIOD_CURRENT; //????????? ??????????
//----
//---- ????????? ??????? ?????
input uint IBSPeriod=5;
input ENUM_MA_METHOD MAType=MODE_SMA;
//---- ????????? RSI
input uint RSIPeriod=14;
input ENUM_APPLIED_PRICE RSIPrice=PRICE_CLOSE;
//---- ????????? CCI
input uint CCIPeriod=14;
input ENUM_APPLIED_PRICE CCIPrice=PRICE_MEDIAN;
input int porog=50; //?????
//---- ???????? ??????? ????? VKWB
input ENUM_MA_METHOD MAType_VKWB=MODE_SMA;
input int RangePeriod_VKWB = 25;
input int SmoothPeriod_VKWB = 3;
//----
input uint SignalBar=1;//????? ???? ??? ????????? ??????? ?????
//+----------------------------------------------+
//---- ?????????? ????? ?????????? ??? ???????? ??????? ??????? ? ????????
int TimeShiftSec;
//---- ?????????? ????? ?????????? ??? ??????? ???????????
int InpInd_Handle;
//---- ?????????? ????? ?????????? ?????? ??????? ??????
int min_rates_total;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---- ????????? ?????? ?????????? IBS_RSI_CCI_v4
InpInd_Handle=iCustom(Symbol(),InpInd_Timeframe,"::Indicators\\IBS_RSI_CCI_v4",IBSPeriod,MAType,RSIPeriod,RSIPrice,CCIPeriod,CCIPrice,porog,MAType_VKWB,RangePeriod_VKWB,SmoothPeriod_VKWB);
if(InpInd_Handle==INVALID_HANDLE)
{
Print(" ?? ??????? ???????? ????? ?????????? IBS_RSI_CCI_v4");
return(INIT_FAILED);
}
//---- ????????????? ?????????? ??? ???????? ??????? ??????? ? ????????
TimeShiftSec=PeriodSeconds(InpInd_Timeframe);
//---- ????????????? ?????????? ?????? ??????? ??????
min_rates_total=int(MathMax(CCIPeriod,RSIPeriod)+IBSPeriod+RangePeriod_VKWB);
min_rates_total+=int(SmoothPeriod_VKWB+RangePeriod_VKWB);
min_rates_total+=int(3+SignalBar);
//----
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//----
GlobalVariableDel_(Symbol());
//----
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---- ???????? ?????????? ????? ?? ????????????? ??? ???????
if(BarsCalculated(InpInd_Handle)<min_rates_total) return;
//---- ????????? ??????? ??? ?????????? ?????? ??????? IsNewBar() ? SeriesInfoInteger()
LoadHistory(TimeCurrent()-PeriodSeconds(InpInd_Timeframe)-1,Symbol(),InpInd_Timeframe);
//---- ?????????? ????????? ??????????
double Up[2],Dn[2];
//---- ?????????? ??????????? ??????????
static bool Recount=true;
static bool BUY_Open=false,BUY_Close=false;
static bool SELL_Open=false,SELL_Close=false;
static datetime UpSignalTime,DnSignalTime;
static CIsNewBar NB;
//+----------------------------------------------+
//| ??????????? ???????? ??? ?????? |
//+----------------------------------------------+
if(!SignalBar || NB.IsNewBar(Symbol(),InpInd_Timeframe) || Recount) // ???????? ?? ????????? ?????? ????
{
//---- ??????? ???????? ???????
BUY_Open=false;
SELL_Open=false;
BUY_Close=false;
SELL_Close=false;
Recount=false;
//---- ???????? ????? ??????????? ?????? ? ???????
if(CopyBuffer(InpInd_Handle,0,SignalBar,2,Up)<=0) {Recount=true; return;}
if(CopyBuffer(InpInd_Handle,1,SignalBar,2,Dn)<=0) {Recount=true; return;}
//---- ??????? ??????? ??? ???????
if(Up[1]>Dn[1])
{
if(BuyPosOpen && Up[0]<=Dn[0]) BUY_Open=true;
if(SellPosClose) SELL_Close=true;
UpSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
}
//---- ??????? ??????? ??? ???????
if(Up[1]<Dn[1])
{
if(SellPosOpen && Up[0]>=Dn[0]) SELL_Open=true;
if(BuyPosClose) BUY_Close=true;
DnSignalTime=datetime(SeriesInfoInteger(Symbol(),InpInd_Timeframe,SERIES_LASTBAR_DATE))+TimeShiftSec;
}
}
//+----------------------------------------------+
//| ?????????? ?????? |
//+----------------------------------------------+
//---- ????????? ????
BuyPositionClose(BUY_Close,Symbol(),Deviation_);
//---- ????????? ????
SellPositionClose(SELL_Close,Symbol(),Deviation_);
//---- ????????? ????
BuyPositionOpen(BUY_Open,Symbol(),UpSignalTime,MM,MMMode,Deviation_,StopLoss_,TakeProfit_);
//---- ????????? ????
SellPositionOpen(SELL_Open,Symbol(),DnSignalTime,MM,MMMode,Deviation_,StopLoss_,TakeProfit_);
//----
}
//+------------------------------------------------------------------+
This one is ea formula too.

Re: Coding Help

85
How to remove the indicator name and buffer labels for a compiled indicator
in the separate window without a new indicator with the iCustom function?  
I saw an indicator which made those fields empty some time ago, but can't find it now.


Re: Coding Help

86
wojtek wrote:How to remove the indicator name and buffer labels for a compiled indicator
in the separate window without a new indicator with the iCustom function?  
I saw an indicator which made those fields empty some time ago, but can't find it now.
wojtek

You can patch some objects there but that does not solve the issue of that data being displayed

Re: Coding Help

88
Hey mladen, could you maybe help me sorting this out ? I am trying to use the value of trend direction& force but somehow there seems to be an issue.Nothing happens, how to test if it gets the value? What am I doing wrong?I use this iCustom (to check value of it on beginning of new candle): 

Code: Select all

double td = iCustom(NULL,PERIOD_CURRENT,"Trend direction & force index nmc",10,0,1);
bool tdcall = td <= -0.8;
bool tdput = td >= 0.8;

Re: Coding Help

89
wojtek wrote:OK, thank you.  I used an obvious solution - an additional indicator with the iCustom function
for each visible buffer.   I'm lazy, so I wanted to avoid listing all the external parameters. 
Hi wojtek,do you want hide some thing (parameters) as been secrets and mysteries :roll:
Indicator is just a tool.

Use it only if it can benefit you. Leave it if you don't know how to use it optimally.

Re: Coding Help

90
gelsas wrote:Hey mladen, could you maybe help me sorting this out ? I am trying to use the value of trend direction& force but somehow there seems to be an issue.Nothing happens, how to test if it gets the value? What am I doing wrong?I use this iCustom (to check value of it on beginning of new candle): 

Code: Select all

 double td = iCustom(NULL,PERIOD_CURRENT,"Trend direction & force index nmc",10,0,1); bool tdcall = td <= -0.8; bool tdput = td >= 0.8; 
Use buffer 2 not buffer 0 for that


Who is online

Users browsing this forum: No registered users and 10 guests