OP_BUY wont trigger but OP_SELLSTOP does!!!!?????

 

KIndly share your input as to why this piece of code opens a sellstop order and yet doesnt open the buy order that precedes the sellstop.

if ( MacdCurrent > 0 && MacdCurrent > Signal Current)

{

Alert("LONG :", Symbol());

condition1 = true;

}

if (condition1)

{ if (OrderType()!=OP_BUY)

{ticket=OrderSend( Symbol(), OP_BUY, Lots, Ask,30,0,Ask+TakeProfit*Point," ",0,0,Green);

ticket=OrderSend(Symbol(), OP_SELLSTOP,Lots,Ask-300*Point,3,0,Ask-800*Point," ",0,0,Red);

return(0);

}

return(0);

}

 

You need to capture the error value that is generated by OrderSend for the OP_BUY order and have your code log (either print or alert) the error.

Bigger issue for you, that I see, is that you are operating without a working understanding of how to handle errors in general. Yeah you have this one specific error that is kind of hard to miss when it happens, but there are lots of errors that can occur and your code is not setup to capture them, nor are you setup to expect/understand/interpret them.

There are lots of examples in the code bank, you need to work through some of them to see examples of how to improve the error handling of your code. I'd make that a priority if I were in your shoes.

 
1005phillip:

You need to capture the error value that is generated by OrderSend for the OP_BUY order and have your code log (either print or alert) the error.

Bigger issue for you, that I see, is that you are operating without a working understanding of how to handle errors in general. Yeah you have this one specific error that is kind of hard to miss when it happens, but there are lots of errors that can occur and your code is not setup to capture them, nor are you setup to expect/understand/interpret them.

There are lots of examples in the code bank, you need to work through some of them to see examples of how to improve the error handling of your code. I'd make that a priority if I were in your shoes.


Thanks alot 1005phillip!!! Your input and response in good time means alot to me.I have picked up some code and placed it right under the OP_BUY, to alert as to the specific error as to why the long doesnt trigger. On a whole other issue,,,,, how visible is one's EA code to the brokers specifically and to other coders and traders in general(is it safe from hacking?). Thanks in advance and have a great day!!!
 
kenkajei:

On a whole other issue,,,,, how visible is one's EA code to the brokers specifically and to other coders and traders in general(is it safe from hacking?). Thanks in advance and have a great day!!!


Happy to help. Regarding code...there are no guarantees. Metaquotes claims the broker cannot see your code, but then again we end-users had no idea Metaquotes was enabling the "virtual trader plugin" that even the NFA regarded as being unethical and fined a couple of US brokers for it. In matters where Metaquotes desires the end-user to trust them at their word, the track record is not pristine. So...

But no, no one to date has even made a weakly supported claim that the broker has somehow acquired their own code. If it were possible or transpiring then someone would have a made a ruckus about it by now, even if it was just a weakly plausible one. And there are a lot of disreputable brokers out there, less today than 4-5 yrs ago, but I'm just saying there have been brokers in the past that were simply stealing their customers money outright and got caught doing it.

If there was a way for the brokers to steal their customer's code then those nasty brokers would have done it, and the regulators found no such evidence of IP theft when they raided the offices and audited their computers.

(think about it, what sort of dumb criminal would steal money and get themselves caught doing the obvious crime while being so savvy that they'd hide their tracks of stealing code such that no regulatory body would find out? If they were savvy enough to accomplish that they'd be smart enough to limit their illegal activities to just the one's they could do without drawing attention to themselves)

As for your code...anyone can decompile your code from a compiled binary. This is a fact of life for all software programmers, not just MQL programmers. Even with billions of dollars invested per year into things like DRM and anti-piracy measures the software industry has failed to stop piracy. Even more money is spent on anti-piracy measures for Hollywood (movies) and their combined resources are no match for the cunning and craftiness of motivated hackers.

Nothing you do, no program you buy, will ever be able to protect your code. If such a thing existed then the company offering the ability to protect your code would be bought up in a heartbeat by Microsoft or Apple and you'd never hear of them again (and jailbreaking iPhone's and PS3's would be a thing of the past). There are programs that purport to be able to protect your code from decompile...but think about it. You can rationalize for yourself whether or not these guys have a legitimate product or are selling snake-oil.

The best defense of your intellectual property, if you truly wish it to remain a secret known only to you, is to never upload the binaries or source code anywhere, never give it to anyone.