HELP FOR CODE EA

 
hi i am a beginner of MQL4 code, help .... code of OP_BUY for CCI cross a value (not when it is greater).
example, bar [1] CCI = 57 at the closing of bar [0] reaches the value CCI = 68, so the ea must open the position size.
In the usual logic, how can I take past values from an indicator?
example I want to check that the value of the previous CCI is greater or lower than the current value CCIs.
Thank you
 

I had write in the forum of MQL4 how you want....

how could i have a simple answer? 

 
alessioboga:

I had write in the forum of MQL4 how you want....

how could i have a simple answer? 

Press F1 in the editor search for iCustom or iCCI and start reading - it is that easy!
 
alessioboga:
hi i am a beginner of MQL4 code, help .... code of OP_BUY for CCI cross a value (not when it is greater).
example, bar [1] CCI = 57 at the closing of bar [0] reaches the value CCI = 68, so the ea must open the position size.
In the usual logic, how can I take past values from an indicator?
example I want to check that the value of the previous CCI is greater or lower than the current value CCIs.
Thank you

double lastCCI=iCCI(Symbol(),PERIOD_CURRENT,14,PRICE_TYPICAL,1)  // note the last parameter. Shift=1

double currentCCI= iCCI(Symbol(),PERIOD_CURRENT,14,PRICE_TYPICAL,0)  // note the last parameter. Shift=0


if (lastCCI<currentCCI && currentCCI>xxx) ...


regards.

 
FXreedom:

double lastCCI=iCCI(Symbol(),PERIOD_CURRENT,14,PRICE_TYPICAL,1)  // note the last parameter. Shift=1

double currentCCI= iCCI(Symbol(),PERIOD_CURRENT,14,PRICE_TYPICAL,0)  // note the last parameter. Shift=0


if (lastCCI<currentCCI && currentCCI>xxx) ...


regards.

thanks, I write this....

if (CCIPassato < CCIPresente && CCIPresente > 60 && alternatibuy() == false) {
      OrderSend(Symbol(),OP_BUY,Lotti,Open[0],0,Low[1],OrderOpenPrice()+(OrderOpenPrice()-Low[1]),"Volatilità BUY",MagicNumber,0,Blue);

But the ea not to Buy and not to Sell

thanks to the availability

 
alessioboga:

thanks, I write this....

if (CCIPassato < CCIPresente && CCIPresente > 60 && alternatibuy() == false) {
      OrderSend(Symbol(),OP_BUY,Lotti,Open[0],0,Low[1],OrderOpenPrice()+(OrderOpenPrice()-Low[1]),"Volatilità BUY",MagicNumber,0,Blue);

But the ea not to Buy and not to Sell

thanks to the availability


Price parameter must be ask for BUY and bid for Sell (not Open[0] ) . You can use:

MqlTick  last_tick; 

SymbolInfoTick(Symbol(),last_tick); // then price for BUY must be NormalizeDouble(last_tick.ask,Digits).   Price for SELL must be NormalizeDouble(last_tick.bid,Digits)


Slippagge is too low, try 2 or 3


For stoploss and tp values use also: NormalizeDouble(xxxx,Digits)


I am not sure if your SL and TP are corrects. Anyway you must check them agains the STOPLEVEL value


Check the journal log to see any error message. It may helps...


good luck.