the problem is how to add indicator code into ea ??
You can, with certain limitations, but using iCustom is a whole lot easier.
But if you really want to: Transferring an Indicator Code into an Expert Advisor Code. Indicator Structure - MQL4 Articles
For Stochastic it is not needed iCustom
Parameters:
Sample: if(iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,0)>iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0)) return(0); |
how about adding rvi indicator into ea ?
also using the same code as the way adding stochastic ?
how about adding rvi indicator into ea ?
also using the same code as the way adding stochastic ?
iCustom() or iRVI()
how about adding rvi indicator into ea ?
also using the same code as the way adding stochastic ?
here the code i did this morning.
anyone can help me to fix it ??
//+------------------------------------------------------------------+
int init()
{
//---- indicator buffers mapping
SetIndexBuffer(0,Buffer);
SetIndexBuffer(1,SignalBuffer);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
//---- drawing settings
SetIndexDrawBegin(0,RVIPeriod+3);
SetIndexDrawBegin(1,RVIPeriod+7);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("RVI("+RVIPeriod+")");
SetIndexLabel(0,"RVI");
SetIndexLabel(1,"RVIS");
//---- initialization done
return(0);
}
{
double bid =MarketInfo(Symbol(),MODE_BID); // Request for the value of Bid
double ask =MarketInfo(Symbol(),MODE_ASK); // Request for the value of Ask
double point =MarketInfo(Symbol(),MODE_POINT);//Request for Point
return; // Exit start()
if(AccountFreeMargin()<100)
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
int start()
{
{
int i,j,nLimit,nCountedBars;
double dValueUp,dValueDown,dNum,dDeNum;
//----
if(Bars<=RVIPeriod+8) return(0);
//----
nCountedBars=IndicatorCounted();
//---- check for possible errors
if(nCountedBars<0) return(-1);
//---- last counted bar will be recounted
nLimit=Bars-RVIPeriod-4;
if(nCountedBars>RVIPeriod+4)
nLimit=Bars-nCountedBars;
//---- RVI counted in the 1-st buffer
for(i=0; i<=nLimit; i++)
{
dNum=0.0;
dDeNum=0.0;
for(j=i; j<i+RVIPeriod; j++)
{
dValueUp=((Close[j]-Open[j])+2*(Close[j+1]-Open[j+1])+2*(Close[j+2]-Open[j+2])+(Close[j+3]-Open[j+3]))/6;
dValueDown=((High[j]-Low[j])+2*(High[j+1]-Low[j+1])+2*(High[j+2]-Low[j+2])+(High[j+3]-Low[j+3]))/6;
dNum+=dValueUp;
dDeNum+=dValueDown;
}
if(dDeNum!=0.0)
Buffer[i]=dNum/dDeNum;
else
Buffer[i]=dNum;
}
//---- signal line counted in the 2-nd buffer
nLimit=Bars-RVIPeriod-7;
if(nCountedBars>RVIPeriod+8)
nLimit=Bars-nCountedBars+1;
for(i=0; i<=nLimit; i++)
SignalBuffer[i]=(Buffer[i]+2*Buffer[i+1]+2*Buffer[i+2]+Buffer[i+3])/6;
//----
return(0);
}
{
OrderSend(Symbol,LotSize,Ask,StopLoss,TakeProfit,0,0);
if (Close<i)
OpenBuy();
return(0);
OrderSend(Symbol,LotSize,Bid,StopLoss,TakeProfit,0,0);
if (Close>i)
OpenSell();
return(0);
}
double GetSizeLot() { return(LotSize); }
double GetTakeProfitBuy() { return(Ask+TakeProfit*Point); }
double GetTakeProfitSell() { return(Bid-TakeProfit*Point); }
double GetStopLossBuy() { return(Bid-StopLoss*Point); }
double GetStopLossSell() { return(Ask+StopLoss*Point); }
string GetCommentForOrder() { return();}
return(0); }
Before posting please read some of the other threads . . . then you would have seen numerous requests like this one:
Please use this to post code . . . it makes it easier to read.
here the code i did this morning.
anyone can help me to fix it ??
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
as i mentioned above, i wish to make ea with stochastic coding.
the problem is how to add indicator code into ea ??