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 Fri May 10, 2024 2:55 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How to use negative numbers in molanis strategy
PostPosted: Mon Jul 23, 2012 8:09 am 
Offline

Joined: Mon Jul 23, 2012 7:49 am
Posts: 1
Hello , just purchased the software but the EA , i would like to build has got negative numbers to be used, forexample Moving Average Shift=-2,
whenever, i try to type in this figure(-2) if i place ok button, it just goes back ton Zero.
Was the software designed not to be used with negative numbers?

I will be so grateful ,if i am rendered due assistance.
Thank you


Top
 Profile  
 
 Post subject: Re: How to use negative numbers in molanis strategy
PostPosted: Sat Jul 28, 2012 9:43 am 
Offline
Site Admin

Joined: Fri Oct 16, 2009 3:40 pm
Posts: 451
Shift is used as an index for the bars, in simple terms to select a current or previous bar. If shift=0 you get the current bar, if shift=1 you get the previous bar. Shift does not use negative numbers - for previous bar use 1


Top
 Profile  
 
 Post subject: Re: How to use negative numbers in molanis strategy
PostPosted: Sat Jul 28, 2012 12:18 pm 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
Ah, the negative shift saga continues...

Let's try and put this issue to bed. Looking at this chart we can all see that the magenta line is a current MA aligned with the current price bar. Both the MA value and the price value are truly in step with each other in time.
Attachment:
0.gif
0.gif [ 19.42 KiB | Viewed 3099 times ]


In the next chart, the MA is shifted by 5 bars. We can see easily enough that the current MA value is offset by 5 (nonexistent) price bars out into the future--meaning the MA value from 5 bars ago is, by definition, at the current price bar.
Attachment:
5.gif
5.gif [ 19.5 KiB | Viewed 3094 times ]


Looking at our final chart, the MA is shifted by -5 bars. The current MA value is offset by -5 price bars into the past--meaning the current MA value is at 5 bars in the past.
Attachment:
-5.gif
-5.gif [ 19.38 KiB | Viewed 3107 times ]


Pay paticular attention to the last chart. All shift -5 is doing is allowing us to visually compare a 5 bar old price to the current MA. When we restate the comparison like this, the solution is simple--shift our price (Close, Bid, etc.) by 5 and leave the MA current to get the same result! In fact, if we were to black out our chart candles, build a new candle indicator shifted by 5, and overlay the current MA; we would see that the last 5 candles would be missing and we would have the same visual comparison.

If you insist on shifting your indicator, this is possible via:

Hard coding a custom indicator's mql4 code to shift -5 permanently, or
Setting a custom indicator's input parameter to shift -5 upon import into SB. Note that this is different than merely selecting iMA in SB where shift -5 will not work.

_________________
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