Simple Sell Script Won't Work?

 

I wrote a very simple sell script. Basically I use a custom indi that does nothing but draws a line at a certain price, say for instance 1.65061. So my script is simply:

         if (BidPrice <= botline) {
         
         sell=True;
       
          }

Where double BidPrice = MarketInfo(Symbol(),MODE_BID);

So if the current market bid price is less than or equal to the botline (the line the custom indi draws), then it should run the sell script. Now, this does work, but only partially, when I test it, it will run the sell, but it keeps opening the sell order at 1.65006 instead of exactly or close to the line of 1.65061. Any idea what I'm doing wrong?

 
Anyone?
 
remix919:
Anyone?

why is there not checked if a sell already has been opend when (BidPrice <= botline)
 
deVries:

why is there not checked if a sell already has been opend when (BidPrice <= botline)

I have other checks I was going to code in, but first trying to figure out why it's not putting the order through at the correct price
 
You can't get the correct price most probably because ...
BidPrice <= botline


Unless you put something like ...

BidPrice == botline


and see what happen.

 
remix919:

I wrote a very simple sell script. Basically I use a custom indi that does nothing but draws a line at a certain price, say for instance 1.65061. So my script is simply:

Where double BidPrice = MarketInfo(Symbol(),MODE_BID);

So if the current market bid price is less than or equal to the botline (the line the custom indi draws), then it should run the sell script. Now, this does work, but only partially, when I test it, it will run the sell, but it keeps opening the sell order at 1.65006 instead of exactly or close to the line of 1.65061. Any idea what I'm doing wrong?


You're telling the script to sell if Bid is = or < than you level or botline and the script does just that. So now you wonder what's wrong with it ?

Nothing ! If the script sells at 1.65006 and you instructed it to sell at or bellow 1.65061, as long as 1.65006 is bellow 1.65061 the script will do just that, sell at bid.

Now if you tell the script to sell at or bellow x and expect it to sell at y, you have a problem and not the script.

This means "at or bellow " the level, not "at level".

if (BidPrice <= botline)


Seriously, the bid is under your level, the script sells bellow the level => script OK.

Hope it helps. Any questions, ask.

Cheers

 
I originally used ==, but doing so it seems to miss a lot of trades?
 
remix919:
I originally used ==, but doing so it seems to miss a lot of trades?

You can try to give it some room like sell if <level && > level -limit*Point where limit is your choice.

That way you stop it from entering if too far from level but not missing on most trades.

Say, if you say

int limit = 200; // points or 20 pips

int minLevel=botline- (limit *Point);

You have an adjustable (can optimize) range from minLevel to botline;

Hope it helps