Coding help needed

Post Reply
User avatar
LittleCaro
Trader
Posts: 63
Joined: Tue May 19, 2015 7:09 am

Coding help needed

Post by LittleCaro »

Hello all,

I want a little help for coding, i want to know if previous trade was long or short.


So based on this code, i make a bool :

Code: Select all

bool Is previous trade long ()
{

if (OrdersHistoryTotal() == 0) return(false);
   
   for (int cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)
   {
      if (!OrderSelect(cc, SELECT_BY_POS, MODE_HISTORY) ) continue;
      if (OrderMagicNumber() != MagicNumber) continue;
      if (OrderSymbol() != Symbol() ) continue;

But i'm stuck here, how differentiate the longs form the shorts ?

Can someone please could help me to correct my code, thanks a lot !
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.

Coding help needed

Post by SteveHopwood »

LittleCaro » Thu Dec 01, 2016 9:10 am wrote:Hello all,

I want a little help for coding, i want to know if previous trade was long or short.


So based on this code, i make a bool :

Code: Select all

bool Is previous trade long ()
{

if (OrdersHistoryTotal() == 0) return(false);
   
   for (int cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)
   {
      if (!OrderSelect(cc, SELECT_BY_POS, MODE_HISTORY) ) continue;
      if (OrderMagicNumber() != MagicNumber) continue;
      if (OrderSymbol() != Symbol() ) continue;

But i'm stuck here, how differentiate the longs form the shorts ?

Can someone please could help me to correct my code, thanks a lot !
Use the OrderType() function i.e.

Code: Select all

if (OrderType() == OP_BUY) return(true);

//Got this far, so the order was not a buy
return(false);
:xm:
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
LittleCaro
Trader
Posts: 63
Joined: Tue May 19, 2015 7:09 am

Coding help needed

Post by LittleCaro »

Thank you so much Steve !

It's working great !
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

Coding help needed

Post by jjasper7 »

i am trying to write an ea. would someone please tell me how to inform the mq4 platform and the MetaEditer where the Empty4 source and exe files are located? i want to put them in a folder located at 'c:\fx\experts'. and where should i look to find that information?
MathiasJ
Trader
Posts: 146
Joined: Thu Mar 17, 2016 9:39 pm
Location: Sweden

Coding help needed

Post by MathiasJ »

jjasper7 » 07 Dec 2016 09:58 wrote:i am trying to write an ea. would someone please tell me how to inform the mq4 platform and the MetaEditer where the Empty4 source and exe files are located? i want to put them in a folder located at 'c:\fx\experts'. and where should i look to find that information?
You need to put it in the MQL4\Experts folder.
BR
Mathias
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.

Coding help needed

Post by SteveHopwood »

jjasper7 » Wed Dec 07, 2016 7:58 am wrote:i am trying to write an ea. would someone please tell me how to inform the mq4 platform and the MetaEditer where the Empty4 source and exe files are located? i want to put them in a folder located at 'c:\fx\experts'. and where should i look to find that information?
The Cretins at Crapperquotes have taken to hiding the Experts folder away locations impossible to find in Explorer. From your platform, Files/Open data folder will access it.

Add the '/portable' handle to the desktop shortcut forces Empty4 to create the data folder in the location of your chosen Empty4 installation. Right click the desktop shortcut and select Properties. Add '/portable' to the Target field. For example, the Target field for my Blindbot demo:
"C:\Users\piano\Desktop\Trading accounts\Blindbot\terminal.exe" /skipupdate /portable

The '/skipupdate' handle tells Empty4 not to auto-update and is probably irrelevant these days.

:xm:
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.
Post Reply

Return to “Coders Hangout”