i'm new and hung out somewhere. I would be glad if you help.
If the close price is up to 20 higher than my active end position, I would like to reopen new position.
How can I assign my last active position price to a variable? and "If the last candle closing price has increased at least 20 from my last open traded price" how can I stipulate it?
show your attempt code.
deneme kodunuzu gösterin.
// Buy if (rsi5m <= 30 && buyopen==0) { openbuyposition(); buyopen=1; lastpositionprice=Close[1]; Sleep(300000); } //again open buy if (buyopen==1 && (lastpositionprice-Close[1])/ Point > 20) { openbuyposition(); lastpositionprice=Close[1]; Sleep(300000); } //close buy pos if (rsi5m >=50 && buyopen==1){ CloseOrders(); buyopen=0; lastpositionprice=""; } } //OnTick Close void openbuyposition() { //open void int tickets = OrderSend(Symbol(),OP_BUY,lot,Ask,10,0,0,"Buy İşlemi Açıldı",OrderMagicNumber(),0,clrBlue); lot=lot*2; openbuy=1;
i'm new and hung out somewhere. I would be glad if you help.
If the close price is up to 20 higher than my active end position, I would like to reopen new position.
How can I assign my last active position price to a variable? and "If the last candle closing price has increased at least 20 from my last open traded price" how can I stipulate it?
Try this
//+------------------------------------------------------------------+ double LastOrder () { double LastOrderPrice; LastOrderPrice=0; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()!=Symbol()) continue; if(OrderType()==OP_BUY) LastOrderPrice=(OrderOpenPrice()); if(OrderType()==OP_SELL) LastOrderPrice=(OrderOpenPrice()); } return (LastOrderPrice); } //+------------------------------------------------------------------+You can use that for your last order price
LastOrder ()that code above not including the Magicnumber, if you want to add that magic number, you may change line of order select
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber) continue;

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i'm new and hung out somewhere. I would be glad if you help.
If the close price is up to 20 higher than my active end position, I would like to reopen new position.
How can I assign my last active position price to a variable? and "If the last candle closing price has increased at least 20 from my last open traded price" how can I stipulate it?