Hello
The EA will be used as a trading assistant and testing new ideas.
I will have code for the other conditions
Example:
//…………………………………………………
int start()
{
//----
if (!StatusOK)
{
return(0);
}
GetDayOpen();
GetSpread();
UpdateStatus();
WriteComment();
int CurrentHour = TimeHour(TimeCurrent());
//……………………………….
I would like an EA that will place the following three pending orders as per the scripts below once every new bar, the EA will be place on several currency pairs at once, so it needs error checking and retries since it will often send orders in one instant.
The ea also should include auto magic numbers as I have other EA’s in separate window that manage the trades based on their names and magic numbers.
An input to set ticket expiration in one or two bars would be nice
Also if a pending buy stop order is placed and the (low[0]-((Spread*2)+(1* point)) < low[2] then delete pending buy stop the EA placed on the current symbol and current time frame
If a pending buy sell stop is placed and the ((high[0] + Spread * 3)+(1*point)) > high[2] then delete the pending sell stop on the EA placed on the current symbol and current time frame.
If possible:
The EA running on the current timeframe will only effect orders it placed on that current time frame. As other orders may be place by other means on the same symbol and different timeframes.
I use the following scripts on the Forex.com UK platform
MULTIBUY
//#property show_inputs
double RiskPercent = 0.35;//.35/2 this time 3 is 100 full postion
//double Lots = 1;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
// Can give name latter with else if
string TicketComment2X = StringConcatenate(TicketComment2X, Period(),"-","2X");
string TicketCommentManageOne = StringConcatenate(TicketCommentManageOne, Period(),"-","MANAGEONE");
string TicketCommentManageTwo = StringConcatenate(TicketCommentManageTwo, Period(),"-","MANAGETWO");
// include auto string for entry timeframe
int SpreadPointss = MarketInfo(Symbol(),MODE_SPREAD);
double GetBid = MarketInfo(Symbol(),MODE_BID);
double SpreadPoints = (SpreadPointss*Point);
double OnePoint = (1*Point);
double Risk = RiskPercent / 100;
double MyStopLoss = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]-(((SpreadPoints+SpreadPoints/2))- OnePoint) ) ) / Point;
double GetTarget = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]- (((SpreadPoints + SpreadPoints/2)) -OnePoint) ) );
// double MyStopLoss = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]-((SpreadPoints/2)- OnePoint) ) ) / Point;
// double GetTarget = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]- ((SpreadPoints/2) -OnePoint) ) );
// double GetTarget = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]- OnePoint) ) ;
double TargetLong = NormalizeDouble((High[1]+GetTarget),Digits);//testing Digits
double Lots = NormalizeDouble( AccountBalance()*Risk/MyStopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);
double LotsDivided = (Lots/2);
double Allowable = (OnePoint*5);
double AutoAllowable = (OnePoint*MarketInfo(Symbol(),MODE_STOPLEVEL));
double EntryPrice;
double BIDANDPOINTS = (GetBid +SpreadPoints+OnePoint);
double HIGHANDPOINTS = (High[1]+SpreadPoints+OnePoint);
// ADJUST ENTRY TO ACCOUNT FOR STOPLOSS LEVAL
if (BIDANDPOINTS > HIGHANDPOINTS-AutoAllowable)
{
EntryPrice = BIDANDPOINTS+AutoAllowable;
} else
{
EntryPrice = HIGHANDPOINTS;
}
if(Lots > 0)
OrderSend(Symbol(),OP_BUYSTOP, Lots, EntryPrice,3,(Low[1]-(SpreadPoints+OnePoint+(SpreadPoints/2))) , TargetLong, TicketComment2X, 0, NULL, LimeGreen);
OrderSend(Symbol(),OP_BUYSTOP, LotsDivided, EntryPrice,3,(Low[1]-(SpreadPoints+OnePoint+(SpreadPoints/2))) , 0,TicketCommentManageOne, 0, NULL, LimeGreen);
OrderSend(Symbol(),OP_BUYSTOP, LotsDivided, EntryPrice,3,(Low[1]-(SpreadPoints+OnePoint+(SpreadPoints/2))) , 0, TicketCommentManageTwo, 0, NULL, LimeGreen);
return(0);
}
//+-------------------------------------------------------
MULTISELL
//#property show_inputs
double RiskPercent = 0.35;//35/2.0
//double Lots = 1;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
string TicketComment2X = StringConcatenate(TicketComment2X, Period(),"-","2X");
string TicketCommentManageOne = StringConcatenate(TicketCommentManageOne, Period(),"-","MANAGEONE");
string TicketCommentManageTwo = StringConcatenate(TicketCommentManageTwo, Period(),"-","MANAGETWO");
int SpreadPointss = MarketInfo(Symbol(),MODE_SPREAD);
double SpreadPoints = (SpreadPointss*Point);
double OnePoint = (1*Point);
double Risk = RiskPercent / 100;
double MyStopLoss = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]-(((SpreadPoints+SpreadPoints/2))- OnePoint) ) ) / Point;
double GetTarget = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]- (((SpreadPoints + SpreadPoints/2))- OnePoint) ) ) ;
// double MyStopLoss = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]-((SpreadPoints/2)- OnePoint) ) ) / Point;
// double GetTarget = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]- ((SpreadPoints/2)- OnePoint) ) ) ;
// double GetTarget = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]- OnePoint) ) ;
double TargetShort = NormalizeDouble((Low[1]-GetTarget),Digits);//testing Digits
double Lots = NormalizeDouble( AccountBalance()*Risk/MyStopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);
double LotsDivided = (Lots/2);
double GetBid = MarketInfo(Symbol(),MODE_BID);
double Allowable = (OnePoint*5);
double AutoAllowable = (OnePoint*MarketInfo(Symbol(),MODE_STOPLEVEL));
double EntryPrice;
double BIDANDPOINTS = (GetBid - OnePoint);
double LOWANDPOINTS = (Low[1]- OnePoint);
// ADJUST ENTRY TO ACCOUNT FOR STOPLOSS LEVAL
if (BIDANDPOINTS < LOWANDPOINTS+AutoAllowable)
{
EntryPrice = BIDANDPOINTS-AutoAllowable;
} else
{
EntryPrice = LOWANDPOINTS;
}
if(Lots > 0)
OrderSend(Symbol(),OP_SELLSTOP, Lots, EntryPrice,3,(High[1]+(SpreadPoints+(SpreadPoints/2)+OnePoint)) , TargetShort, TicketComment2X, 0, NULL, LimeGreen);
OrderSend(Symbol(),OP_SELLSTOP, LotsDivided, EntryPrice,3,(High[1]+(SpreadPoints+(SpreadPoints/2)+OnePoint)) , 0, TicketCommentManageOne, 0, NULL, LimeGreen);
OrderSend(Symbol(),OP_SELLSTOP, LotsDivided, EntryPrice,3,(High[1]+(SpreadPoints+(SpreadPoints/2)+OnePoint)) , 0, TicketCommentManageTwo, 0, NULL, LimeGreen);
return(0);
}
//+------------------------
The EA will be used as a trading assistant and testing new ideas.
I will have code for the other conditions
Example:
//…………………………………………………
int start()
{
//----
if (!StatusOK)
{
return(0);
}
GetDayOpen();
GetSpread();
UpdateStatus();
WriteComment();
int CurrentHour = TimeHour(TimeCurrent());
//……………………………….
I would like an EA that will place the following three pending orders as per the scripts below once every new bar, the EA will be place on several currency pairs at once, so it needs error checking and retries since it will often send orders in one instant.
The ea also should include auto magic numbers as I have other EA’s in separate window that manage the trades based on their names and magic numbers.
An input to set ticket expiration in one or two bars would be nice
Also if a pending buy stop order is placed and the (low[0]-((Spread*2)+(1* point)) < low[2] then delete pending buy stop the EA placed on the current symbol and current time frame
If a pending buy sell stop is placed and the ((high[0] + Spread * 3)+(1*point)) > high[2] then delete the pending sell stop on the EA placed on the current symbol and current time frame.
If possible:
The EA running on the current timeframe will only effect orders it placed on that current time frame. As other orders may be place by other means on the same symbol and different timeframes.
I use the following scripts on the Forex.com UK platform
MULTIBUY
//#property show_inputs
double RiskPercent = 0.35;//.35/2 this time 3 is 100 full postion
//double Lots = 1;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
// Can give name latter with else if
string TicketComment2X = StringConcatenate(TicketComment2X, Period(),"-","2X");
string TicketCommentManageOne = StringConcatenate(TicketCommentManageOne, Period(),"-","MANAGEONE");
string TicketCommentManageTwo = StringConcatenate(TicketCommentManageTwo, Period(),"-","MANAGETWO");
// include auto string for entry timeframe
int SpreadPointss = MarketInfo(Symbol(),MODE_SPREAD);
double GetBid = MarketInfo(Symbol(),MODE_BID);
double SpreadPoints = (SpreadPointss*Point);
double OnePoint = (1*Point);
double Risk = RiskPercent / 100;
double MyStopLoss = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]-(((SpreadPoints+SpreadPoints/2))- OnePoint) ) ) / Point;
double GetTarget = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]- (((SpreadPoints + SpreadPoints/2)) -OnePoint) ) );
// double MyStopLoss = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]-((SpreadPoints/2)- OnePoint) ) ) / Point;
// double GetTarget = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]- ((SpreadPoints/2) -OnePoint) ) );
// double GetTarget = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]- OnePoint) ) ;
double TargetLong = NormalizeDouble((High[1]+GetTarget),Digits);//testing Digits
double Lots = NormalizeDouble( AccountBalance()*Risk/MyStopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);
double LotsDivided = (Lots/2);
double Allowable = (OnePoint*5);
double AutoAllowable = (OnePoint*MarketInfo(Symbol(),MODE_STOPLEVEL));
double EntryPrice;
double BIDANDPOINTS = (GetBid +SpreadPoints+OnePoint);
double HIGHANDPOINTS = (High[1]+SpreadPoints+OnePoint);
// ADJUST ENTRY TO ACCOUNT FOR STOPLOSS LEVAL
if (BIDANDPOINTS > HIGHANDPOINTS-AutoAllowable)
{
EntryPrice = BIDANDPOINTS+AutoAllowable;
} else
{
EntryPrice = HIGHANDPOINTS;
}
if(Lots > 0)
OrderSend(Symbol(),OP_BUYSTOP, Lots, EntryPrice,3,(Low[1]-(SpreadPoints+OnePoint+(SpreadPoints/2))) , TargetLong, TicketComment2X, 0, NULL, LimeGreen);
OrderSend(Symbol(),OP_BUYSTOP, LotsDivided, EntryPrice,3,(Low[1]-(SpreadPoints+OnePoint+(SpreadPoints/2))) , 0,TicketCommentManageOne, 0, NULL, LimeGreen);
OrderSend(Symbol(),OP_BUYSTOP, LotsDivided, EntryPrice,3,(Low[1]-(SpreadPoints+OnePoint+(SpreadPoints/2))) , 0, TicketCommentManageTwo, 0, NULL, LimeGreen);
return(0);
}
//+-------------------------------------------------------
MULTISELL
//#property show_inputs
double RiskPercent = 0.35;//35/2.0
//double Lots = 1;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
string TicketComment2X = StringConcatenate(TicketComment2X, Period(),"-","2X");
string TicketCommentManageOne = StringConcatenate(TicketCommentManageOne, Period(),"-","MANAGEONE");
string TicketCommentManageTwo = StringConcatenate(TicketCommentManageTwo, Period(),"-","MANAGETWO");
int SpreadPointss = MarketInfo(Symbol(),MODE_SPREAD);
double SpreadPoints = (SpreadPointss*Point);
double OnePoint = (1*Point);
double Risk = RiskPercent / 100;
double MyStopLoss = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]-(((SpreadPoints+SpreadPoints/2))- OnePoint) ) ) / Point;
double GetTarget = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]- (((SpreadPoints + SpreadPoints/2))- OnePoint) ) ) ;
// double MyStopLoss = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]-((SpreadPoints/2)- OnePoint) ) ) / Point;
// double GetTarget = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]- ((SpreadPoints/2)- OnePoint) ) ) ;
// double GetTarget = ( (High[1]+(SpreadPoints + OnePoint)) - (Low[1]- OnePoint) ) ;
double TargetShort = NormalizeDouble((Low[1]-GetTarget),Digits);//testing Digits
double Lots = NormalizeDouble( AccountBalance()*Risk/MyStopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);
double LotsDivided = (Lots/2);
double GetBid = MarketInfo(Symbol(),MODE_BID);
double Allowable = (OnePoint*5);
double AutoAllowable = (OnePoint*MarketInfo(Symbol(),MODE_STOPLEVEL));
double EntryPrice;
double BIDANDPOINTS = (GetBid - OnePoint);
double LOWANDPOINTS = (Low[1]- OnePoint);
// ADJUST ENTRY TO ACCOUNT FOR STOPLOSS LEVAL
if (BIDANDPOINTS < LOWANDPOINTS+AutoAllowable)
{
EntryPrice = BIDANDPOINTS-AutoAllowable;
} else
{
EntryPrice = LOWANDPOINTS;
}
if(Lots > 0)
OrderSend(Symbol(),OP_SELLSTOP, Lots, EntryPrice,3,(High[1]+(SpreadPoints+(SpreadPoints/2)+OnePoint)) , TargetShort, TicketComment2X, 0, NULL, LimeGreen);
OrderSend(Symbol(),OP_SELLSTOP, LotsDivided, EntryPrice,3,(High[1]+(SpreadPoints+(SpreadPoints/2)+OnePoint)) , 0, TicketCommentManageOne, 0, NULL, LimeGreen);
OrderSend(Symbol(),OP_SELLSTOP, LotsDivided, EntryPrice,3,(High[1]+(SpreadPoints+(SpreadPoints/2)+OnePoint)) , 0, TicketCommentManageTwo, 0, NULL, LimeGreen);
return(0);
}
//+------------------------
Attached File(s)
Multi Buy.mq4
3 KB
|
183 downloads
MultiSell.mq4
3 KB
|
159 downloads