molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Thu May 09, 2024 4:11 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: negative value input when attaching EA
PostPosted: Wed Jun 06, 2012 10:21 pm 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
I see here that double can handle negative numbers: http://book.mql4.com/basics/types. So... can I input a negative value as a MetaTrader Variable created in SB (when I attach the EA to a chart)?

This works fine when I assign the negative value directly in a TA block:

if ( ( iCustom(Symbol(),0,"NzdUsdm_AudUsdm",0,0) <= -0.01000 ) && (CalculateOpenPositions("AUDUSDm",OP_SELL,MagicNumberShort)<=4) )
{ SELL("AUDUSDm",S_AUDUSD_LS_4,S_AUDUSD_TP_4,S_AUDUSD_SL_4,S_AUDUSD_TS_4,"if ( ( iCustom(Symbol(),0,NzdUsdm_AudUsdm,0,0) <= -0.01000 ) && (CalculateOpenPositions(AUDUSDm,OP_SELL,MagicNumberShort)<=4) )") ;}

But the condition is ignored (EA enters all shorts immediately upon attachment to a chart) when I use a MetaTrader Variable in a TA+ block (and then input the negative value later):

if ( ( iCustom(Symbol(),0,"NzdUsdm_AudUsdm",0,0) <= iAC(Symbol(),0,EntryLevel5) ) && (CalculateOpenPositions("AUDUSDm",OP_SELL,MagicNumberShort)<=4) )
{ SELL("AUDUSDm",S_AUDUSD_LS_0,S_AUDUSD_TP_0,S_AUDUSD_SL_0,S_AUDUSD_TS_0,"if ( ( iCustom(Symbol(),0,NzdUsdm_AudUsdm,0,0) <= iAC(Symbol(),0,EntryLevel5) ) && (CalculateOpenPositions(AUDUSDm,OP_SELL,MagicNumberShort)<=4) )") ;}

[update: I rebuilt the imported indi in TIB to read positive and reversed my conditions in SB--same result]. Any ideas?

_________________
I'm not a programmer, but I play one on TV.


Top
 Profile  
 
 Post subject: Re: negative value input when attaching EA
PostPosted: Thu Jun 07, 2012 9:01 am 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
The 2 logics are not the same:
- ( iCustom(Symbol(),0,"NzdUsdm_AudUsdm",0,0) <= -0.01000 ) is not
- ( iCustom(Symbol(),0,"NzdUsdm_AudUsdm",0,0) <= iAC(Symbol(),0,EntryLevel5)
In a TA plus you can do ( iCustom(Symbol(),0,"NzdUsdm_AudUsdm",0,0) <= EntryLevel5)


Top
 Profile  
 
 Post subject: Re: negative value input when attaching EA
PostPosted: Thu Jun 07, 2012 9:31 am 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
:oops: I now see that I failed to select User Defined Number in the TA+ block, so the Accelerator/Decelerator Oscillator was defaulted to. Thank you.

_________________
I'm not a programmer, but I play one on TV.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009