My shell EA code

Post Reply
User avatar
NeoTrader
Trader
Posts: 436
Joined: Wed Apr 04, 2012 2:52 pm
Location: small Village at Lake Chiemsee, Bavaria, Germany

Re: My shell EA code

Post by NeoTrader »

Hi Steve,

me again... ;)

Still in the Process of making the documentation and getting to grip with your Shell EA
I tumbled over something that I think you should look at.

ModifyOrder()
Your ModifyOrder() Function never reports back if the modify was successful or not...it only creates an Error Report.
This means that SendSingleTrade() can create an order and if the crim is an ECN and the ModifyOrder fails you would have an open Order without SL/TP set.

Wouldn't it be better to define ModifyOrder as bool and send a true/false back if it was successful or has failed? And repeat the Modify Process till it succeeds?

Or did I miss something?


happy trading,

NeoTrader

-
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: My shell EA code

Post by SteveHopwood »

NeoTrader wrote:Hi Steve,

me again... ;)

Still in the Process of making the documentation and getting to grip with your Shell EA
I tumbled over something that I think you should look at.

ModifyOrder()
Your ModifyOrder() Function never reports back if the modify was successful or not...it only creates an Error Report.
This means that SendSingleTrade() can create an order and if the crim is an ECN and the ModifyOrder fails you would have an open Order without SL/TP set.

Wouldn't it be better to define ModifyOrder as bool and send a true/false back if it was successful or has failed? And repeat the Modify Process till it succeeds?

Or did I miss something?


happy trading,

NeoTrader

-
Welcome to the warped and twisted world of Crapql4 order sending - my world. :lol:

What if the ordermodify continues to fail? What if continued, unlimited attempts to modify the order sets up unforeseen memory problems that cause an endless loop, platform freeze or computer crash?

Is this possible? I do not know, but I tell you this: we are relying on a combination of Crapdows os, Empty4 and Crapql4. Is the sort of scenario I describe above so unlikely? And how about all the possible combinations this Trio of Woe and Cataclysmic Crap might throw up that we cannot foresee? No idea what they might be, because nobody has foreseen them. Apart from the cowboys who programmed all this rubbish, who have probably built in quite a lot of stuff deliberately to make watertight code almost impossible to achieve.

Those were the questions that raced through my mind when I contemplated the very same problem you raised, back when Matt first produced the code.

InsertStopLoss/TakeProfit are the functions that deal with the prob. They are both called from within CountOpenTrades and insert said thingies when they should be there but are not. Developers just need to be aware that the functions might need adapting to suit the needs of the system.

:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

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

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
NeoTrader
Trader
Posts: 436
Joined: Wed Apr 04, 2012 2:52 pm
Location: small Village at Lake Chiemsee, Bavaria, Germany

Re: My shell EA code

Post by NeoTrader »

hi Steve
SteveHopwood wrote:Welcome to the warped and twisted world of Crapql4 order sending - my world. :lol:

What if the ordermodify continues to fail? What if continued, unlimited attempts to modify the order sets up unforeseen memory problems that cause an endless loop, platform freeze or computer crash?

Is this possible? I do not know, but I tell you this: we are relying on a combination of Crapdows os, Empty4 and Crapql4. Is the sort of scenario I describe above so unlikely? And how about all the possible combinations this Trio of Woe and Cataclysmic Crap might throw up that we cannot foresee? No idea what they might be, because nobody has foreseen them. Apart from the cowboys who programmed all this rubbish, who have probably built in quite a lot of stuff deliberately to make watertight code almost impossible to achieve.

Those were the questions that raced through my mind when I contemplated the very same problem you raised, back when Matt first produced the code.

InsertStopLoss/TakeProfit are the functions that deal with the prob. They are both called from within CountOpenTrades and insert said thingies when they should be there but are not. Developers just need to be aware that the functions might need adapting to suit the needs of the system.
Ok... I understand the problematic...but if the ModifyOrder fails when you call it then the other two Functions will also fail because of the same Problem because all three Functions use the OrderModify Function of Empty4 to complete their task.

Wouldn't it be better to make the ModifyOrder as reliable as possible so we don't need to tweek around it...possibility to do so would be to use the sleep function O_R_Sleep that you already use in O_R_CheckForHistory() instead of the Sleep(100). Or to integrate the CalculateStopLoss and CalculateTakeProfit calls into it.

Why handle and deal with 3 Functions if one clean Function could do this? It would make the code clearer and more logical. Or get rid of order modify and call only InsertStopLoss/TakeProfit.
Redundant code is always bad and confuses people.


By the way I think I found a bloop in your InsertStopLoss() Function in the current ShellEA BareBone
if (OrderType() == OP_BUY)
{
stop = CalculateStopLoss(OP_SELL);
}//if (OrderType() == OP_BUY)

if (OrderType() == OP_SELL)
{
stop = CalculateStopLoss(OP_SELL);
}//if (OrderType() == OP_SELL)
The red selection should be OP_BUY if I'm not wrong (Line1683).



happy trading,

NeoTrader

-
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: My shell EA code

Post by SteveHopwood »

NeoTrader wrote:hi Steve
SteveHopwood wrote:Welcome to the warped and twisted world of Crapql4 order sending - my world. :lol:

What if the ordermodify continues to fail? What if continued, unlimited attempts to modify the order sets up unforeseen memory problems that cause an endless loop, platform freeze or computer crash?

Is this possible? I do not know, but I tell you this: we are relying on a combination of Crapdows os, Empty4 and Crapql4. Is the sort of scenario I describe above so unlikely? And how about all the possible combinations this Trio of Woe and Cataclysmic Crap might throw up that we cannot foresee? No idea what they might be, because nobody has foreseen them. Apart from the cowboys who programmed all this rubbish, who have probably built in quite a lot of stuff deliberately to make watertight code almost impossible to achieve.

Those were the questions that raced through my mind when I contemplated the very same problem you raised, back when Matt first produced the code.

InsertStopLoss/TakeProfit are the functions that deal with the prob. They are both called from within CountOpenTrades and insert said thingies when they should be there but are not. Developers just need to be aware that the functions might need adapting to suit the needs of the system.
Ok... I understand the problematic...but if the ModifyOrder fails when you call it then the other two Functions will also fail because of the same Problem because all three Functions use the OrderModify Function of Empty4 to complete their task.
They try again at every tick and alert me to a problem. I am happy with this as it is - it ain't bust so I ain't fixin' it.
By the way I think I found a bloop in your InsertStopLoss() Function in the current ShellEA BareBone
if (OrderType() == OP_BUY)
{
stop = CalculateStopLoss(OP_SELL);
}//if (OrderType() == OP_BUY)

if (OrderType() == OP_SELL)
{
stop = CalculateStopLoss(OP_SELL);
}//if (OrderType() == OP_SELL)
The red selection should be OP_BUY if I'm not wrong (Line1683).



happy trading,

NeoTrader

-
Yep. I have to fix this every time I use the shell, but by then I have renamed it and am busy, and so forget to return to the shell and add the fix. :lol:

Done it now, rather than wait and forget again. Cheers.

:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

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

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
NeoTrader
Trader
Posts: 436
Joined: Wed Apr 04, 2012 2:52 pm
Location: small Village at Lake Chiemsee, Bavaria, Germany

Re: My shell EA code

Post by NeoTrader »

hi Steve,
SteveHopwood wrote:They try again at every tick and alert me to a problem. I am happy with this as it is - it ain't bust so I ain't fixin' it.
We could get philosophical about this... ;) actually your ModifyOrder is bust...;)
thats why you need this two Functions.. ;)

But I will not go there...you're the Boss and this is your castle aehem code.. ;)


happy trading,

NeoTrader

-
User avatar
NeoTrader
Trader
Posts: 436
Joined: Wed Apr 04, 2012 2:52 pm
Location: small Village at Lake Chiemsee, Bavaria, Germany

Re: My shell EA code

Post by NeoTrader »

hi steve,

and again some observations and thoughts... ;)


Function CalculateTradeProfitInPips(int type)
I know that you don't really use this Function actively anywhere in your Code. But it is still there and therefore I thought I check this up with you.

In the call of the Function there is a Function Parameter "type" but you don't use this parameter inside your code.
if (OrderType() == OP_BUY)
{
profit = bid - OrderOpenPrice();
}//if (OrderType() == OP_BUY)

if (OrderType() == OP_SELL)
{
profit = OrderOpenPrice() - ask;
}//if (OrderType() == OP_SELL)
Shouldn't the "type" parameter used here instead of the OrderType() Function?


Function GetSwap()
This Function uses only the current Symbol to get the Swap Values. Wouldn't it be better to use GetSwap(symbol) to be more flexible and also usable in multi-pair EA's?

Thanks in advance,

NeoTrader

-
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: My shell EA code

Post by SteveHopwood »

NeoTrader wrote:hi steve,

and again some observations and thoughts... ;)


Function CalculateTradeProfitInPips(int type)
I know that you don't really use this Function actively anywhere in your Code. But it is still there and therefore I thought I check this up with you.

In the call of the Function there is a Function Parameter "type" but you don't use this parameter inside your code.
if (OrderType() == OP_BUY)
{
profit = bid - OrderOpenPrice();
}//if (OrderType() == OP_BUY)

if (OrderType() == OP_SELL)
{
profit = OrderOpenPrice() - ask;
}//if (OrderType() == OP_SELL)
Shouldn't the "type" parameter used here instead of the OrderType() Function?


Function GetSwap()
This Function uses only the current Symbol to get the Swap Values. Wouldn't it be better to use GetSwap(symbol) to be more flexible and also usable in multi-pair EA's?

Thanks in advance,

NeoTrader

-
Yes to both, and thanks. I have made the changes and uploaded to post 1 for the benefit of others taking notice of what is happening here.

Note that I do not use the shell for coding multi-pair ea's. I usually adapt one of the existing multi-pair bots instead. I rarely code a multi-trader and so do not have a multi-trader shell. This shell is intended for adaptation for single-pair use.

Doesn't stop me accepting contributions that make it more flexible, so many thanks again.

By the by, I have received your pm and am not ignoring it. I have been engaged on a project today, and an upcoming 'new toy' pm will explain.

:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

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

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
NeoTrader
Trader
Posts: 436
Joined: Wed Apr 04, 2012 2:52 pm
Location: small Village at Lake Chiemsee, Bavaria, Germany

Re: My shell EA code

Post by NeoTrader »

Hi Steve,

found another thingy that got some bells ringing.

Function JumpingStopLoss()

Line2007 if (Bid >= sl + ((JumpingStopPips * 2) / factor) )//George{

Line2024 if (Bid <= sl - ((JumpingStopPips * 2) / factor) )//George

Can you tell me why you multiply the JumpingStopPips with 2 here?

Thanks in advance,

happy trading,

NeoTrader
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: My shell EA code

Post by gaheitman »

NeoTrader wrote:Hi Steve,

found another thingy that got some bells ringing.

Function JumpingStopLoss()

Line2007 if (Bid >= sl + ((JumpingStopPips * 2) / factor) )//George{

Line2024 if (Bid <= sl - ((JumpingStopPips * 2) / factor) )//George

Can you tell me why you multiply the JumpingStopPips with 2 here?

Thanks in advance,

happy trading,

NeoTrader
If the JSL is set for 40, it has to move 80 before it jumps 40. It basically locks in half of the move every time we have 2 x JumpingStopPips of room between SL and price.

George
User avatar
NeoTrader
Trader
Posts: 436
Joined: Wed Apr 04, 2012 2:52 pm
Location: small Village at Lake Chiemsee, Bavaria, Germany

Re: My shell EA code

Post by NeoTrader »

Hi George,
gaheitman wrote:If the JSL is set for 40, it has to move 80 before it jumps 40. It basically locks in half of the move every time we have 2 x JumpingStopPips of room between SL and price.
Ahhh...ok...now I understand...it's logical...didn't visualized it right in my brain...

Thanks again,

happy trading,

NeoTrader

-
Post Reply

Return to “Coders Hangout”