|
Simple SMA strategy, to be enhanced later on |
Simon_Harritz
|
Post subject: Simple SMA strategy, to be enhanced later on |
Post rating: 0
|
Posted: Sat 10 Oct, 2015, 19:51
|
|
User rating: 0
Joined: Mon 06 Jul, 2015, 16:52 Posts: 14 Location: DenmarkDenmark
|
Hi
I seem to keep running into creating strategies that does not open positions. This simple SMA strategy is supposed to do the following
1: Only have one position open 2: Check if the SMA runs through a candle 3: if 2 is yes, then check if the candle is red or green 4: open buy on green and sell on red candle.
But i must have made an error, as the strategy never opens a position.
When this part works im planning on putting a safety on the trades that goes bad so that the strategy opens a hedge position, with a number of trades^2 in 0,001 units (smallest trade possible). This means that first trade going the wrong way to a certain predefined lvl (say +10pips for all buy and -10 pips for all sell) makes the strategy open a hedge for 0,004 units (2^2), if that goes wrong it opens another hedge for 0,009 (3^2).
Hope you have some hints on the above problem.
Attachments: |
Simple_SMA_Strategy.vfs [34.57 KiB]
Downloaded 142 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.
|
|
|
|
|
 |
amine_chourou
|
Post subject: Re: Simple SMA strategy, to be enhanced later on |
Post rating: 0
|
Posted: Mon 12 Oct, 2015, 14:46
|
|
Visual JForex expert at Dukascopy |  |
User rating: 288
Joined: Thu 18 Apr, 2013, 09:26 Posts: 1496 Location: Switzerland, Geneva
|
1/ The default instrument is set to "Not equal" to the candle instrument. Thus, the flow is blcoked. 2/ The number of open positions check: In your IF block you're comparing a variable (Position_Amount) which you created but this variable doesn't have any value as it simply a static variable that doesn't get updated with any action. In other words, it is the same as creating a variable X that has a position type and not attaching it to any "dynamic" command and then comparing it to the value 0. and as this variable will never get updated (or even getting assigned with a start value) it will trigger an error because the system cannot compare "Unkown" to the number 0. You need to use in this case the ready-made variable "Open Positions: Position Amount" and compare it to 0 3/ Then comes your 2 IF conditions circled below that are in contradiction and will never get the flow go through  4/ You need also to pay attention to the logic of the strategy: If the candle is green <--> Open < Close and if you want the EMA to be in : Open <EMA<Close If the candle is Red <--> Open > Close ----------------------------------- OPen >EMA > Close Hope things are clearer now !
Attachments: |
Simple_SMA_scnsht.png [172.33 KiB]
Downloaded 448 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.
|
|
|
|
|
 |
Simon_Harritz
|
Post subject: Re: Simple SMA strategy, to be enhanced later on |
Post rating: 0
|
Posted: Mon 12 Oct, 2015, 15:45
|
|
User rating: 0
Joined: Mon 06 Jul, 2015, 16:52 Posts: 14 Location: DenmarkDenmark
|
Thank you very much  Ill be checking to see if I can fix that. One does feel rather stupid when dealing with programming sometimes. I guess I had stared myself blind to those errors.
|
|
|
|
 |
amine_chourou
|
Post subject: Re: Simple SMA strategy, to be enhanced later on |
Post rating: 0
|
Posted: Mon 12 Oct, 2015, 16:09
|
|
Visual JForex expert at Dukascopy |  |
User rating: 288
Joined: Thu 18 Apr, 2013, 09:26 Posts: 1496 Location: Switzerland, Geneva
|
Hi ! No worries at all ! Once you get it you'll keep on going 
|
|
|
|
 |
Simon_Harritz
|
Post subject: Re: Simple SMA strategy, to be enhanced later on |
Post rating: 0
|
Posted: Wed 14 Oct, 2015, 13:22
|
|
User rating: 0
Joined: Mon 06 Jul, 2015, 16:52 Posts: 14 Location: DenmarkDenmark
|
I have been working more on the strategy.
After getting the historic candle and sma, the first if is now whether the candle is red or green.
Second section of if´s is on whether the sma is lower than the candle high, and higher than candle low (it wont work to use candle open and close here, as a red candle may have a higher open and lower close than sma and still cross this). By using candle high/low this problem is overcome.
But alas, something is still preventing the strategy from opening positions. Also do I need to use the loop viewer on this?
Attachments: |
Simple_SMA_Strategy.vfs [34.14 KiB]
Downloaded 146 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.
|
|
|
|
|
 |
amine_chourou
|
Post subject: Re: Simple SMA strategy, to be enhanced later on |
Post rating: 0
|
Posted: Wed 14 Oct, 2015, 16:12
|
|
Visual JForex expert at Dukascopy |  |
User rating: 288
Joined: Thu 18 Apr, 2013, 09:26 Posts: 1496 Location: Switzerland, Geneva
|
Hi, Working with highs and lows make sense as the EMA should indeed cross in between these levels i.e low < EMA < High The error come from the first condition where you are saying IF open positions is greater than 1 which is never the case as a start phase. Correcting this to Less (meaning If no open positions) then the flow goes on and IF greater or equal to 1 than the flow is blocked.
Cheers
|
|
|
|
 |
Simon_Harritz
|
Post subject: Re: Simple SMA strategy, to be enhanced later on |
Post rating: 0
|
Posted: Sat 17 Oct, 2015, 15:25
|
|
User rating: 0
Joined: Mon 06 Jul, 2015, 16:52 Posts: 14 Location: DenmarkDenmark
|
Thanks, it works now, I was so certain that the error had to be in the more complex parts of the strategy 
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|