[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 174
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
>> Please advise. I have an Expert Advisor in one window (for example, USDJPY) and I need it to set arrows(ObjectCreate) at a certain moment in other open windows, for example, AUDUSD, EURUSD e.t.c.
If you look in the ObjectCreate helper, you can clearly see that it only works within a single open chart, on which the indicator or Expert Advisor is located. The output can be the transfer of data to the Expert Advisor in the desired window through the global variables or file.
If you look in the ObjectCreate helper, you can clearly see that it only works within a single open chart, on which the indicator or Expert Advisor is located. The output can be the transfer of data to the Expert Advisor in the required window through global variables or a file.
I.e., there is no way to do it from another window? >> Thank you.
How can this pending order modification function be disabled via external variables?
How can this pending order modification function be disabled via external variables?
>> something like this.
Thank you! Vinin!
>> I'll try it.)
Programmers, please help, I need an EA to open orders, even if they are already open. This is a channel EA. Every time a line touches one of the lines, the corresponding order should be opened. I would like to thank you in advance.
//+------------------------------------------------------------------+
//| TradeChannel.mq4 |
//| Copyright © 2005, Yuri Makarov |
//| http://mak.tradersmind.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Yuri Makarov"
#property link "http://mak.tradersmind.com"
extern double Lots = 1.0;
extern int Slippage = 5;
extern int TimeOut = 10000;
double SetLevel(double Level, double NewLevel, string ObjName, int Style)
{
switch (Style)
{
case 1: // Buy Order line
ObjectSet(ObjName,OBJPROP_COLOR,Blue);
ObjectSet(ObjName,OBJPROP_STYLE,STYLE_SOLID);
ObjectSet(ObjName,OBJPROP_WIDTH,2);
break;
case 2: // Sell Order line
ObjectSet(ObjName,OBJPROP_COLOR,Red);
ObjectSet(ObjName,OBJPROP_STYLE,STYLE_SOLID);
ObjectSet(ObjName,OBJPROP_WIDTH,2);
break;
case 3: // Buy Stop line
ObjectSet(ObjName,OBJPROP_COLOR,Blue);
ObjectSet(ObjName,OBJPROP_STYLE,STYLE_DASH);
ObjectSet(ObjName,OBJPROP_WIDTH,1);
break;
case 4: // Sell Stop line
ObjectSet(ObjName,OBJPROP_COLOR,Red);
ObjectSet(ObjName,OBJPROP_STYLE,STYLE_DASH);
ObjectSet(ObjName,OBJPROP_WIDTH,1);
break;
case 5: // Buy Take line
ObjectSet(ObjName,OBJPROP_COLOR,Blue);
ObjectSet(ObjName,OBJPROP_STYLE,STYLE_DOT);
ObjectSet(ObjName,OBJPROP_WIDTH,1);
break;
case 6: // Sell Take line
ObjectSet(ObjName,OBJPROP_COLOR,Red);
ObjectSet(ObjName,OBJPROP_STYLE,STYLE_DOT);
ObjectSet(ObjName,OBJPROP_WIDTH,1);
break;
}
if (MathAbs(NewLevel - Close[0]) < MathAbs(Level - Close[0])) return (NewLevel);
else return (Level);
}
int start()
{
int NumObj = ObjectsTotal();
double Spread = Ask - Bid;
double pBuy = 0;
double pSell = 0;
double pBuyStop = 0;
double pBuyTake = 0;
double pSellStop = 0;
double pSellTake = 0;
for (int i = 0; i < NumObj; i++)
{
string ObjName = ObjectName(i);
string ObjDesc = ObjectDescription(ObjName);
double Price = 0;
switch (ObjectType(ObjName))
{
case OBJ_HLINE:
Price = ObjectGet(ObjName,OBJPROP_PRICE1);
break;
case OBJ_TREND:
Price = ObjectGetValueByShift(ObjName,0);
break;
}
if (Price > 0)
{
if (ObjDesc == "Buy") pBuy = SetLevel(pBuy, Price, ObjName, 1); else
if (ObjDesc == "Sell") pSell = SetLevel(pSell, Price, ObjName, 2); else
if (ObjDesc == "Stop")
{
if (Price < Close[0]) pBuyStop = SetLevel(pBuyStop, Price, ObjName, 3);
else pSellStop = SetLevel(pSellStop, Price, ObjName, 4);
} else
if (ObjDesc == "Take")
{
if (Price > Close[0]) pBuyTake = SetLevel(pBuyTake, Price, ObjName, 5);
else pSellTake = SetLevel(pSellTake, Price, ObjName, 6);
}
}
}
int NumOrders = OrdersTotal();
int NumPos = 0;
for (i = 0; i < NumOrders; i++)
{
OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() != Symbol()) continue;
NumPos++;
double tp = OrderTakeProfit();
double sl = OrderStopLoss();
if (OrderType() == OP_BUY)
{
if (Bid > pSell && pSell > 0)
{
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Red);
Sleep(TimeOut);
return(0);
}
if (MathAbs(tp - pBuyTake) > Spread || MathAbs(sl - pBuyStop) > Spread)
{
OrderModify(OrderTicket(), Ask, pBuyStop, pBuyTake, 0);
Sleep(TimeOut);
return(0);
}
}
if (OrderType() == OP_SELL)
{
if (Ask < pBuy)
{
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Red);
Sleep(TimeOut);
return(0);
}
if (MathAbs(tp - pSellTake) > Spread || MathAbs(sl - pSellStop) > Spread)
{
OrderModify(OrderTicket(), Bid, pSellStop, pSellTake, 0);
Sleep(TimeOut);
return(0);
}
}
}
if (NumPos > 0) return(0);
if ((pSell - pBuy) < Spread*2) return(0);
if (Bid > pSell && pSell > pBuyStop)
{
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, pSellStop, pSellTake);
Sleep(TimeOut);
return(0);
}
if (Ask < pBuy && (pBuy < pSellStop || pSellStop == 0))
{
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, pBuyStop, pBuyTake);
Sleep(TimeOut);
return(0);
}
}
int init()
{
return(0);
}
int deinit()
{
return(0);
}
You are most likely hampered by this line:
We can start with this. This should be removed.
AND Separate the buy and sell entry mechanism. Take I.Kim's function (insert it at the very-very end of the code)
Then the condition of transaction opening will be buy:
And the condition for opening a sell trade :
This problem has probably been solved before 2003. But since someone else doesn't know, I'll share)))
Right-click on the chart - select properties - general tab - check fixed scale - OK
Then hover the mouse over the price scale, left click and keep it pressed, move the mouse up/down to adjust the scale.
You may have it in the main window, so you don't have to look far.
Channel EA
I want to ask the EA to open orders even if they are already open. This is a channel EA, every time some line or other is touched, the corresponding order should be opened. I think this EA will open one order and do not open another one until it closes.
I did what I described in the post above. I inserted the number of positions function and replaced the position opening block at the end with this one:
Now EA can hold at least 2 positions at the same time.
Sorry, I can't test it as you forgot to attach the indicator which draws the channels.