but I need over all take profit include buy & sell both take profit.
Thanks for your help.
Gayathri.
Try...
externdouble Lots=0.1;
externdouble ProfitGoal=10.00; // Profit goal in deposit currencydatetime NewTime=0;
int start()
{
if(NewTime!=Time[0])
{
NewTime=Time[0];
if(Close[1]>=Open[1])
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,NULL,0,0,Blue);
elseOrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,NULL,0,0,Red);
}
if(AccountProfit()>=ProfitGoal) // Checks if you reached your profit goal
{
// Closes all orders oldest first inline with FIFOfor(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),10,clrNONE))
i--; // Decrement by one since closed orders are removed from que
}
}
return(0);
}
#property strictexterndouble Lots=0.1;
externint TakeProfit=30; // Take profit value in pointsexterndouble ProfitGoal=10.00; // Profit goal in deposit currencydatetime NewTime=0;
//+------------------------------------------------------------------+//| Begin main function |//+------------------------------------------------------------------+int start()
{
if(NewTime!=Time[0]) // Run only on new bars
{
NewTime=Time[0];
bool orderOpended=false;
if(Close[1]>=Open[1])
orderOpended=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+(TakeProfit*_Point),NULL,0,0,Blue);
else
orderOpended=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-(TakeProfit*_Point),NULL,0,0,Red);
}
if(AccountProfit()>=ProfitGoal) // Checks if you reached your profit goal
{
// Closes all orders oldest first inline with FIFOfor(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),10,clrNONE))
i--; // Decrement by one since closed orders are removed from que
}
}
return(0);
}
//+------------------------------------------------------------------+
You probably would want to add, stoploss and maxloss.
Opens buys on Bullish Engulfing candles when RSI is above overbought and sells on Bearish Engulfing candles when RSI is below oversold. When the account's profit reaches the desired level it closes all the orders. Inputs Lot size - specify the trade...
This is the simplest way, but it leaves a lot to be desired, does not work with ECN brokers.
Dear John Davis
but I need over all take profit include buy & sell both take profit.
Thanks for your help.
Gayathri.
Dear John Davis
but I need over all take profit include buy & sell both take profit.
Thanks for your help.
Gayathri.
Try...
Dear John Davis
i am very happy
you are amazing,thank you for your precious time.
Gayathri
Try...
Dear John Davis
in profit its not closing single pair
its closing total profit.
Thanks
Gayathri
Dear John Davis
in profit its not closing single pair
its closing total profit.
Thanks
Gayathri
Ok, so this code has both types.
You probably would want to add, stoploss and maxloss.
So, I released some code to the codebase, based on upon my interaction with you on this forum. Check it out.
https://www.mql5.com/en/code/19180
Not really profitable but the code fits on one page.