i need help Renko

 

any one here can help me to code ea

i need code that mean

open sell order when bar open and last bar Close[1]<Open[1]

close sell order when bar close down "Bear"

and

open buy order when bar open and last bar Close[1]>Open[1]

close buy order when bar close up "Bull"


i can't code this,

when i use newbar open code :

bool NewCandel(){

if(Bars==b)return(false);

b=Bars;

return(true);

}
to open order, that's good

but when i called newbar function again and add condtions"Bear or Bull" to close ... no thing happen

.................................

this is my code .. can any one here help me

//////////////////////////////////////////////////////////////////// void OnTick() >> start

if(!ExistPositions() && LastProfit()>=0 && NewCandel()==true){

if(Close[1]<Open[1]){

open(OP_SELL,Lot,Bid,TakeProfit,StopLoss) ;

}

else

if(Close[1]>Open[1]){

open(OP_BUY,Lot,Ask,TakeProfit,StopLoss) ;

}

}

if(NewCandel()==true){///

if(MyOrders(OP_BUY)==1 && Close[1]>Open[1]){

CloseBuyOrders();

}

else

if(MyOrders(OP_SELL)==1 && Close[1]<Open[1]){

CloseSellOrders();

}

else

if(MyOrders(OP_SELL)==1 && Close[1]>Open[1]){

CloseSellOrders();

LastClosedTrade();

NewLots=LastOrderLots * Multi_Mode ;

open(OP_BUY,NewLots,Ask,TakeProfit,StopLoss) ;

}

else

if(MyOrders(OP_BUY)==1 && Close[1]<Open[1]){

CloseBuyOrders();

LastClosedTrade();

NewLots=LastOrderLots * Multi_Mode ;

open(OP_SELL,NewLots,Bid,TakeProfit,StopLoss) ;

}

///

}

////////////////////////////////////////////////void OnTick() >>> end 
 

Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.

 

thank you

sorry it's first time to post

but i need help please.

 
ExistPositions()
LastProfit()>=0

maybe ExistPosition()

or maybe LastProfit < 0

i cant see your code

B.T.W. on the first call NewCandel() can be false but on the second its gonna be always true

& it's not compiling anyway 'b' undeclared identifier

 
qjol:

maybe ExistPosition()

or maybe LastProfit < 0

i cant see your code

B.T.W. on the first call NewCandel() can be false but on the second its gonna be always true

& it's not compiling anyway 'b' undeclared identifier


double b =0;

but
my request in other way

how can i code next bar

i tried to put

Close[-1]

but do nothing

 

what about

bool NewBar ()
   {
   static datetime LastTime = 0;

   if (Time[0] != LastTime) 
      {
      LastTime = Time[0];     
      return (true);
      }
   else
      return (false);
   }
 
amerelhozn: how can i code next bar. i tried to put
Close[-1]

but do nothing

Why do you think you could possibly read the future?
 
qjol: B.T.W. on the first call NewCandel() can be false but on the second its gonna be always true
bool NewBar(){
   static datetime LastTime = 0;
   if (Time[0] != LastTime){
      LastTime = Time[0];     
      return (true);
   }
   return (false);
}
This is why I recommend not using a function (in this case.)
void OnTick(){
   static datetime time0=0; datetime timePre = time0; time0 = Time[0];
   bool isNewBar = time0 != timePre;
   :
Both of the above, also return true, mid-bar on initial load. If that isn't wanted:
datetime time0;
int OnInit(){
   time0 = Time[0];
   :
}
void OnTick(){
   datetime timePre = time0; time0 = Time[0];
   bool isNewBar = time0 != timePre;
   :