I need close position, when bar is closing......

 

Hi all, i need help. I want add to my EA this: If bar is closing (each bar), close position. (EXIT BUY / EXIT SELL),

thank you

//Close

//+------------------------------------------------------------------+

//| Signal Begin(Exit Buy) |

//+------------------------------------------------------------------+


if (I need this code !!!!...................) = SIGNAL_CLOSEBUY


//+------------------------------------------------------------------+

//| Signal End(Exit Buy) |

//+------------------------------------------------------------------+


if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {

OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);

if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");

if (!EachTickMode) BarCount = Bars;

IsTrade = False;

continue;

}

 

FXnight gives away an indicator which times down to the end of the bar for each time frame it is in.

you could maybe use that as your exit signal ? Im only a beginner and too busy just now to offer other help, sorry.

 

You don't know exactly when a bar actually closes until the new tick opens another.

BarCloseTime = Time[0] + Period()*60 - 1;

 
rozirozi:

Hi all, i need help. I want add to my EA this: If bar is closing (each bar), close position. (EXIT BUY / EXIT SELL),

thank you

//Close

//+------------------------------------------------------------------+

//| Signal Begin(Exit Buy) |

//+------------------------------------------------------------------+

if (I need this code !!!!...................) = SIGNAL_CLOSEBUY

//+------------------------------------------------------------------+

//| Signal End(Exit Buy) |

//+------------------------------------------------------------------+


Hi Rozirozi,

Try using one or both of the following - OrderOpenTIme() and OrderOpenPrice():

if (

Time[0] > OrderOpenTime() && Close[0] == OrderOpenPrice()

) Order = SIGNAL_CLOSEBUY

Do the same for SELL's.


Hope this helps,

Robert

 
cosmicbeing:

Hi Rozirozi,

Try using one or both of the following - OrderOpenTIme() and OrderOpenPrice():

if (

Time[0] > OrderOpenTime() && Close[0] == OrderOpenPrice()

) Order = SIGNAL_CLOSEBUY

Do the same for SELL's.


Hope this helps,

Robert




GREAT!! OrderOpenTime() work!! Thank you cosmicbeing
 

can someone help me edit sar ohlc to use heiken ashi ohlc

Hi, I have an MTF indicator that uses sar, however I'd like the sar to calculate heiken ashi ohlc, and not the normal type

Can you tell me how I can do this, my mtf indicator calls to the sar indicator to calculate sar formula, I think it is calling to the internal indicator in mt4 that can not edit

you can skype or email if you can assist and like to talk about it

skype sty671

email sty671@gmail.com

I can also supply the original file that I'm trying to use heiken ashi ohlc for

 
Robert:

Hi Rozirozi,

Try using one or both of the following - OrderOpenTIme() and OrderOpenPrice():

if (

Time[0] > OrderOpenTime() && Close[0] == OrderOpenPrice()

) Order = SIGNAL_CLOSEBUY

Do the same for SELL's.


Hope this helps,

Robert

hello. i have an Ea that i need to add codeso that when it opens a trade, that thade is closed at the closing of that bar.

i have used diffent codes but none is working. i need help.
   RefreshRates();
   double lts=fGetLotsSimple(OP_BUY);
  // int SIGNAL_CLOSEBUY,Order;
      if(lts>0){      
         if(!IsTradeContextBusy()){
            double slts=ND(Ask-Point*StopLoss);
            if(StopLoss==0)slts=0;
            double tpts=ND(Ask+Point*TakeProfit);
            if(TakeProfit==0)tpts=0;
             
            int irv=OrderSend(Symbol(),OP_BUY,lts,ND(Ask),Slippage,slts,tpts,NULL,Magic_N,0,CLR_NONE);
               if(irv>0)
               {
                  
                  LastBuyTime=iTime(NULL,TimeFrame,0);
                  if(
                  Time[0]>OrderOpenTime()&&Close[0]==OrderOpenPrice());
                   OrderClose(OrderTicket(),OrderLots(),Ask,0,CLR_NONE);
                  if(CancelSleeping)LastSellTime=0;
                  return(irv);
                  
               }
               else{
                  Print ("Error open BUY. "+fMyErDesc(GetLastError())); 
                  return(-1);
               }
         }
         else{
            static int lt2=0;
               if(lt2!=iTime(NULL,TimeFrame,0)){
                  lt2=iTime(NULL,TimeFrame,0);
                  Print("Need open buy. Trade Context Busy");
               }            
            return(-2);
         }

Reason: