Coding help - page 490

 
tfi_markets:
Implement; NonLag_Schaff_TrendCycle indicator:

Hi Pro-Coders,

I wonder someone could help me in implementing the NonLag_Schaff_TrendCycle indicator.

Indicator Externs:

extern int FastLength = 23;

extern int SlowLength = 50;

extern int StcPeriod = 10;

extern int MacdPrice = PRICE_CLOSE;

extern bool Interpolate = true;

extern bool MultiColor = true;

Indicator Buffers:

IndicatorBuffers(8);

SetIndexBuffer(0,stcBuffer);

SetIndexBuffer(1,stcBufferUA);

SetIndexBuffer(2,stcBufferUB);

SetIndexBuffer(3,macdBuffer);

SetIndexBuffer(4,fastKBuffer);

SetIndexBuffer(5,fastDBuffer);

SetIndexBuffer(6,fastKKBuffer);

SetIndexBuffer(7,trend);

I try to do something like:

double STC1_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,0,bar);

double STC2_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,0,bar+1);

if((STC1_c>15 && STC2_c85 && STC2_c BUY

if((STC1_c15)||(STC1_c85) -> SELL

But I get an error message:

Error: NonLag_Schaff_TrendCycle has been removed.

I guess I may read the buffers wrong. Does anyone have a suggestion?

Thank you in advance!

First parameter of nonlag schaf trend cycle is "TimeFrame". You are missing it in the iCustom call. The iCustom() call should be like this :

iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,0,bar);

 

Need Help

Hello mladen

thanks for your past helps

i have tried to make this indicator but it does not appears

so pls help me again

Thanks in advance

mtf_rsi_candle_all_in_one.mq4

 

Hi Mladen,

thank you very much for your help. Now it is working

With kind regards,

Thomas

mladen:
First parameter of nonlag schaf trend cycle is "TimeFrame". You are missing it in the iCustom call. The iCustom() call should be like this : iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,0,bar);
 

Hi, Mladen!

When new build long does the optimization.

If returning to build 670, the optimization speed is good.

What could be the problem?

experttsi.mq4

tsi.mq4

Files:
experttsi.mq4  2 kb
tsi.mq4  4 kb
 
QuantF:
Hi, Mladen!

When new build long does the optimization.

If returning to build 670, the optimization speed is good.

What could be the problem?

experttsi.mq4

tsi.mq4

Firs in TSI indicator delete the line that goes like this :

#property strict

With that line it will not work

______________

For the rest : we all should hope and pray. With each and every new build, backtesting is slower and slower and slower (see complaint of build 840). Not much to be done. It came to the point that visual back testin is faster than regular backtesting (build 788 is the one I am using) and there is no logic at all in it

 

Hi Pro Coders,

for some reason my EA is closing positions but not opening new ones, after the trend has changed. Could someone kindly have a look?

Thank you in advance!

//----------------------- LOAD INDICATORS FOR CLOSING POSITIONS

double STC0_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,MultiColor,0,bar+2);

double STC1_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,MultiColor,0,bar+1);

double STC2_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,MultiColor,0,bar);

// for(int i=0;i<OrdersTotal(); i++)

for(int i=OrdersTotal()-1;i>=0 ; i--)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;

if(OrderMagicNumber()!= MAGIC)continue;

if(OrderSymbol()!= s_symbol) continue;

//----------------------- CLOSE BUY CONDITION

if(STC1_c!=STC2_c) // Check trend

{

if(OrderType()==OP_BUY)

{

if(STC1_c>STC0_c&&STC2_c<STC1_c)

{

bool buyClose=OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_BID),Slippage*pipMultiplier,clCloseBuy);

if(buyClose==false)

{

int ErrorCode = GetLastError();

string ErrDesc = ErrorDescription(ErrorCode);

string ErrAlert= StringConcatenate("Close Buy Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts == true) Alert(ErrAlert);

string ErrLog=StringConcatenate("Bid: ",MarketInfo(s_symbol,MODE_BID)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

break;

} // mod

}

}

//----------------------- CLOSE SELL CONDITION

if(STC1_c!=STC2_c)

{

if(OrderType()==OP_SELL)

{

if(STC1_cSTC1_c)

{

bool sellClose= OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_ASK),Slippage*pipMultiplier,clCloseSell);

if(sellClose == false)

{

ErrorCode = GetLastError();

ErrDesc = ErrorDescription(ErrorCode);

ErrAlert=StringConcatenate("Close Sell Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts==true) Alert(ErrAlert);

ErrLog=StringConcatenate("Ask: ",MarketInfo(s_symbol,MODE_ASK)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

break;

} // mod

}

}

}

}

Files:
trendcycle.jpg  97 kb
 
tfi_markets:
Hi Pro Coders,

for some reason my EA is closing positions but not opening new ones, after the trend has changed. Could someone kindly have a look?

Thank you in advance!

//----------------------- LOAD INDICATORS FOR CLOSING POSITIONS

double STC0_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,MultiColor,0,bar+2);

double STC1_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,MultiColor,0,bar+1);

double STC2_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,MultiColor,0,bar);

// for(int i=0;i<OrdersTotal(); i++)

for(int i=OrdersTotal()-1;i>=0 ; i--)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;

if(OrderMagicNumber()!= MAGIC)continue;

if(OrderSymbol()!= s_symbol) continue;

//----------------------- CLOSE BUY CONDITION

if(STC1_c!=STC2_c) // Check trend

{

if(OrderType()==OP_BUY)

{

if(STC1_c>STC0_c&&STC2_c<STC1_c)

{

bool buyClose=OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_BID),Slippage*pipMultiplier,clCloseBuy);

if(buyClose==false)

{

int ErrorCode = GetLastError();

string ErrDesc = ErrorDescription(ErrorCode);

string ErrAlert= StringConcatenate("Close Buy Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts == true) Alert(ErrAlert);

string ErrLog=StringConcatenate("Bid: ",MarketInfo(s_symbol,MODE_BID)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

break;

} // mod

}

}

//----------------------- CLOSE SELL CONDITION

if(STC1_c!=STC2_c)

{

if(OrderType()==OP_SELL)

{

if(STC1_cSTC1_c)

{

bool sellClose= OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_ASK),Slippage*pipMultiplier,clCloseSell);

if(sellClose == false)

{

ErrorCode = GetLastError();

ErrDesc = ErrorDescription(ErrorCode);

ErrAlert=StringConcatenate("Close Sell Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts==true) Alert(ErrAlert);

ErrLog=StringConcatenate("Ask: ",MarketInfo(s_symbol,MODE_ASK)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

break;

} // mod

}

}

}

}

In that code there is no code that would open a position at all (OrderSend() function is not used in it at all)

 
mladen:
Firs in TSI indicator delete the line that goes like this :

#property strict

With that line it will not work

______________

For the rest : we all should hope and pray. With each and every new build, backtesting is slower and slower and slower (see complaint of build 840). Not much to be done. It came to the point that visual back testin is faster than regular backtesting (build 788 is the one I am using) and there is no logic at all in it

Thanks for the answer!

Clear. I stay in an old build.

 
mladen:
In that code there is no code that would open a position at all (OrderSend() function is not used in it at all)

Hi Mladen,

you are right, please find the code below which is calling "OpenSell()".

//+------------------------------------------------------------------+

//| OPEN BUY / OPEN SELL

//+------------------------------------------------------------------+

//----------------------- BUY CONDITION

for(i=OrdersTotal()-1;i>=0; i--)

if(OrderType()==OP_SELL) break;

{

if(STC1!=STC2)

{

/*if(STC1STC1)BUY="true";*/

if(STC1STC1)

/*if((STC115) || (STC185)) // code for buy */

OpenBuy();

return(0);

}

openedOrders++;

}

//----------------------- SELL CONDITION

// if(STC1>STC0&&STC2<STC1)SELL="true";

//if((STC1>15 && STC285 && STC2<85)) // code for sell

if(STC1>STC0&&STC2<STC1) // code for sell

{

OpenSell();

return(0);

}

}

//----------------------- OPEN SELL

void OpenSell()

{

double lsStop = 0; if(sStopLoss>0) lsStop = NormalizeDouble(MarketInfo(s_symbol,MODE_BID)+sStopLoss *pPoint*pipMultiplier,digit);

double lsTake = 0; if(sTakeProfit>0) lsTake = NormalizeDouble(MarketInfo(s_symbol,MODE_BID)-sTakeProfit*pPoint*pipMultiplier,digit);

if(AccountFreeMargin()<(100*Lots)) { Print("We have no money. Free Margin = ",AccountFreeMargin()); return; }

// ECN

if(!EcnBroker)

dummyResult=OrderSend(s_symbol,OP_SELL,LotsOptimized(),MarketInfo(s_symbol,MODE_BID),Slippage*pipMultiplier,lsStop,lsTake,ExpertName,MAGIC,0,clOpenSell);

else

{

int sellTicket = OrderSend(s_symbol,OP_SELL,LotsOptimized(),MarketInfo(s_symbol,MODE_BID),Slippage*pipMultiplier,0,0,ExpertName,MAGIC,0,clOpenSell);

if(sellTicket >= 0)

bool sellOrderMod=OrderModify(sellTicket,OrderOpenPrice(),lsStop,lsTake,0,CLR_NONE);

if(sellOrderMod==false)

{

int ErrorCode = GetLastError();

string ErrDesc = ErrorDescription(ErrorCode);

string ErrAlert=StringConcatenate("Modify Sell Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts==true) Alert(ErrAlert);

string ErrLog=StringConcatenate("Ask: ",MarketInfo(s_symbol,MODE_ASK)," Bid: ",MarketInfo(s_symbol,MODE_BID)," Ticket: ",sellTicket," Stop: ",lsStop," Profit: ",lsTake);

Print(ErrLog);

}

}

}

 

dear mladen, mrtools waiting to see your reply for my queries of fxultratrend indicator in above post.

hope you will not disappoint me.

thanks.

Reason: