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 Sun May 19, 2024 2:10 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Creating Custom Indicators and then using them in the EA
PostPosted: Mon Sep 26, 2011 2:58 am 
Offline

Joined: Wed Jul 27, 2011 6:22 am
Posts: 14
I am looking at Buying when the close of the bar is less than 5% from the high of the bar and other confirmations are met (opposite will apply for a sale but have excluded for now)
I will enter 6 pips above the close of the recently close bar to confirm that prices have continued in the expected direction
To do this I have created 2 Custom Indicators
1. Creates a value against which I can compare the close to ensure the close and High are within 5%
2. Created a value eual to the close shift 1 plus 6 that becomes the entry for the trade if reached

When creating the Custom Indicators in Molanis I have used high(i) but when in the EA builder I have used shift 2 for the custom indicator when doing the comparisons and calculating the entry price as I understand i (Closei, Openi etc) in Molanis Custom Builder is the current bar for calculating the indicator but Shift 2 is used in the Molanis EA creater (this item is unclear to me and would appreciate further explanations)

As I understand it I only have to move the EA to the chart and not any Custom indicators.

Please confirm I have understood things correctly and/or advise what I should do.

Also please advise if what I have done is the most efficient way to do what I want to do or if there is a better approach – its a learming and practice approach

Thanks


Attachments:
902 Shaved bar Buy.mol [7 KiB]
Downloaded 415 times
ShavedHighTest.moi [1.47 KiB]
Downloaded 441 times
Top
 Profile  
 
 Post subject: Re: Creating Custom Indicators and then using them in the EA
PostPosted: Tue Sep 27, 2011 2:44 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
To fully understand shift read this viewtopic.php?f=8&t=162
In plain English, use:
shift = 0 to get the indicator's value of the current bar (still forming)
shift = 1 value on the previous bar
shift = 2 value in a bar before the previous bar
In your case, using Close[i] in the indicator formula will mean the current bar is used when doing the calculation. In the strategy builder you need to use shift 1 to get the indicator's value in the previous bar if you trade bars. Shift 0 if you trade ticks. I would trade using the previous bar since trading the current bar may give you false signals - high and lows of the current bar are temporal, the real high and low is know after the last tick is received and a new bar starts.
Your indicator Low[i]+((High[i]-Low[i])*0.95) does not have the logic you mentioned.
Do not use = in your comparions. Prices jump so you need to use > or <
If you want all the conditions to be evaluated at the same time, you need to connect them with and AND
I think You are on the right track.


Top
 Profile  
 
 Post subject: Re: Creating Custom Indicators and then using them in the EA
PostPosted: Fri Oct 07, 2011 4:56 am 
Offline

Joined: Wed Jul 27, 2011 6:22 am
Posts: 14
I am still having problems with this. I will state my understanding below. Please advise which nos if any are wrong and what it should be. This is tricky for me being an Accountant not a programmer

1 I want to buy order if the price closes above say the 20 ema and continues to move upwards after the close of the last bar by 6 pips or more. I have entered a fixed lot size, target and stop for now
2 I create a custom indicator as below
Custom Indicator name - "Inside bar entry"
Formulae - Close[i]+6
3 when I create the EA i say
iclose shift 1 > 20ema shift 1
ibid shift 0 > iCustom "inside bar entry" shift 1
4 I have to put in a mode to indicate which one should be used - I don't know where to get this

Files are attached


Attachments:
850 Inside Bary Entry.moi [1.43 KiB]
Downloaded 415 times
850 Inside Bar Trade.mol [5.64 KiB]
Downloaded 394 times
Top
 Profile  
 
 Post subject: Re: Creating Custom Indicators and then using them in the EA
PostPosted: Fri Oct 07, 2011 6:10 am 
Offline

Joined: Wed Jul 27, 2011 6:22 am
Posts: 14
Please find corrected EA - I did not save it before sending it.

Also as I am checking on the current forming bar for the entry price I have enter execute on current tick. Please confirm this is correct

Thank You
Geoff


Attachments:
850 Inside Bar Trade.mol [5.63 KiB]
Downloaded 391 times
Top
 Profile  
 
 Post subject: Re: Creating Custom Indicators and then using them in the EA
PostPosted: Sat Oct 08, 2011 12:03 am 
Offline

Joined: Wed Jul 27, 2011 6:22 am
Posts: 14
Hi

On checking the Indicator Builder manual I read where the mode is used when there is more than 1 indicator line. Where there is only 1 the mode is 0. I have made this change.

I also read that Shift should be
0 if referring to the current unclosed bar
1 if referring to the last close bar
2 if referring to the bar 2 bars back from the current open bar
etc

I also amended the Trading Block Execution mode to Completed bars after reading the Shift information

I also added a trend check so I only Buy in an Uptrend ( 20 ema > 50 ema) and only Sell in a Downtrend ( 20 ema < 50 ema)

The strategy is called Price Action Inside Bar outlined below

When a bar closes is fully inside the previous bar ( High to Low) it is called an inside bar.

There are three bars

A Bar - Reference Bar
B Bar - The Inside Bar
C Bar - The current Open Bar

TA - Buy if

Open of B Bar < Open of A Bar and
Close of B Bar > Close of A Bar and
It is an Uptrend 20 ema > 50 ema on B Bar and
Entry 6 pips above the close of the A Bar ( to confirm move is continuing)
Close if Bid < the close of the A Bar
Target as entered

Opposite for Sell

Please review my Custom Indicator and EA and confirm if I have done it correctly or advise if there is something wrong or can be done better ( Is there a better or more accurate way to confirm trading with the trend

Thank You
Geoffinaus


Attachments:
855 Inside Bar Trade.mol [16.38 KiB]
Downloaded 410 times
Top
 Profile  
 
 Post subject: Re: Creating Custom Indicators and then using them in the EA
PostPosted: Sat Oct 08, 2011 8:14 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
1. The indicator is wrong Close[i]+6 - 6 is given in dollars not pips. It should be Close[i]+0.0006 for EUR/USD (you need to adjust it depending on the pair you want to trade)
Also, when you generate the indicator it tells you which mode to use:
//***Read this first: Integration with Molanis Strategy Builder***
/*To integrate this indicator with Molanis Strategy Builder use the following modes:
Mode 0 = Close[i]+6;
So use mode 0.. (but change 6 with 0.0006)
2. You talk about open and close but your indicators show open and close ???
3. Bid = indicator value is wrong. Prices jump so you cannot use =, you need to use >= or <=
Bid of 1.45672 is not equal to 1.45671 ... and prices may move from 1.45670 to 1.45678 so = shouldn't be used
4. If your expert advisor is not multi timeframe, use current time frame. It's easier that way, you can backtest the ea in any timeframe, and add the ea to any chart - any timeframe

My advice. Test one condition at a time, when you know they work join them in an ea


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 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