My code below places sell pending orders when certain candle pattern conditions are met on the H_1 chart. At certain points the condition is met but the pending orders are not placed, as in the encircled portions in https://imgur.com/a/3pNC7M3 . I am not sure what's causing it.
Did you check these?
MarketInfo(_Symbol,MODE_STOPLEVEL);
When limit (price - Bid) and your stoploss/takeprofit is less than stoplevel, OrderSend() will fail.
Did you check these?
When limit (price - Bid) and your stoploss/takeprofit is less than stoplevel, OrderSend() will fail.
Thanks. I adjusted the Period condition code in the following way and it seems like the send orders always fail. Even on a weekly period that the difference in the entry price and stop loss is very large. How can I solve this? Is there a way I could delay the pending order or try after a new bar is formed till it goes through? Or what's the recommended way of solving this kind of issue?
if(_Period == 10080){ double entryPrice=bottom-3*_Point; double stopLoss=top; double slDist=fabs(entryPrice-stopLoss); double dTakeProfit=entryPrice-2*slDist; int ticketSell = OrderSend(Symbol(),OP_SELLLIMIT,lotSize, entryPrice,0, stopLoss,dTakeProfit,"SellOrder",magicnumber,0,Red); double val = MarketInfo(_Symbol,MODE_STOPLEVEL); double bpDiff = entryPrice - Bid; if (bpDiff < val || slDist < val) { Print("stop level caused order to fail = "+failCount); failCount++; }
returning both true and false seems odd
bool isBearishEngulfing(int current) { if( (iClose(_Symbol,0,current ) < iOpen( _Symbol,0,current )) && (iClose(_Symbol,0,current + 1) > iOpen( _Symbol,0,current + 1)) && (iOpen( _Symbol,0,current ) > iClose(_Symbol,0,current + 1)) && (iClose(_Symbol,0,current ) < iOpen( _Symbol,0,current + 1)) ) return true;////?? return false; ////?? }
returning both true and false seems odd
Okay, actually I think putting it in curly braces is better, but I don't think it really changes the result since true will be returned if the condition is satisfied and false if not. This seems to be doing exactly what I want it to do. Unless I don't fully understand your comment.
well i think using 'else' would be better. If it's not true then it needs to return false ;). Your code do not tell what to do it if it's false, it runs both,first telling it's true and then direct after it's false- it can't work out. Well this is my opinion
bool isBearishEngulfing(int current) { if( (iClose(_Symbol,0,current ) < iOpen( _Symbol,0,current )) && (iClose(_Symbol,0,current + 1) > iOpen( _Symbol,0,current + 1)) && (iOpen( _Symbol,0,current ) > iClose(_Symbol,0,current + 1)) && (iClose(_Symbol,0,current ) < iOpen( _Symbol,0,current + 1))) return(true); else return(false); }
maybe this is better
maybe this is better
what about them? is there an issue with entry price maybe...
for a sell limit order the entry price would be for example;
Bid + distance to price, or if the broker uses a dynamic stops level then it would be with the use of MODE_STOPLEVEL Bid + Stops Level + distance
what about them? is there an issue with entry price maybe...
for a sell limit order the entry price would be for example;
Bid + distance to price, or if the broker uses a dynamic stops level then it would be with the use of MODE_STOPLEVEL Bid + Stops Level + distance
I don't fully get this.
What should my OrderSend() precisely be in the code below
double entryPrice=bottom-3*_Point; double stopLoss=top; double slDist=fabs(entryPrice-stopLoss); double dTakeProfit=entryPrice-2*slDist; int ticketSell = OrderSend(Symbol(),OP_SELLLIMIT,lotSize, entryPrice,0, stopLoss,dTakeProfit,"SellOrder",magicnumber,0,Red);
for both a SELLLIMIT and a SELLSTOP?
Thanks. I adjusted the Period condition code in the following way and it seems like the send orders always fail. Even on a weekly period that the difference in the entry price and stop loss is very large. How can I solve this? Is there a way I could delay the pending order or try after a new bar is formed till it goes through? Or what's the recommended way of solving this kind of issue?
Assuming that the price you're setting SellLimit is above Bid in the first place, just that the Bid and entryprice are too close to each other (in which case using higher timeframe does not necessarily widen the gap between entry price and stop loss)... then I have these two thoughts:
(1) As you mentioned, one way is to delay the pending order - you can always keep track of un-sent pending order with a global array of prices, for instance. Then you scan through this array in later ticks to set pending order for those that qualify.
or
(2) since your Bid is already so close to your entryprice, how about opening a Sell straightaway?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
My code below places sell pending orders when certain candle pattern conditions are met on the H_1 chart. At certain points the condition is met but the pending orders are not placed, as in the encircled portions in https://imgur.com/a/3pNC7M3 . I am not sure what's causing it.