Doesn't seem to be working. Here's my code:
while (execute_trade ==5)
{if ( OrdersTotal() <= buy_trade1 )
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point);
double price = OrderOpenPrice();
Comment ("My 1st trade order " + price);
execute_trade=0;
Before you can "work with a ticket", you must "select" it.
See OrderSelect()
Or you could try something like:
Well, if I tried that the comment would change with each new "Ask" price change, right?
I'm a total newbie here but the ultamate goal that I'm trying to reach is to have it do the following:
- Place a buy order with T/P of 60
- If price drops -60 pips from the 1st order then place a 2nd "buy" order
- If the price of the 2nd order drops another -60 pips then place a 3rd order and so on in a loop until the tickets close out on their own.
- If the 1st order is fine...then +30 pips from the 1st order place a 2nd order with t/p of 60 pips
- If 2nd order is fine...then +30 pips from the 2nd order...place a 3rd and last trade with t/p of 60 pips.
- Also, if any of the "good" trades drop -60 pips have the EA place another buy order...same as before.
Well, if I tried that the comment would change with each new "Ask" price change, right?
No, only after you placed an OrderSend and that OrderSend succeeded.
No, only after you placed an OrderSend and that OrderSend succeeded.
Ok yeah that worked. But how can I move it into a variable so I can compare it in an "if" or "while" loop?
Ok yeah that worked. But how can I move it into a variable so I can compare it in an "if" or "while" loop?
double myVariable = Ask;
(Please have a look at the docs.)
CB
I can make it now put in the 1st trade fine...but the second trade it puts in 76 trades all at once. How can I control it to only add in 1?
while (execute_trade ==5)
{if ( OrdersTotal() == buy_trade1 ) //this stops it after 1 order have been placed.
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point);
execute_trade=0;
if(OrderSelect(1, SELECT_BY_TICKET)==true) //selecting order 1
{
buy1 = OrderOpenPrice(); //taking the 1st order's price and pushing it into this variable
// Comment("order #1 open price is ", OrderOpenPrice() + " " + buy1 + " less than " + (buy1-0.0030));
if (buy1 >= (buy1-0.0030))
{
//if ( OrdersTotal() <= buy_trade1 ) //this stops it after 1 order have been placed.
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point);
execute_trade=0;
}
}
else
Print("OrderSelect returned the error of ",GetLastError());

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
For example, if my EA placed an order for a "buy" how can I move that price value into a variable?
Opening price