"complex" formula
-
Hello,
i'm trying to create an EA with the trigger to close a position being based on the following rules: when the stochastic oscillator crosses above 20, then take the highest close of the previous 10 candles and subtract 3*average true range OF THAT CANDLE and use the resulting value as the trigger. So in formula form:
S>20 --> C= H-(3*ATR)
Where:
S = Stochastic oscillator
C = trigger to close the position
H = highest close of previous 10 candles
A = Average True Range of candle HHow would i put something like this in fxdreema?
Thanks a lot in advance.
-
S>20 --> C= H-(3ATR)
Where:
S = Stochastic oscillator
C = trigger to close the position
H = highest close of previous 10 candles
A = Average True Range of candle H*H - custom code block - here you fill some double variable, like: myHighest=iHighest(Symbol(),Period(),MODE_HIGH,10,1);
A - for this I have not understand what exactly you need, if ID from this candle - you can get it with custom block and function to write into variable like: myHighestID=iHigh(NULL,Period(),10); ... and after this you can use this known candle ID to compute ATR or whatever you need ... after this you can work with your formula and filled variables in custom block ...
maybe it goes with other ways, you must try it
-
In Condition (or Formula), somewhere in "Market Properties" you can get the highest value out of few candles in the past. I guess you know how to use indicators. The rest is calculations. Maybe it's better to use Formula block, which does very basic calculation. But it's also possible to work with variables, and there are other ways as well. I don't know what exactly to recommend. Check these examples here: https://fxdreema.com/examples/#Constants-and-Variables
-
Hi and thanks for the responses. My problem isn't really solved however, perhaps because i may not have been clear about what exactly i want my EA to do.
So if i have an open position, i want it to look at the stochastic oscillator: when it reaches a certain threshold, look for the highest close in the last 10 candles. Then if for instance candle 4 had the highest closing value, i then want to subtract the average true range (ATR) of candle 4. If it was candle 6 i would subtract the ATR of candle 6 and so on.
So i can't seem to find the correct block to achieve this goal. If there is no block that can do this, i'd have to think of something else as i am no programmer and have no programming experience whatsoever...

Again, thanks for the help and looking forward to any responses.
-
It's not 1 block, but few Condition blocks and maybe Formula. These blocks are pretty simple, they do one thing only, but when you connect them in proper way, they all do the complex thing