An advisor that would follow the rate on a five-minute chart with conditions after launch: - page 12
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
Insert a function at the end of the code -
And to make it work, insert the line before the buy/sell :
and see what happens.Still mistakes... mistakes...
//------------------------------ //+----------------------------------------------------------------------------+ //| Возвращает номер бара открытия последней позиции или -1. | //| Параметры: | //| sym - наименование инструмента ("" - текущий символ) | //| tf - таймфрейм ( 0 - текущий таймфрейм) | //| op - операция (-1 - любая позиция) | //| mn - MagicNumber (-1 - любой магик) | //+----------------------------------------------------------------------------+ int NumberOfBarOpenLastPos(string sym="", int tf=0, int op=-1, int mn=-1) { datetime oot; int i, k=OrdersTotal(); if (sym=="") sym=Symbol(); for (i=0; i<k; i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol()==sym) { if (OrderType()==OP_BUY || OrderType()==OP_SELL) { if (op<0 || OrderType()==op) { if (mn<0 || OrderMagicNumber()==mn) { if (oot<OrderOpenTime()) oot=OrderOpenTime(); } } } } } } return(iBarShift(sym, tf, oot, True)); } int start() { if (NumberOfBarOpenLastPos()>0) if(OrdersTotal()!=0) return; //Выполнять только одну сделку. //--- if (Ask - iOpen(NULL,0,0)>=Delta*Point) //Цена выросла больше Delta пунктов - продаем!!! { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"Продал"); } //------------------------------------------------------------------------- if (iOpen(NULL,0,0)-Bid >=Delta*Point) //цена упала больше Delta пунктов - покупаем!!! { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"Купил"); } //---- return(0); }And also, will this line in the code be redundant? :Trying to make the above code work. An error appears in the log with the text:
18:38:23 '153085': order sell 1.00 GBPUSD opening at 2.0006 sl: 2.0019 tp: 2.0003 failed [Invalid S/L or T/P]
What is the meaning of this?
Again a problem.
I am trying the above described code. An error appears in the log with the text:
18:38:23 '153085': order sell 1.00 GBPUSD opening at 2.0006 sl: 2.0019 tp: 2.0003 failed [Invalid S/L or T/P]
What is the meaning of this?
1) And what DT do you use for MT4?
2) What is the allowable distance of stoploss and takeprofit in this brokerage house?