i downloaded the indicator attached in the mql4 website. I try to do an EA based on this indicator but when i start the backtest after some seconds the platforms crash and i think it is a fault of the indicator because it is use a lot of cpu.
So i'm asking if it possible to lighten the code to solve this problem.
I tested it with this snippet, and it works OK. I don't know the parameters you used so this is just calling a default indicator, but there is no problem this way
int init()
{
return(0);
}
int start()
{
Comment(iCustom(NULL,0,"Cronex Taichi",0,0));
return(0);
}
dasio: Hi,
i downloaded the indicator attached in the mql4 website. I try to do an EA based on this indicator but when i start the backtest after some seconds the platforms crash and i think it is a fault of the indicator because it is use a lot of cpu.
So i'm asking if it possible to lighten the code to solve this problem.
I tested it with this snippet, and it works OK. I don't know the parameters you used so this is just calling a default indicator, but there is no problem this way
int init()
{
return(0);
}
int start()
{
Comment(iCustom(NULL,0,"Cronex Taichi",0,0));
return(0);
}
Thank you, for your reply,
what i see is that in the history the indicator was loaded repeatedly so i move the code of icustom only in a new candle event but the problem still persists.
I have a problem with a function that have to result me the profit of all openorder but i think it's not work because the condition never been respected. Below the code:
I have a problem with a function that have to result me the profit of all openorder but i think it's not work because the condition never been respected. Below the code:
In this way i check the order that are not opened with specified magicnumber right? I need to check the order with specific symbol and magic number. I don't know if it is important but i found the error in strategy tester
...
You have to do 2 things :After that you will get something like this :
Have a nice weekend
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_maximum 100
#property indicator_level1 70
#property indicator_level2 50
#property indicator_level3 30
#property indicator_minimum 0
//---- input parameters
extern int rsiperiod = 14 ;
extern int Shortperiod = 5 ;
extern int Middleperiod = 8;
extern int Longperiod = 13;
extern int mamode = 2 ;
//---- buffers
double RSI[];
double ShortRSI[];
double MiddleRSI[];
double LongRSI[];
double SMRSI[];
int period ;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(5);
SetIndexBuffer(0,SMRSI);
SetIndexBuffer(1,RSI);
SetIndexBuffer(2,ShortRSI);
SetIndexBuffer(3,MiddleRSI);
SetIndexBuffer(4,LongRSI);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("SMRSI("+rsiperiod+","+Shortperiod+","+Middleperiod+","+Longperiod +","+mamode+")");
SetIndexDrawBegin(0,rsiperiod+Longperiod);
period=Shortperiod+Middleperiod+Longperiod;
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i,limit;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit = Bars-counted_bars;
for( i=limit; i>=0; i--) RSI=iRSI(NULL,0,rsiperiod,0,i);
for( i=limit; i>=0; i--) ShortRSI=iMAOnArray(RSI,0,Shortperiod,0,mamode,i);
for( i=limit; i>=0; i--) MiddleRSI=iMAOnArray(RSI,0,Middleperiod,0,mamode,i);
for( i=limit; i>=0; i--) LongRSI=iMAOnArray(RSI,0,Longperiod,0,mamode,i);
for( i=limit; i>=0; i--) { if(period!=0) SMRSI=(Shortperiod/period)*ShortRSI+(Middleperiod/period)*MiddleRSI+(Longperiod/period)*LongRSI;}
return(0);
}
//+------------------------------------------------------------------+n_n
You have to do 2 things :
After that you will get something like this :
Have a nice weekendThank you !
Hi,
i downloaded the indicator attached in the mql4 website. I try to do an EA based on this indicator but when i start the backtest after some seconds the platforms crash and i think it is a fault of the indicator because it is use a lot of cpu.
So i'm asking if it possible to lighten the code to solve this problem.
Thank yo for your disponibility.
cronex_taichi.mq4
dasio
I tested it with this snippet, and it works OK. I don't know the parameters you used so this is just calling a default indicator, but there is no problem this way
{
return(0);
}
int start()
{
Comment(iCustom(NULL,0,"Cronex Taichi",0,0));
return(0);
}
Hi,
i downloaded the indicator attached in the mql4 website. I try to do an EA based on this indicator but when i start the backtest after some seconds the platforms crash and i think it is a fault of the indicator because it is use a lot of cpu.
So i'm asking if it possible to lighten the code to solve this problem.
Thank yo for your disponibility.
cronex_taichi.mq4dasio
I tested it with this snippet, and it works OK. I don't know the parameters you used so this is just calling a default indicator, but there is no problem this way
{
return(0);
}
int start()
{
Comment(iCustom(NULL,0,"Cronex Taichi",0,0));
return(0);
}
Thank you, for your reply,
what i see is that in the history the indicator was loaded repeatedly so i move the code of icustom only in a new candle event but the problem still persists.
I don't know why.
However thank you for your disponibility.
Hi,
i found the problem. Now all its ok.
I have another problem with another ea.
I have this two code and the function Lotti() would be return me the number of lot for an ordersend.
When i compile it i receive Posizioni Internal Error. What's wrong? Thank you;
{
int intCount=0;
int intPOS=0;
bool boolTerm=false;
while(boolTerm==false)
{
if(OrderSelect(intPOS,SELECT_BY_POS))
{
if(OrderMagicNumber()==intMagic) intCount++;
intPOS++;
}
else
boolTerm=true;
}
return(intCount);
}
[/PHP]
[PHP]int Lotti(){
int Lotti;
int Posizioni=OTBM(MagicNumber);
switch (Posizioni)
{
case 0 : Lotti=0.1; break;
case 1 : Lotti=0.2; break;
case 2 : Lotti=0.4; break;
case 3 : Lotti=0.8; break;
case 4 : Lotti=1.6; break;
case 5 : Lotti=3.2; break;
case 6 : Lotti=6.4; break;
case 7 : Lotti=12.8; break;
}
return(Lotti);
}Try replacing OTBM() with this :
{
int intCount=0;
for (int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS))
{
if(OrderMagicNumber()==intMagic) intCount++;
}
}
return(intCount);
}
[/PHP]
Hi,
i found the problem. Now all its ok.
I have another problem with another ea.
I have this two code and the function Lotti() would be return me the number of lot for an ordersend.
When i compile it i receive Posizioni Internal Error. What's wrong? Thank you;
{
int intCount=0;
int intPOS=0;
bool boolTerm=false;
while(boolTerm==false)
{
if(OrderSelect(intPOS,SELECT_BY_POS))
{
if(OrderMagicNumber()==intMagic) intCount++;
intPOS++;
}
else
boolTerm=true;
}
return(intCount);
}
[PHP]int Lotti(){
int Lotti;
int Posizioni=OTBM(MagicNumber);
switch (Posizioni)
{
case 0 : Lotti=0.1; break;
case 1 : Lotti=0.2; break;
case 2 : Lotti=0.4; break;
case 3 : Lotti=0.8; break;
case 4 : Lotti=1.6; break;
case 5 : Lotti=3.2; break;
case 6 : Lotti=6.4; break;
case 7 : Lotti=12.8; break;
}
return(Lotti);
}Hi, -.-"
I do not find peace with these codes eheheh.
I have a problem with a function that have to result me the profit of all openorder but i think it's not work because the condition never been respected. Below the code:
if(Profit()>=0.....[/PHP]
[PHP]double Profit()
{
int total=OrdersTotal();
double profit=0;
for(int i=0; i<total; i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) continue;
profit+=OrderProfit();
}
return(profit);
}dasio
Try like this :
if(Profit()>=0.....[/PHP]
{
int total=OrdersTotal();
double profit=0;
for(int i=0; i<total-1; i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber) continue;
profit+=OrderProfit();
}
return(profit);
}[/PHP]
Hi, -.-"
I do not find peace with these codes eheheh.
I have a problem with a function that have to result me the profit of all openorder but i think it's not work because the condition never been respected. Below the code:
[PHP].....
if(Profit()>=0.....[PHP]double Profit()
{
int total=OrdersTotal();
double profit=0;
for(int i=0; i<total; i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) continue;
profit+=OrderProfit();
}
return(profit);
}dasio
Try like this :
if(Profit()>=0.....[/PHP]
[PHP]double Profit()
{
int total=OrdersTotal();
double profit=0;
for(int i=0; i<total-1; i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber) continue;
profit+=OrderProfit();
}
return(profit);
}In this way i check the order that are not opened with specified magicnumber right? I need to check the order with specific symbol and magic number. I don't know if it is important but i found the error in strategy tester