Help with coding, something really strange

Help with coding, something really strange

Postby LittleCaro » Mon Jun 08, 2020 3:35 pm

Hello guys,

I'm facing a really strange thing, that's several days i'm on it, and well ...

Here is the thing : i create something really basic with Steve's shell.

I want to set pending order + x pips to the high of the previous candle, the thing it :

It's working with High[0] and High[2], BUT it's not working with High[1] the one that i'm interested in.

The expert says error 130 invalid stops, and that's the same stops used with High[0] and High[2]


Maybe some of our geniuses can look at it.

Here is the code :

Code: [Select all]
 Please Login or Register to see this content
<


And the code for calculating stoploss :

Code: [Select all]
 Please Login or Register to see this content
<


Thanks guys !
User avatar
LittleCaro
 
Posts: 62
Joined: Tue May 19, 2015 7:09 am

Help with coding, something really strange

Postby LittleCaro » Mon Jun 08, 2020 5:25 pm

Hey guys,

When i was under my shower, i find partly a solution :

It's the setting : PostTradeAttemptWaitSecond, if i put it to zero, it works.

But now i have another problem, the limit order stays active for only 1 bar if he isn't triggerded, after he gets deleted.

You put a security to delete the pendings ? I looked through the code and find nothing ?
User avatar
LittleCaro
 
Posts: 62
Joined: Tue May 19, 2015 7:09 am

Help with coding, something really strange

Postby SteveHopwood » Mon Jun 08, 2020 7:12 pm

LittleCaro » Mon Jun 08, 2020 3:35 pm wrote:Hello guys,

I'm facing a really strange thing, that's several days i'm on it, and well ...

Here is the thing : i create something really basic with Steve's shell.

I want to set pending order + x pips to the high of the previous candle, the thing it :

It's working with High[0] and High[2], BUT it's not working with High[1] the one that i'm interested in.

The expert says error 130 invalid stops, and that's the same stops used with High[0] and High[2]


Maybe some of our geniuses can look at it.

Here is the code :

Code: [Select all]
 Please Login or Register to see this content
<


And the code for calculating stoploss :

Thanks guys !


Good for you for getting your hands dirty by looking under the bonnet of CrapQl4. :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap:

Re this:
price = High[1] + (PipsAdjust/factor);

Supposing the market had fallen by the time your EA tries to execute this code. You could be trying to send a limit order at an impossible price because the market is already lower than your limit price. You need to check that 'price' is below the current market price so that a limit order is possible. From there, you either abort the trade or send a stop order.

Assuming you are happy to send a stop order, then the construct would be this:
type = BUYLIMIT;
price = High[1] + (PipsAdjust/factor);
if (price > Ask)//In English to follow
{
  • Abort the function if you will not allow stop orders instead of limit orders.
  • Adjust the type code etc if you are happy to accept stop orders.

}

Up an at 'em, Tiger. I hope this helps. Ask away if not.

:xm: :rocket:
Read the effing manual, ok?

Global Prime is the official SHF broker. Click here to sign up for a live account with Global Prime and join the several thousand SHF members who wisely choose GP as their broker of choice.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Tommaso (milanese) for all the incredible work he does here.
User avatar
SteveHopwood
 
Posts: 9554
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Help with coding, something really strange

Postby SteveHopwood » Mon Jun 08, 2020 7:22 pm

LittleCaro » Mon Jun 08, 2020 5:25 pm wrote:Hey guys,

When i was under my shower, i find partly a solution :

It's the setting : PostTradeAttemptWaitSecond, if i put it to zero, it works.

But now i have another problem, the limit order stays active for only 1 bar if he isn't triggerded, after he gets deleted.

You put a security to delete the pendings ? I looked through the code and find nothing ?

Not that I can think of. Try my latest and see, then I will take a look if need be.

:xm: :rocket:
Read the effing manual, ok?

Global Prime is the official SHF broker. Click here to sign up for a live account with Global Prime and join the several thousand SHF members who wisely choose GP as their broker of choice.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Tommaso (milanese) for all the incredible work he does here.
User avatar
SteveHopwood
 
Posts: 9554
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Help with coding, something really strange

Postby LittleCaro » Tue Jun 09, 2020 7:42 am

Hello Steve,

Thanks a lot for all your help.

I restarted from zero, with your latest shell code.

And all is working good.

I also realized that i made a mistake between stop and limit orders.

Sometimes i'm so silly :smile:


Thanks for all !
User avatar
LittleCaro
 
Posts: 62
Joined: Tue May 19, 2015 7:09 am

Help with coding, something really strange

Postby tzaro1 » Wed Nov 03, 2021 2:04 pm

LittleCaro » Tue Jun 09, 2020 5:12 pm wrote:Hello Steve,

Thanks a lot for all your help.

I restarted from zero, with your latest shell code.

And all is working good.

I also realized that i made a mistake between stop and limit orders.

Sometimes i'm so silly :smile:


Thanks for all !


Hi, glad you got it worked out. Regarding 1 bar expiry, the limit/ stop orders in Empty4 use an additional parameter variable of the type 'datetime'. It is the 2nd to last one and between magic number and color. Hope that helps.
tzaro1
 
Posts: 2
Joined: Wed Nov 03, 2021 1:41 pm


Return to Coders Hangout

Who is online

Users browsing this forum: No registered users and 1 guest

cron