• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 6:40am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 6:40am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Closing all trades coding 3 replies

little help wanted with coding arrows 0 replies

Little coding help needed.. 1 reply

Need your opinion on trades not closing 4 replies

A little help with coding 3 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe

Need a little help on coding about closing trades

  • Post #1
  • Quote
  • First Post: Feb 15, 2012 11:34pm Feb 15, 2012 11:34pm
  •  Fourxxxx
  • | Joined Sep 2009 | Status: Member | 174 Posts
I am trying to add a modification to an EA to close close trades when Nonlagma_V7 changes colour. I can get it to work in a small test EA but for some reason I can't get it to work where I need it.

Buffer 3 = 1 for trend up and -1 for trend down.
nTrdL & nTrdS add 1 with each addition trade opened as price goes up/down.
If I can change to if (nTrdL>=2)y=ExitTrades..... the trades close with no problem.
PHP Code
 bool CloseNhedgeL=false;

bool CloseNhedgeS=false; 
PHP Code
 double Nontrend=iCustom(Symbol(),0,"NonLagMA_v7",Price,Length,Displace,PctFilter,Color,ColorBarBack,Deviation,SoundAlertMode,3,1);    

    
if (
nTrdL>0&&Nontrend<0)CloseNhedgeL=true;
               if(
y==0)
            {
               if ((
CloseNhedgeL==true)&&nTrdL>=2)y=ExitTrades(H,DarkViolet,"NHedge Profit Lock Activated",ThO); //Madness
               
nTrdS=0;
         }
if (
nTrdS>0&&Nontrend>0)CloseNhedgeS=true;
          if(
y==0)
         {
            if ((
CloseNhedgeS==true)&&nTrdS>=2)y=ExitTrades(H,DarkViolet,"NHedge Profit Lock Activated",ThO); //Madness
            
nTrdL=0;
        } 
I am sure it something simple but I am a new beginner to coding EA's so any pointers would be appreciated. I have tried paying people to do this for me but keep ending up with quick and dirty short cuts.

Thanks Fourxxxx
  • Post #2
  • Quote
  • Feb 16, 2012 2:40am Feb 16, 2012 2:40am
  •  Fourxxxx
  • | Joined Sep 2009 | Status: Member | 174 Posts
Quoting nubcake
Disliked
no it makes it your problem. no more help for you. it's no skin off my nose.
Ignored
Doesn't matter I got it working and your suggestion made no difference what so ever.

Here is some code from MQL4.com documentation.

"if (Bid > MA && Fact_Up == true)"

So much for "ALWAYS use brackets"
 
 
  • Post #3
  • Quote
  • Feb 16, 2012 5:08am Feb 16, 2012 5:08am
  •  Xaphod
  • Joined Mar 2010 | Status: Member | 1,380 Posts
Try indenting your code properly. That would entice more people to offer you help and possibly make the code logic clearer for yourself.

http://en.wikipedia.org/wiki/Indent_style
 
 
  • Post #4
  • Quote
  • Last Post: Feb 16, 2012 6:10am Feb 16, 2012 6:10am
  •  Fourxxxx
  • | Joined Sep 2009 | Status: Member | 174 Posts
Quoting Xaphod
Disliked
Try indenting your code properly. That would entice more people to offer you help and possibly make the code logic clearer for yourself.

http://en.wikipedia.org/wiki/Indent_style
Ignored
Thanks for the suggestion, I have worked it out now anyway.
 
 
  • Platform Tech
  • /
  • Need a little help on coding about closing trades
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2022