Unreadable. One thought per sentence.
try this:
if (oo.count == 0 && PRICE >= LEVEL){ int ticket = OrderSend(OP_BUY...); if (ticket < 0) Alert("OrderSend failed: ", GetLastError()); else oo.count = 0; }
thanks for answer i will try your code. Realy sorry for my english. in that sentence i meen that i want that order would be opened only if price croses my level line, and not if order closes for such a reason as TP and that instantly open new one becose it is up(more) that my level, i mean this ">" not working, it will keep doing that until price is biger then level, all i need is just cross funcion, from that side wich i want(depends of order type, sell or buy).
I hope you understand now, and again sory for sentence formation, it is realy hard to convert from my language :)
here is biger part of code
double priceB = Ask;
double priceS = Bid;if(CountOrders(MagicNumber,OP_BUY) == 0 && priceB == LINEUP)
{
OrderSend(Symbol(),OP_BUY, Lots,Ask,Slippage,Ask-Stoploss*Point,Ask+ProfitTarget*Point," buy",MagicNumber,0,Blue);
PlaySound(alert+".wav");
}
if(CountOrders(MagicNumber,OP_SELL) == 0 && priceS == LINEDOWND)
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid+Stoploss*Point,Bid-ProfitTarget*Point," sell",MagicNumber,0,Red);
PlaySound(alert+".wav");
}
too dificuilt, much usless info, just need simple algorithm
Hi, i just have seems the simple probleme but canot slove it so simple :/ look lets take an ex:
double price = Ask;
if(CountOrders(MagicNumber,OP_BUY) == 0 && PRICE == LEVEL)
here price is curent price, level is my input that i want, for example line or something, so that is working, its all ok.the probleme is that i need that it open order then price crosses the level from down to up in this case, i could use for sur ">" but then if it reaches TP it allways will keep opening orders until it will be biger then "level", so i use "=" to slove it, but then again the problem comes when it reaches tp and backs to the level from up to down and touches the line it again opens the order. all i need that it would be opening order if it goes from down to up by crossing it once, and keep it until same condicion will form OR if it reaches the line again from the top to down would open the opossite posision, that would be even better for me.
Any ideas? Thank you for any response
Hi Vyckaa,
For 1 trade per crossing - Check for current crossing by using past bar to compare the values with the current bar...
Cross Upwards -
If the past Price starts below the Level and the current Price goes above the Level....then do something...
if ( Price_1 < Level_1 && Price_0 > Level_0 ) Do CrossUpBuy ;
Cross Downwards -
Reverse for the opposite direction.
If the past Price starts above the Level and the current Price goes below the Level....then do something...
if ( Price_1 > Level_1 && Price_0 < Level_0 ) Do CrossDownSell ;
This should do only one trade per crossing....until the next crossing...
Hope this helps,
Robert
- 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, i just have seems the simple probleme but canot slove it so simple :/ look lets take an ex:
double price = Ask;
if(CountOrders(MagicNumber,OP_BUY) == 0 && PRICE == LEVEL)
here price is curent price, level is my input that i want, for example line or something, so that is working, its all ok.the probleme is that i need that it open order then price crosses the level from down to up in this case, i could use for sur ">" but then if it reaches TP it allways will keep opening orders until it will be biger then "level", so i use "=" to slove it, but then again the problem comes when it reaches tp and backs to the level from up to down and touches the line it again opens the order. all i need that it would be opening order if it goes from down to up by crossing it once, and keep it until same condicion will form OR if it reaches the line again from the top to down would open the opossite posision, that would be even better for me.
Any ideas? Thank you for any response