Hi Guru's
Could someone possibly help me with this bit of code:
I've defined as user input
extern double high_price = 2.0500;
and opp for low
extern double low_price = 2.0400;
using this I can calculate the distance from the current price that i want to place pending orders.
For some reason when I do the calculations for distanceh or distancel (see below) it goes wrong, it won't place an order BUT if I tell it the distance as external double distance = 15; it is ok.
Code:
int start()
{
int ticket,distanceh,distancel;
string hcomment = "place pending";
distanceh = (high_price - Bid); //works out distance from current price for pending buystop
distancel = (Ask - low_price); // vice versa for sell stop
ticket=OpenPendingOrder(OP_SELLSTOP,lots,distancel,5,stoploss,takeprofit,hcomment);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("Pending " + GetOrderType(OrderType()) + " order opened : ",OrderOpenPrice());
}
else Print("Error opening Pending " + GetOrderType(OrderType()) + " order : ",GetLastError());
ticket=OpenPendingOrder(OP_BUYSTOP,lots,distanceh,5,stoploss,takeprofit,hcomment);
if(ticket>0)
{
any help very appreciated. It doesn't seem to like the output from the calculation so not going any further. I'm also wondering if the price format has anything to do with it, i.e number of decimal places possibly
Many thanks
KevM

- 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've looked forever but can't find a script to place 2 pending orders at my prices, a pending buy stop at one price and a pending sell stop at another.
Does such a script exist, most straddles work on "x pips away from the current price" but this is not the same as setting my own price with an expiry.
If anyone can give me a heads up on finding this script, if it exists, would really appreciate it, I feel like my eyes are going to pop out.
I did try and code it based on a news script but it was a bit of a disaster :-).
my 2 efforts are below (I am not a programmer so I have tried to mod exisitng scripts) if some one sees something in them that could be salvaged please let me know. I know how difficult programming is now.
Many thanks
Kevin
this one might be closer, it compiles ok, just doesn't work