Download MetaTrader 5
To add comments, please log in or register
All activity of the MQL5.community members is displayed on a single page!
remix919
85
remix919 2014.04.07 14:52 

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?

remix919
85
remix919 2014.04.08 14:00  
Anyone?
Tjipke de Vries
6277
Tjipke de Vries 2014.04.08 14:24  
remix919:
Anyone?

why is there not checked if a sell already has been opend when (BidPrice <= botline)
remix919
85
remix919 2014.04.08 19:25  
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
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.09 00:30  
You can't get the correct price most probably because ...
BidPrice <= botline


Unless you put something like ...

BidPrice == botline


and see what happen.

Daniel Petrovai
440
Daniel Petrovai 2014.04.09 10:49  
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

remix919
85
remix919 2014.04.09 18:19  
I originally used ==, but doing so it seems to miss a lot of trades?
Daniel Petrovai
440
Daniel Petrovai 2014.04.10 01:01  
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

/
To add comments, please log in or register