Please help: Place ATR Stop Loss?
-
Hi everyone!
I am trying to create an EA that buys (sells) when the price breaks above (below) the highest high (lowest low) of X previous days.
I am curenlty having 2 problems:
-
I am trying to include a trend filter so that the trade is placed only if the fast SMA is above (below) the slow SMA. However in the EA I have built there are some sell trades that are placed against the trend (i.e. when the fast SMA is above the slow SMA) - see screenshot. Would anyone be able to tell me where i went wrong?
-
I would like to place a stop loss based on [(highest high of X days) - 3x ATR] or [(lowest low of X days) + 3x ATR]. I have tried a few solutions, but cannot seem to make it work. Does anyone have suggestions?
Thanks a lot!
EA: https://fxdreema.com/shared/zeFLoMrCd

-
-
in blocks where you compare MA, you compare null candle, it means that as time goes this flight up and down and can cross and not cross, you can try compare candle 1 (More Settings - Candle ID in block for comparison).
Be sure, that you have same period in EA like in chart for visualization results
check what happens with visual tester mode -
What if you backtest on Daily and you don't use block 1. If it's the same.. well, maybe at the time the conditions were true. If you want to see everything at this particular moment when the Sell is created, you can put "Terminate" immediately after the sell block and the EA will stop there. Or use "Delay" (but edit its settings so it can pause the EA while backtesting) and in Visual mode you can see exactly what is going on at the moment

-
__in blocks where you compare MA, you compare null candle, it means that as time goes this flight up and down and can cross and not cross, you can try compare candle 1 (More Settings - Candle ID in block for comparison).
Be sure, that you have same period in EA like in chart for visualization results
check what happens with visual tester mode[/quote:2rinftm2]Hi miro1360, thanks for the suggestion. I shall try it and let you know

-
__What if you backtest on Daily and you don't use block 1. If it's the same.. well, maybe at the time the conditions were true. If you want to see everything at this particular moment when the Sell is created, you can put "Terminate" immediately after the sell block and the EA will stop there. Or use "Delay" (but edit its settings so it can pause the EA while backtesting) and in Visual mode you can see exactly what is going on at the moment :)[/quote:1yknj4ew]
Hi! Thank you for the input

The conditions shown in the screenshot are already the 'correct' conditions, if you will - i.e. Daily chart with 50 SMA and 100 SMA, but as you can see, the entry point for the sell trade does not seem correct...Would you also have any suggestions on how to implement the ATR stop loss? For example, for a buy order I am trying to set an an initial stop loss = (Entry price) - (3 x ATR) , when the 10-day lowest low becomes higher than the stop loss, I would like this to become the exit point....if it makes sense...
I have tried many different possibilities, but cannot seem to get it right. This is what I have now https://fxdreema.com/shared/boFwQ4rMb
Cheers guys!
-
In 14 and 22, will it work if you use < and >
Block 32 like that... check this one: https://fxdreema.com/demo/mt4-loop-how-it-works
-
__In 14 and 22, will it work if you use < and >
Block 32 like that... check this one: https://fxdreema.com/demo/mt4-loop-how-it-works[/quote:3dvs59po]
Hi fxdreema, thanks for your suggestion! I see m to have solved the first problem
However, I still cannot understand how to set a stop loss for a buy order = candle high - 3xATR
I have tried like you suggested (block 36, 38, 45, 46 ,47) but by backtesting it I can see it is not working as supposed (see screenshot) - do you have any ideas of where I could be going wrong?
https://fxdreema.com/shared/pDctZiDGcThanks

-
Be careful with these words - price level, pips, price fraction. This variable "SL_buy" contains price level value, but then in block 46 this variable is used for "Custom (pips)". Try this instead: http://prntscr.com/bu5v10
-
__Be careful with these words - price level, pips, price fraction. This variable "SL_buy" contains price level value, but then in block 46 this variable is used for "Custom (pips)". Try this instead: http://prntscr.com/bu5v10[/quote:3l6hdyj9]
Thanks!! seems to be working better

But is not quite there yet, I cannot understand why it draws the Stop Loss on the last candle, rather than on the entry candle https://fxdreema.com/shared/uB2iAc00dI have set "candle ID"=1 with respect to the open price, in bloc 38 but it is not working as i would like...
Would you please be able to suggest how to edit it?......
Screen Shot 2016-07-18 at 21.49.38.png
Screen Shot 2016-07-18 at 21.51.54.png -
If I understood this right, you want to modify your stop just once. Now the bot modifies it on every tick though, and so forgets about your open bar as time passes.
Use "check stop-loss" (needs to equal 0) and modify the stop only then. -
__If I understood this right, you want to modify your stop just once. Now the bot modifies it on every tick though, and so forgets about your open bar as time passes.
Use "check stop-loss" (needs to equal 0) and modify the stop only then.[/quote:17xwgd3b]Thanks
exactly what I was looking for!!