Dukascopy
 
 
Wiki JStore Search Login

Help with MA strategy-explanation inside
 Post subject: Help with MA strategy-explanation inside Post rating: 0   New post Posted: Wed 29 Jun, 2016, 12:16 
User avatar

User rating: 0
Joined: Wed 23 Mar, 2016, 21:17
Posts: 7
Location: Czech RepublicCzech Republic
I have uploaded my starting work on a strategy. I thought I could finish it but there is an important problem I've come across. Here is the explanation of the strategy first:

The user can select two EMA lengths, say 50 and 150. At any one point one MA will be above the other MA. The strategy is simple: Buy when price goes even one pip above the MA that is on top, and sell when price goes below the lower MA.

So the first thing I do in the strategy is to distinguish which MA is where. Still however, I have a problem because the way I have it right now it will go into a buy order if the price is just above the top MA for example. I want to go into a buy order if the price was below the top MA, and then crossed it. I am using the OnTIck event, this is why this is a problem. But I don't want to use the OnBar event, because I want to catch intraday movements on the daily. So I can't wait for the current bar to finish to check where my MA's are with respect to price.

I hope this all makes sense. And I can of course answer questions if something is not clear. If someone can help me I would be very grateful.


Attachments:
BuySellOffMAs.vfs [23.11 KiB]
Downloaded 132 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Help with MA strategy-explanation inside Post rating: 0   New post Posted: Wed 29 Jun, 2016, 15:49 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Hi,

thanks for reaching out in this forum !
First of all, any block that is not linked to a start point is not considered by the the strategy at all. So you have to link all your blocks (is serial way or in parallel).
Second, the indicators are built in away to use candle periods. So the minimum period that a candle could take is 10 sec but the update frequency of its output cans be on tick basis. check the attached example and you'll see that indicators are calculated on 10 sec and updated on tick basis as they are linked to OnTick method.

I think this can meet your requirements, up to you to fine tune the conditions ...

ps: I've added a condition to limit the number of opened orders and changed the SL and TP values for testing purpose. feel free to adjust these as per your needs.


Attachments:
BuySellOffMAs_V2.vfs [24.29 KiB]
Downloaded 128 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Help with MA strategy-explanation inside Post rating: 0   New post Posted: Wed 29 Jun, 2016, 16:16 
User avatar

User rating: 0
Joined: Wed 23 Mar, 2016, 21:17
Posts: 7
Location: Czech RepublicCzech Republic
amine_chourou wrote:
Hi,

thanks for reaching out in this forum !
First of all, any block that is not linked to a start point is not considered by the the strategy at all. So you have to link all your blocks (is serial way or in parallel).
Second, the indicators are built in away to use candle periods. So the minimum period that a candle could take is 10 sec but the update frequency of its output cans be on tick basis. check the attached example and you'll see that indicators are calculated on 10 sec and updated on tick basis as they are linked to OnTick method.

I think this can meet your requirements, up to you to fine tune the conditions ...

ps: I've added a condition to limit the number of opened orders and changed the SL and TP values for testing purpose. feel free to adjust these as per your needs.


Thank you very much for the help. So I see that the MA's are calculated on the 150 and 50, 10 second candle periods. Would it be possible to calculate in that small time period the daily 150 and 50 MA's instead? And then be checking if the current price exceeded these MA's on the 10 second candles?


 
 Post subject: Re: Help with MA strategy-explanation inside Post rating: 0   New post Posted: Thu 30 Jun, 2016, 12:39 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Hi,

Yes indeed ! Simply change the MA period to daily and plug it directly to the OnCandle Start: The result is a daily MA checked every minimum candle length which is obviously 10 sec
Cheers


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com