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 17, 2024 1:47 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Simulated Testing using MT4 ST & Stop Loss
PostPosted: Wed Dec 12, 2012 2:59 am 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
Hi,

I have an enquiry about doing simulated testing using the Strategy Tester of MT4 combined with either of Molanis products.

At present from my understanding the Strategy Builder either can be programmed to send an alert or trade. We can't seem to send alerts using the Custom Indicator builder.

If I build a strategy, say built as a custom indicator, and then it's imported in the Strategy builder through iCustom(), with trade and not alert. Running this through the Strategy Tester (ST), the EA will just run across the period in time I select for it to run.

What comes to mind is this as a preferred approach:

1. strategy conditions are met;
2. Alert is sent to stop everything for a decision to be made;
3. After decision made, then execute the BUY or SELL.

This is then more like a simulated test environment in real time without knowing what the market will do ahead in time using MT4 past data.

Normally with 3. a final decision to make before taking a trade or not, is after doing support / resistance, candle formation analysis etc ... I'm still trying to code this part using Molanis, which I was planning to add using the MQL block as a final sequence or even built through Custom Indicator builder then add in Strategy Builder as iCustom final sequence before using a BUY or SELL block

Right now the custom indicator builder does not send alerts.

The other issue I have is setting the STOP LOSS based on the most recent high or low analysis depending on direction to trade. The BUY/SELL/BUYP/SELLP have inputs for a defined SL value only.

I can't see how I can do this at present :?:

Perhaps someone can share some thoughts on these.

Thank You


Top
 Profile  
 
 Post subject: Re: Simulated Testing using MT4 ST & Stop Loss
PostPosted: Wed Dec 12, 2012 10:52 am 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Quote:
Right now the custom indicator builder does not send alerts

You are right. It does not show alerts.

Quote:
2. Alert is sent to stop everything for a decision to be made;

Do you mean stopping the ea waiting for the user input to define if the trade is taken? The builder will not do that. You can add code on your own to do it - maybe using a yes/no window


Top
 Profile  
 
 Post subject: Re: Simulated Testing using MT4 ST & Stop Loss
PostPosted: Wed Dec 12, 2012 6:21 pm 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
Quote:
Quote:
2. Alert is sent to stop everything for a decision to be made;

Do you mean stopping the ea waiting for the user input to define if the trade is taken? The builder will not do that. You can add code on your own to do it - maybe using a yes/no window


Yes in effect that's what I mean. Which portion of the code to edit from the Strategy Builder ? Around the part where the MolanisAlert() is sent ?

What about this part

3. The other issue I have is setting the STOP LOSS based on the most recent high or low analysis depending on direction to trade. The BUY/SELL/BUYP/SELLP have inputs for a defined SL value only. I can sort out the part to find the most recent high or low using the custom indicator builder and import in strategy builder before the BUY/SELL/BUYP/SELLP modules, but how do I then use this to have a stop loss based on that when trade is taken ? Is this supported at this stage ? With this set, then within the BUY/SELL/BUYP/SELLP modules, then I can use the trailing stop part as needed. I was thinking a similar analogy with the take profit based on the stop loss calculated, i.e 1:1 ratio etc ... for TP.

Thank You


Top
 Profile  
 
 Post subject: Re: Simulated Testing using MT4 ST & Stop Loss
PostPosted: Thu Dec 13, 2012 4:40 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Unfortunately adding the code is not an easy task. You will need to find the part that trades and then move the alert just before that, and add code to manage your yes/no.

The builder only uses fixed stops. In the next version we will have more types of stops. I am uncertain if the beta will be live in Dec or early January. We will post some news next week in the forum


Top
 Profile  
 
 Post subject: Re: Simulated Testing using MT4 ST & Stop Loss
PostPosted: Tue Aug 13, 2013 6:51 am 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
I have an extra question on the matter of stop loss. At present it's specified in pips value and later from what I can see in code, ExecuteOrder() and ExecuteOrderinTwo() converts it the stop loss as follows

Quote:
stoploss_bn = NormalizeDouble(price_bn-stoploss_bn*points_bn, digits_bn); [for buy]
stoploss_bn = NormalizeDouble(price_bn+stoploss_bn*points_bn, digits_bn); [for sell]


after which it's checked by CheckStopLoss().

If I want to use my own stops that is dynamycally calculated using specific price action and other indicators combinations, which returns a value in 4 or 5 digit format, is it safe for me to replace the the above quotation with my own calculations?

Will this break CheckStopLoss() ?

I am thinking the same thing for take profit, rather than using a hardcoded pips value, to overwrite the code, to use a dynamic value as per market at the point in time it opens.

Right now I can't see how I can use two different take profit levels from the same order ticket generated.

I hope this will be given some consideration in the present beta release.

Thank You


Top
 Profile  
 
 Post subject: Re: Simulated Testing using MT4 ST & Stop Loss
PostPosted: Tue Aug 13, 2013 8:48 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
For new questions please start a new thread.
Yes you can use your own calculation but you need to be consistent with the existing coding. For example in the code you posted the sl is not in pips, also the 4 - 5 digits has been dealt with before
If you are consistent you will not break it


Top
 Profile  
 
 Post subject: Re: Simulated Testing using MT4 ST & Stop Loss
PostPosted: Tue Aug 13, 2013 9:14 pm 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
sl I want to use will be a 4 or 5 digit value and not pips, and why i had to look in code where the conversion from pips to price point digits is being done. sounds like I have the correct place to put my calculations and comment the calculations below. will give it a go and see what happens.


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