Coding help - page 709

 
tfi_markets:
Hi Pro-Coders,

I would like to use the NonLagMA_v7.7 Indicator as signal trigger or trade signal filter.
The indicator provides signals either 0 or 1084. 

For example:
// Up Signal
// NonLag Up = 1084
// NonLag Dn = 0

// Dn Signal
// NonLag Up = 0
// NonLag Dn = 1084

Could someone please have a look at my "pseudo" code? I guess it may work,
but it can be probably optimized for the better. Thank you in advnace!

extern string  NLMA_inputs      = "+--- NonLagMA Settings ---+";
extern int     Price            = 0;  //Apply to Price(0-Close;1-Open;2-High;3-Low;4-Median price;5-Typical price;6-Weighted Close)
extern int     MALength         = 9;  // Period of NonLagMA
extern int     Displace         = 0;  //DispLace or Shift
extern double  PctFilter        = 0;  //Dynamic filter in decimal
extern int     Color            = 1;  //Switch of Color mode (1-color)  
extern int     ColorBarBack     = 1;  //Bar back for color mode
extern double  Deviation        = 0;  //Up/down deviation        
extern int     AlertMode        = 1;  //Sound Alert switch (0-off,1-on)
extern int     WarningMode      = 0;  //Sound Warning switch(0-off,1-on)
extern int     WarningTicks     = 0;
extern bool    SendAlertEmail   = false;

extern double  BarShift                 = 1;

double nLagMA;
nLagMA=iCustom(Symbol(),0,"NonLagMA_v7.7", Price, Length, Displace, PctFilter, Color, ColorBarBack, Deviation, AlertMode, WarningMode, WarningTicks, SendAlertEmail);
  
double nLagMA1;
nLagMA1=iCustom(Symbol(),0,"NonLagMA_v7.7", Price, Length, Displace, PctFilter, Color, ColorBarBack, Deviation, AlertMode, WarningMode, WarningTicks, SendAlertEmail, BarShift);


// Signal Cross
   if (nLagMA == 0 && nLagMA1 > 1000) Order=SIGNAL_BUY;
   if (nLagMA1 == 0 && nLagMA > 1000) Order=SIGNAL_SELL;    

// Signal Filter
   if (nLagMA1 > 1000) Filter_BUY = True;    // Maybe used as SellExit Signal
   if (nLagMA == 0)    Filter_SELL = True;   // Maybe used as BuyExit Signal

 


Can you post the indicator itself so that it can be checked?
 

Hi Mladen,

please find the indicator attached to this posting.

Thank you in advance!

Files:
 
tfi_markets:

Hi Mladen,

please find the indicator attached to this posting.

Thank you in advance!

Best to use "trend" buffer for that

Something like this :

double trendNow   = iCustom(NULL,0,"NonLagMA_v7.7", Price, Length, Displace, PctFilter, Color, ColorBarBack, Deviation, AlertMode, WarningMode, WarningTicks, SendAlertEmail, 3, BarShift);
double trendPrev  = iCustom(NULL,0,"NonLagMA_v7.7", Price, Length, Displace, PctFilter, Color, ColorBarBack, Deviation, AlertMode, WarningMode, WarningTicks, SendAlertEmail, 3, BarShift+1);  
if (trendNow!=trendPrev)
{
   if (trendNow>0)
         Order=SIGNAL_BUY;
   else  Order=SIGNAL_SELL;
}
 
mladen:

Best to use "trend" buffer for that

Something like this :

double trendNow   = iCustom(NULL,0,"NonLagMA_v7.7", Price, Length, Displace, PctFilter, Color, ColorBarBack, Deviation, AlertMode, WarningMode, WarningTicks, SendAlertEmail, 3, BarShift);
double trendPrev  = iCustom(NULL,0,"NonLagMA_v7.7", Price, Length, Displace, PctFilter, Color, ColorBarBack, Deviation, AlertMode, WarningMode, WarningTicks, SendAlertEmail, 3, BarShift+1);  
if (trendNow!=trendPrev)
{
   if (trendNow>0)
         Order=SIGNAL_BUY;
   else  Order=SIGNAL_SELL;
}

Hi Mladen,

thank you very much for your advise!

Would it also work if I put in more paramaters from other indicators like this?

if (trendNow!=trendPrev)
{
  if(totalOrdersLong<MaxLongTrades  && trendNow>0 && (NLD1>NLD2) && RSIfilter>55) Order=SIGNAL_BUY;
  if(totalOrdersShort<MaxShortTrades && trendPrev>0 && (NLD1<NLD2) && RSIfilter<45) Order=SIGNAL_SELL;
}

 \Thomas 

 
tfi_markets:

Hi Mladen,

thank you very much for your advise!

Would it also work if I put in more paramaters from other indicators like this?

if (trendNow!=trendPrev)
{
  if(totalOrdersLong<MaxLongTrades  && trendNow>0 && (NLD1>NLD2) && RSIfilter>55) Order=SIGNAL_BUY;
  if(totalOrdersShort<MaxShortTrades && trendPrev>0 && (NLD1<NLD2) && RSIfilter<45) Order=SIGNAL_SELL;
}

 \Thomas 

Yes, you can add as much conditions as you wish.

But in the case of the code written that way, the "primary" condition is if nonlag ma have changed the trend and then all the rest of the conditions would be checked. If that is what you wanted, then you can pack in that code block as much conditions as you wish

 
mladen:

Yes, you can add as much conditions as you wish.

But in the case of the code written that way, the "primary" condition is if nonlag ma have changed the trend and then all the rest of the conditions would be checked. If that is what you wanted, then you can pack in that code block as much conditions as you wish

Cool thank you. Have a nice evening. 
 

hello mr mladen:

could you introduce or making a indicator to draw MTF vertical line on any histogram 

kind regard 

 

 
bilbao:

hello mr mladen:

could you introduce or making a indicator to draw MTF vertical line on any histogram 

kind regard 

 

You mean a simple vertical line drawn at certain time(s)?
 
mladen:
You mean a simple vertical line drawn at certain time(s)?

YES i need simple vertical line to draw on any histogram for determining candle on histogram

 

similar this picture but on separate chart or sub chart {can drag it on histogram} to show vertical line

 
bilbao:

YES i need simple vertical line to draw on any histogram for determining candle on histogram

 

similar this picture but on separate chart or sub chart {can drag it on histogram} to show vertical line

Here you go. Just drag it to the sub-window you wish it to be displayed at and chose the time frame


Files:
Reason: