How to create double cross MA bot?
-
Ok so for this bot I will use 2 MAs 10 & 20, every time the 10 crosses underneath the 20 BUT then crosses back up a few candles later I want to enter a trade.
How would I go about creating that?
Just to clarify again, for example a buy trade would be the 10 MA crosses below the 20 MA, maybe 6-7 candles later it crosses back up, I would want the bot to enter a buy trade when it crosses back up the 20 MA. The process will be reversed for a sell trade.
-
@gtoat777 You need to use a variable to count candles after the first crossing. Each new candle after that crossing it should be added +1. That you compare that value of thet variable when the opposote crossing happens. Depending if it is higher or lower than the desired value, you condition will occur.
-
@l-andorrà Sometimes it might cross back over from the 2nd candle, sometimes the 4th it varies how would I input that? Also I want it to disregard the trade of it takes more than 6 candles to cross, how would I write a variable for that?
-
@l-andorrà https://fxdreema.com/shared/1SnLGtKze let me know if this is correct
-
-
@jstap Thanks, it’s not so much on a particular number of candles before it crosses back, I’m more focused on the double cross of the MAs because sometimes it could double cross with 3, sometimes 5 and both are still excellent trading opportunities.
Is my initial project for the double croos?
-
@gtoat777 In there your firs condition becomes false when you second becomes true.
In HERE is an updated version, at this point is where you need to decide how many candles you use in each condition, and what conditions you use to reset. the way you had can be use to achieve this but is restricted to what happens on specific candles, or you can use the yellow dot to check different conditions, you will just need a lot of blocks and is not easily changeable in your inputs.
-
@jstap so are you saying to just copy and paste the whole of area 20 or just blocks 73-78? I appreciate the help
-
@gtoat777 Other blocks in there are useful but not connected, 73-90 is what is required to create an EA that does what you require, you have to decide the conditions to use to make the EA, make a start and ask about any problems you are having so things can be assessed.
-
@jstap I'll make an attempt but currently i find the concept of conditions and variables a bit confusing, either way ill roughly do a version and send it over to you for some guidance, again i appreciate the help
-
This is the general concept as you can see the this SELL example, the 10 MA crossed above the 20 and the crosses back a few candles later.
I would like the bot to enter the trade when it crossed back over/down, generally though I don’t care how many candles if anything I would prefer to put a limit meaning if price hasn’t crossed back over within 7 candles then don’t attempt the trade.
So which part in PART 20 that you sent covers which steps
-
https://fxdreema.com/shared/1SnLGtKze Este proyecto no funciona porque la tercera condición depende de la primera y nunca se produciría.
Para que haga lo que quieres hacer tienes que usar el Bloque "Turn on" despues de la segunda condición y dejar apagado el tercer bloque, y cuando se active la tercera condición pones un bloque "Turn Off" para reiniciar todo el programa. Con dos bloques más y separando el tercer bloque lo tienes hecho. -
@nillav Thank you but where are Turn On and Turn off blocks?
-
@jstap Ive gone through the part 20 stuff you sent and ill be honest i have no idea what any of that means, i'm a beginner at this FXdreema stuff so I don't know what terminology like "BOOL" means. When I click on the conditions and variables all the stuff input in there is confusing to me as of now.
-
@gtoat777 bool = true/false, double = number with decimal like 0.0, int = whole number like 12,34, string = text, color = colours. this covers most. If you learn these then you'll have a good idea of when to use what.
-
@jstap ah ok thank you, looking back I think I worded my original post wrong, scrap what I said about candles the premise is basically this
Part 1: X_Ma crosses below Z_Ma
Part 2: When X_Ma crosses back above Z_Ma then BUY.Part 1.5
Only “BOOL” I guess would be that if X_Ma has not crossed back up with 5 candles then cancel the potential trade. -
@gtoat777 Yes you can use a bool condition to hold a position until it's relevent or not. Basically a condition block with MA < or> MA, then a condition block with X< or X> will give you the conditions to cover this, use as many condition blocks with < or > and different candle ID's. If you need a cross one way=t then the other you will need to use something like a flag or bool conditions.
-
@jstap https://fxdreema.com/shared/N9Pp9ZJNb Ive made a rough simple version, let me know if this is correct, i did it that if the fast ma is still below the slow ma after 3 candles is TRUE but if its below 6 candles its FALSE and i linked it back to no trade. The following condition was then if the fast ma crosses back above the slow ma
-
@gtoat777 I am unsure what you are trying to do but a constant cannot be a bool and a double at the same time, you shouldn't need a loop back to the top to achieve this.
-
@jstap hahaha my inexperience is showing, so what I was trying to program was, if it is still below the fast MA after 3 candles it’s still a go-ahead but if it’s 6 then cancel the potential trade
