close target directly

 

hello every body...

i have code like this:

double ma= iMA(NULL,0,10,0,MODE_SMMA,PRICE_CLOSE,0);
double ma1= iMA(NULL,0,10,0,MODE_SMMA,PRICE_CLOSE,1);

if(High[1]>ma && High[2]<ma){
ticket=OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(Ask,4),3,NormalizeDouble(Ask-StopLose,Digits),NormalizeDouble(Ask+TakeProfit,Digits),0,Green) ;

}

if(Open[0] >ma && Open[1]<ma )
{
closebuy function.......
}


i want the price if have touch the ma line, so close the position directly..

but the problem is the price always close in the next candle stick,

so how to make the position close directly after touch the ma?

thx..

 

my old problem untill now still not get resolved..

seems easy, but difficult...

even using

If (Open[0]>ma)
or Close[0] 
or High[0]
or Low[0]
or [1]
or >ma1
or bid > ma or ma1
or ask > ma or ma1

the result always close target at next bar or candlestick..

can not close at that time when touch the ma line...

 
if (MarketInfo(Symbol(),MODE_ASK) >= ma)
 

can not too....

and i change to mode_bid, same result too, always close in next openning candlestick..

is the meta can not execute trade in middle of timeframe?

always execute after timeframe ends..

 

show your code

(don't use if New_Bar())

 

oh.. great..

you know if i always using my favorite code (new bar).. hehe..

thx, now can work after not using new bar on

if (MarketInfo(Symbol(),MODE_ASK) >= ma)
thx very much gjol..... :)
 

hardyyanto:

so how to make the position close directly after touch the ma?


  1. //  if(Open[0] >ma && Open[1]<ma )
    //  {
    //     closebuy function.......
    //  }
    
    if(Open[0] >ma && Bid<=ma )
    {
       closebuy function.......
    }
 

Whroeder,

this problem have solved by gjol..

the answer is removing the new bar function from order close function..

if not, so all condition will be close in next bar.. ok..