Hi guys,
I am a beginner so please excuse my lack of coding skills!
First- I have created an EA to CLOSE all positions using a button on the chart (close all trades button)
In this same EA I also want it to draw arrows on the chart when I open new positions manually.
So I am trying to add an arrow on the chart next to where a position is opened (when opening manually via MT4's Order Window or the built-in Once-Click trading buttons on the chart)
Something wrong with my code but I don't know what it is, arrows do not appear when I open trades.
Am I doing this right? Appreciate any help!
//+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { bool test; for (int i=0; i < OrdersTotal(); i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY || OrderType() == OP_SELL) { ObjectCreate(0, "OrderArrow",OBJ_ARROW, 0, OrderOpenTime(), OrderOpenPrice()); ObjectSet(0, OBJPROP_ARROWCODE, 1); ObjectSet(0, OBJPROP_COLOR, Red); ObjectSetText(0, "BUY"); } } } }
thanks so much Marco. changed to 0.
Out of curiosity- may I ask why I have to use 0 and cannot use 1?
I also created a string variable (i.e "name") and that worked too, but dont understand why 1 didnt work
thanks so much Marco. changed to 0.
Out of curiosity- may I ask why I have to use 0 and cannot use 1?
I also created a string variable (i.e "name") and that worked too, but dont understand why 1 didnt work
chart_id
[in] Chart identifier.
0 means the main chart window.
if you have another chart open with ID=1 then the object should show up on that chart..
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
I am a beginner so please excuse my lack of coding skills!
First- I have created an EA to CLOSE all positions using a button on the chart (close all trades button)
In this same EA I also want it to draw arrows on the chart when I open new positions manually.
So I am trying to add an arrow on the chart next to where a position is opened (when opening manually via MT4's Order Window or the built-in Once-Click trading buttons on the chart)
Something wrong with my code but I don't know what it is, arrows do not appear when I open trades.
Am I doing this right? Appreciate any help!