- How to code?
- Help with icustom calling indicator into EA
- Please help me to close order of the ea once there is a certain profit
Why are you using & ?
Are these params correct for your custom indicator.
double dFastMA = iCustom(sSymbol,CurrentTimeFrame,sMAIndicatorName,0,iFastMAPeriod,0,0,1,1,0,0,0,0,0);
double dSlowMA = iCustom(sSymbol,CurrentTimeFrame,sMAIndicatorName,0,iSlowMAPeriod,0,0,1,1,0,0,0,0,0);
Are these params correct for your custom indicator.
double dFastMA = iCustom(sSymbol,CurrentTimeFrame,sMAIndicatorName,0,iFastMAPeriod,0,0,1,1,0,0,0,0,0);
double dSlowMA = iCustom(sSymbol,CurrentTimeFrame,sMAIndicatorName,0,iSlowMAPeriod,0,0,1,1,0,0,0,0,0);
jy has it - assuming params are as below, this is your problem - the tenth param is missing:
double dSlowMA = iCustom(sSymbol,CurrentTimeFrame,sMAIndicatorName,0,iSlowMAPeriod,0,0,1,1,0,0,0,0,0,0);
nonlagma_v711 takes following params:
- Price -- 0..6
- Length -- indicator's lookback history..
- Displace
- PctFilter
- Color -- 0 or 1
- ColorBarBack
- Deviation
- AlertMode
- WarningMode
- WarningTicks
and... you are happy with using index buffer #0?
just mentioning as assuming same, you have buffers 0,1,2 to play with... (Colors tab on inputs window shows 3bufrs available for polling)
Have think about below. It appears at quick glance that on first entry to (),
if(PreviousDirection==NODIRECTION) { PreviousDirection = CurrentDirection; return(NODIRECTION); } even tho you detect a cross on 1st entry to () it is ignored and above block entered. this would give a delay until next cross detected, at which time below block entered. iow, first call to () and it sees cross -> rets(nodir) cuz prevDir=NoDir on second+ () call it [eventually] sees second cross -> sets time, rets(up/dn) if(PreviousDirection!=CurrentDirection) { PreviousDirection = CurrentDirection; //Saves the open time of the bar the cross was detected in CrossTime = iTime(NULL,CurrentTimeFrame,0); return(CurrentDirection); } suggest, if happy with above observation, revisit your design flow... also, what is purpose of refreshing rates? as not see code following next line make refs to series data...: if(OrderSelect(iTicket, SELECT_BY_TICKET)) {RefreshRates();}
The version of NonLagMA I have has only 9 parameters, I don't have the 'WarningTicks' option available.
'and... you are happy with using index buffer #0?' - Could you elaborate what you mean please? I was using buffer #0 as in my version of NonLagMA, the absolute value whatever the MA is currently at is stored there, buffers #1,#2, store UpBuffer and DnBuffer respectively, if I made comparisons on them I would be comparing zero sometimes - at least that was my understanding of the situation anyway.
As to the purpose of RefreshRates - none really, in my previous EA I was getting a lot of 'wrong price' errors and so I stuck RefreshRates in anywhere I thought might help, its just remaining from that.
It was my intention to ignore the first 'cross' as the EA could be loaded onto the chart at any point I thought it would be better to wait for a fresh signal and enter there. Is there a better way of going about this?
I have NonLogMA_v6.1. I have attached it along with this message. Can you put pics comparing the lag of both the indicvators from your charts.
The problem of using the 0 candle is that there will be multiple conflicting conditions during the formation of the candle. If you are checking for MA crosses it
is better to check it at the open of the next bar/candle. I sometimes put a param saying 90% completion of the candle by the following method.
bool
candle_ready(double percentage_completion)
{
datetime open_time = Time[0];
datetime curr_time = TimeCurrent();
double delta = curr_time - open_time;
double total = Period() * 60;
if ( ( ( delta * 100 ) / total ) >= percentage_completion )
return(true);
return(false);
}
You can call this function as
if (candle_ready(90)) {
*******
Do your processing here.
}
I just notice NonLagMA_v711 is available in the forum at
'Using Information of an Custom Indicator'
This one has 9 params and 3 line indicators
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 Length = 15; //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 = 0; //Sound Alert switch (0-off,1-on)
extern int WarningMode = 0; //Sound Warning switch(0-off,1-on)
How many lines does you indicator have?
You many need to read different indicators depending on the condition. Otherwise the indicator value will be 0 in some cases.
double dFastMA = iCustom(sSymbol,CurrentTimeFrame,sMAIndicatorName,0,iFastMAPeriod,0,0,1,1,0,0,0,0,0);
double dSlowMA = iCustom(sSymbol,CurrentTimeFrame,sMAIndicatorName,0,iSlowMAPeriod,0,0,1,1,0,0,0,0,0);
Does your indicator have only one line?
The version of NonLagMA I have has only 9 parameters, I don't have the 'WarningTicks' option available.
understood
'and... you are happy with using index buffer #0?' - Could you elaborate what you mean please? I was using buffer #0 as in my version of NonLagMA, the absolute value whatever the MA is currently at is stored there, buffers #1,#2, store UpBuffer and DnBuffer respectively, if I made comparisons on them I would be comparing zero sometimes - at least that was my understanding of the situation anyway.
It can happen that buffer choice is not given due thought and I asked to ensure you were happy with what buffer using - nothing more
As to the purpose of RefreshRates - none really, in my previous EA I was getting a lot of 'wrong price' errors and so I stuck RefreshRates in anywhere I thought might help, its just remaining from that.
It was my intention to ignore the first 'cross' as the EA could be loaded onto the chart at any point I thought it would be better to wait for a fresh signal and enter there. Is there a better way of going about this?
guess the question is what is a good point? since a cross can happen at anytime. Do you employ some confirming filters? eg, can you guarantee that UP,DOWN mirrors price direction?
all thots - is your code/design...
I've attached a screenshot of what the EA does currently, once this order is opened (since it has been opened incorrectly I assume) it is not closed by the ea and no more order's can be placed due to the only one order restriction within EntrySignal(), The tester later says the order was 'closed at stop', which is also confusing since no stop is placed...
I was not going to employ any sort of confirmation for the moment, what I had envisioned was an order being placed on the first cross, and then subsequent crosses back and forth during this candle period are ignored and the order left to stand.
'Does your indicator have only one line?' - Yes only one line is drawn. When the line is increasing/decreasing the current value is stored in Buffer1/2 respectively. Buffer0 holds the value regardless of the current direction and it is this I wanted to be reading.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use