binary-com / binary-bot

Visual automation for binary.com
binary-bot.binary.sx
MIT License
231 stars 521 forks source link

MA crossing + candle confirmation #3233

Closed navtemmt closed 3 years ago

navtemmt commented 3 years ago

Hello may I ask how to code a ma crossing for example sma 5 cross sma 15 upward and the candle closed as bullish, then next candle buy rise at candle open?

Here is my code but it didn't work out in 3 ways:

  1. The notification only shows abc which means that the way I code to identify whether the candle is bullish or bearish is not working
  2. The notification keep notifying abc in every tick of the minutes of how I coded the MA cross. However, when I check the chart the time it notify is not the time the notification appears,
  3. And also, I intended to make the trade only at current candle closing/next candle opening price, can I make it to execute the analysis and notify me every minutes instead of every tick?

image

image

I apologize for seeking the attention of yours but I tried to search various topics and apply them and it turns out like this and I have no idea how to work it out, any kind input are appreciated, thank you

cleberscr commented 3 years ago

image

navtemmt commented 3 years ago

image

Thank you for the example sir, I modified a bit from the code because I was looking for ma crossing after the candle closed instead of during running candle. However when I tried to run it in binary.com it shows error like this: image

Here is my code please kindly review, thank you

binarybot (2).zip

navtemmt commented 3 years ago

Update: this is embarrassing but the error was because I define ma1 twice instead of ma1 and ma2, now I trying to run the bot and see if its running like it intended to, will close or update depends if there are further troubleshooting needed

cleberscr commented 3 years ago

ok bro

navtemmt commented 3 years ago

Hello, after running same function code in both binary.bot and dbot I realise the outcome of the trade are different lol but then I realise dbot will change the trade options unit after a certain period (maybe because the defined contract is not available so it change i don't know) anyway I would like to just focus on binary.bot right now as it seems more user friendly. And here is the part of the bot issue I would like to talk about:

image

The bot was intended to take trade only if the previous candle close as bearish and at the same time fast ma crosses slow ma but as you can see in the photo above even though there is no crossing of ma in the chart but the bot still took trade, I found out that the reason of this is because during the running candle price move up and caused the MAs temporary crossed upward and then crossed down again and the bot recognized as MAs crossing down and bearish candle so open trade in the middle of the running candle time, this is not I intended to let it be, what I was looking is the bot only take trades if the previous candle is bearish and at the same time the MAs at previous candle is crossing, for example:

image

May I know how to code it exactly the way I wanted? Thank you

navtemmt commented 3 years ago

Here is my code, any input is appreciated, thank you. binarybot (4).zip

deny-titan commented 3 years ago

Hi @navtemmt

Here I revise your bot. But appologize I only make for Deriv Bot. Kindly extract this .ZIP and run its XML.

DBot EMA6 cross EMA14 - With Check Prev Candle Green or Red.zip

  1. My revision is adding function to check if New Candle had just appeared. If true, then bot will check value of EMA6 and EMA14.

  2. In handling EMA lists, you may forgot to use get [listname] #from end instead get [listname] #from only.

  3. About duration setup, for volatility market I set 55 seconds to wait until candle nearly closed time. You can change it in 1 minute or any duration.

I give screenshot of this bot. Thanks for sharing your strategy :)

SharedScreenshot_EMA6_cross_EMA14

navtemmt commented 3 years ago

Thank you @deny-titan ! It works exactly as it intended to and thank you for pointing out my mistake, sorry this is my first time coding and I keep thinking the from end is from the end of list but okay, now I have learnt, thank you and also i like the function of new candle, perfect for me.

Now, I would like to know if its possible to code the bot to do a one step martingale to trade the opposite direction(or the same direction) of the previous trade in case the previous trade has failed. The second trade will be taken without checking if the analysis meet requirements. Then no matter the second trade win or lose the next trade stake with reset to the default. Let me know how if its possible, thank you for your attention !

deny-titan commented 3 years ago

Thank you @deny-titan ! It works exactly as it intended to and thank you for pointing out my mistake, sorry this is my first time coding and I keep thinking the from end is from the end of list but okay, now I have learnt, thank you and also i like the function of new candle, perfect for me.

Now, I would like to know if its possible to code the bot to do a one step martingale to trade the opposite direction(or the same direction) of the previous trade in case the previous trade has failed. The second trade will be taken without checking if the analysis meet requirements. Then no matter the second trade win or lose the next trade stake with reset to the default. Let me know how if its possible, thank you for your attention !

Yes. Sure we can. It is possible. I already set up duration for 55 seconds before, and we can do purchase next contract with first opportunity after previous candle has ended. If you would like to have an example in bot, do not hesitate to let me know :)

navtemmt commented 3 years ago

Yes please @deny-titan, could you please add one step martingale to trade in same direction of the previous trade if the previous trade was lost for the following bot:

DBot.EMA6.cross.EMA14.-.With.Check.Prev.Candle.Green.or.Red.zip

Also I added macd to filter the signal where as if the ema crossing from below to above only valid when signal line is below 0 and crossing from above to below only valid when signal line is above 0, please kindly review if I coded correctly, thank you

navtemmt commented 3 years ago

Update: Sorry I have no idea why but it seems like this is the way to code for signal line below 0 when fast ma cross slow ma, please add one step martingale on this bot instead, sorry for the incovenience

DBot EMA6 cross EMA14 - With Check Prev Candle Green or Red + Macd as signal filter.zip

image

navtemmt commented 3 years ago

Update again: Okay.... I'm confuse now all the trades were working as intended but this one I don't understand why it open a rise trade because macd signal line is above 0 so the trade shouldn't be valid, can someone enlignten me please

image

deny-titan commented 3 years ago

Yes please @deny-titan, could you please add one step martingale to trade in same direction of the previous trade if the previous trade was lost for the following bot:

DBot.EMA6.cross.EMA14.-.With.Check.Prev.Candle.Green.or.Red.zip

Also I added macd to filter the signal where as if the ema crossing from below to above only valid when signal line is below 0 and crossing from above to below only valid when signal line is above 0, please kindly review if I coded correctly, thank you

Here is example block code. There are alternative to open position after first prediction fail :

  1. Open position in opposite direction until allowed max. martingale.
  2. Open position in same direction until allowed max. martingale.
  3. Open position in zig-zag until allowed max. martingale.

Also add check for Target Profit and Stop Loss (estimate).

Please try : DBot EMA6 cross EMA14 - With Check Prev Candle Green or Red with Martingale OpD-SmD-ZZg.zip

deny-titan commented 3 years ago

Update again: Okay.... I'm confuse now all the trades were working as intended but this one I don't understand why it open a rise trade because macd signal line is above 0 so the trade shouldn't be valid, can someone enlignten me please

image

Please check again. If you use MACD Array (macda) indicator, it will give you a LIST of MACD (macd it self, signal and histogram), in all previous candle data, not only MACD on 1 spot. If you need to check MACD element only in 1 spot, you may use MACD indicator instead of MACDA. But if you still prefer to use MACDA (array), you can get it by list, with this syntax get macda from end # .

deny-titan commented 3 years ago

Update again: Okay.... I'm confuse now all the trades were working as intended but this one I don't understand why it open a rise trade because macd signal line is above 0 so the trade shouldn't be valid, can someone enlignten me please image

Please check again. If you use MACD Array (macda) indicator, it will give you a LIST of MACD (macd it self, signal and histogram), in all previous candle data, not only MACD on 1 spot. If you need to check MACD element only in 1 spot, you may use MACD indicator instead of MACDA. But if you still prefer to use MACDA (array), you can get it by list, with this syntax get macda from end # .

Ups I'm sorry. There is no MACD indicator. There is only MACDA indicator which mean that you have to setup it by list procedure to get data from MACD array.

navtemmt commented 3 years ago

The MM part and after first prediction fail is really fantastic, ty for coding the tp and stop loss target as well, they are working like a like charm ! I got quite mind boogling after seeing how it works and I find myself might be spending weeks or months trying to figure it out to code them like this. A big thanks to you @deny-titan for the block, bow

Please check again. If you use MACD Array (macda) indicator, it will give you a LIST of MACD (macd it self, signal and histogram), in all previous candle data, not only MACD on 1 spot. If you need to check MACD element only in 1 spot, you may use MACD indicator instead of MACDA. But if you still prefer to use MACDA (array), you can get it by list, with this syntax get macda from end # .

I take MACD block like this: image

Then I code them like this: image

I tried to run but it seems like the macd signal line filter is not working or working in opposite way of intended because trades are taken whenever the fast ma crosses slow ma. The MACD signal should be above 0 when the fast ma crosses slow ma from above to below, MACD below 0 when the fast ma crosses slow ma from below to above, it would be better if we can code the signal line to face downward when above 0 and face upward when below 0 but I think we have to get the signal line filter to work first.. So @deny-titan what's wrong with me again? 😂

deny-titan commented 3 years ago

@navtemmt Don't you see it? Hahaha. Try this : in list macda get # from end 2 ....

deny-titan commented 3 years ago

@navtemmt Maybe I can easily create a block of bot, because I often make Binary/Deriv bot in several months before. But it seems hard for me to find a good strategy as you did. So we are the team, share best strategy and we can use it together to make money.

Regards

navtemmt commented 3 years ago

@navtemmt Don't you see it? Hahaha. Try this : in list macda get # from end 2 ....

OMG I'm a dumb -.-

@navtemmt Maybe I can easily create a block of bot, because I often make Binary/Deriv bot in several months before. But it seems hard for me to find a good strategy as you did. So we are the team, share best strategy and we can use it together to make money.

Regards

Hi teammate~ The strategy concept is to do reversal trade at ranging market or at the end of a major trend, we looking for a fast ma crossing slow ma indicating there might be a trend changing in lower timeframe, and macd signal line moving back to 0 means there is a momentum drop in higher timeframe, it would be nice to see macd signal line is above 0 but moving towards 0 as a filter then the crossing of shorter MAs confirming the trend (this is what I'm trying to build) . Then also in ranging market price reverse at support and resistance, macd signal above 0 means that we have higher possibility that the price is currently near to the resistance and again MAs crossing with bearish candle indicating the resistance is active. This approach is given that:

  1. Market in most of the time is ranging
  2. Even if there is a strong trend, I'm taking MAs crossing as a confirmation that price might reversing

I'd really appreciate your input because it really saves up a lot of time trying to figure how it works but I also feel like I need to put in some effort in it too and also to do some minor tweak without troublesome other. I'm thinking to tweak the ema parameter by decreasing the period after added the macd filter because the ema and macd settings might be too close and end up giving the same timeframe market conditions, but now the priority should be making sure the macd filter works haha, I will update you here again

deny-titan commented 3 years ago

@navtemmt Add this logic to make sure MACD move toward 0 from top position/positive : {[in list macda get # from end 4] > [in list macda get # from end 3]} AND {[in list macda get # from end 3] > [in list macda get from end 2]} as opposite direction MACD move toward 0 from bottom position/negative : {[in list macda get # from end 4] < [in list macda get # from end 3]} AND {[in list macda get # from end 3] < [in list macda get from end 2]}

If you want to check a shorter MACD period, this called as signal. You must have another MACDa indicator as addition and then change default source from macd to signal. Then you can check whether signal line crossing up or crossing down macd line like a block that you used for check crossing faster EMA and slower EMA.

Let's give a try :)

navtemmt commented 3 years ago

@deny-titan try this, I didn't add the moving toward 0 code yet but it seems to me that the result of current parameter is okay, let me know your thoughts about it, you might wanna consider to add the towards zero and test on other markets too, for now I think I will stick to this. Once again, thank you bow

DBot EMA6 cross EMA14 - With Check Prev Candle Green or Red with Martingale OpD-SmD-ZZg edited (3).zip

EDIT: I used fail prediction 2

navtemmt commented 3 years ago

@deny-titan how's thing going? Did you tried the bot?

Peacefull-Mind commented 3 years ago

Anyone Can help with the code to start trade when new candle starts ?

navtemmt commented 3 years ago

Anyone Can help with the code to start trade when new candle starts ?

Its already coded in the bot above, the function new candle is it

deny-titan commented 3 years ago

@deny-titan how's thing going? Did you tried the bot?

Sure. I already ran your bot for 4 hours. But in market Volatility 10 Index, I have lower win rate than Volatility 25 Index. Now, I'm trying to use your strategy in real forex market. EUR/USD. With 3 minutes candle time frame, without martingale nor immediately correction. I compare what our Deriv Bot does versus real time chart on TradingView.com. I build "study" indicator with EMA6 crossing EMA14 and 1-previous candle for confirmation in TradingView.com. It's look very similar and also have a same win rate both of them.

Compared in 3 last open position (my Deriv Bot had just started again this morning) ; 1=FAIL 2=SUCCESS 3=SUCCESS

Deriv-ema6-ema14 TV-ema6-ema14

But I still confused in combining EMA strategy with MACD. I will try to use MACD histogram movement to see if it proper to increase win rate of our strategy. I'll be back soon my ~teammate @navtemmt :)

navtemmt commented 3 years ago

@deny-titan Good to hear from you, just to let you know i changed from ema to esma crossing strategy in the latest version I post, and I mentioned I willing to stick to the strategy is because the result from the strategy that day is amazing

Check this: Snipaste_2021-05-05_00-32-25

Then I keep it run for a few days and also tried on the forex market but the result is not so same with the first day Snipaste_2021-05-07_20-55-11

Pardon me cuz I didnt take ss for all the day, the above two is result on volatility index 10, I didn't take forex ss but the result was a lost and the win rate is <50%

Then I tweak it by removing the MACD signal as filter and here is the result today so far: Snipaste_2021-05-08_16-07-06

All is tested using 1 step martin and immediate correction in the same direction, the win rate seems to be high in the winning day where the winning is bigger than 2:1 ratio while at losing day the ratio never exceed 2:1, the lost on forex pair are becasue of two reason in my opinion:

  1. The payout rate is much lower so 1 losing martingale require a lot of winning to cover
  2. Forex pair have low volume market where the moving average crossing each other back and forth frequently and generate a signal where the price couldnt hold until contract expiration ( they call that whipsawing )

And during the losses day I observed, the strategy is making lose trade mostly on occasion where

  1. Ranging in small timeframe
  2. Strong trend in higher timeframe against the crossing, after crossing price stopped mostly on change of polarity SnR level and then pullback to the direction of major trend

So I think we might able to increase the winning rate of the strategy by adding some ways to identify if the price is now in the middle of strong trend


For EMA crossing strategy

But I still confused in combining EMA strategy with MACD. I will try to use MACD histogram movement to see if it proper to increase win rate of our strategy. I'll be back soon my ~teammate @navtemmt :)

I agree with you. Now that I give it a second thought, EMA 6 and 14 crossing with 3 minutes expiry time indicating that we are expecting a longer/higher timeframe reversal but what MACD signal moving towards zero is just indicating price is going either retrace or reversal. It helps if we are doing a shorter period of option because no matter it is a reversal or retracement the price will at least move in opposite direction for a short period of time but no so helpful if we are doing a longer period option because moving toward zero also happen in the middle of a trend but reversal strategy with long expiration couldn't tolerate that.

Xbrmachine commented 3 years ago

OS RESULTADOS CERTAMENTE SÃO MELHORES NO BOT.BINARY

O que acham de reescrevermos este código para realizarmos testes?

@deny-titan seu codigo no deriv é impressionante, há a possibilidade de converte-lo para o bot.binary?

creio que assim possamos melhora-lo ainda mais.

@navtemmt @cleberscr

Xbrmachine commented 3 years ago

DEAR FRIENDS, FOLLOW MY CONTRIBUTION.

TRANSCREVI TO BOT.BINARY FOR BOT.BINARY.zip

OBVIOUSLY THAT NEEDS CORRECTIONS BECAUSE SOME FUNCTIONS I DID NOT UNDERSTAND, BUT WITH JUST A FEW TAPES A DEVELOPER CAN CORRECT.

THAT WILL RUN WELL LIGHTER AND WITH MORE PRECISION IN BOT.BINARY

AN ERROR IS OPENING, I BELIEVE THAT RELATED TO THE FUNCTION.

SO IT NEEDS CORRECTIONS

navtemmt commented 3 years ago

@Xbrmachine thank you for your input, it seems like there are some code in the function block are disabled, also some variable is not defined. I personally don't think it is essential to recode it in lighter way, after some time of testing, the strategy couldn't adapt to all type of market, I will close the issue now, thank you everyone for contributing.

lakeen01 commented 3 years ago

good day , how do i code engulfing pattern on support line with stochastic and adx confirmation. this is the best strategy i have ever seen in my life , to spice it up adfd mart 1 to 3 which has been giving 100% result

Nwokeson commented 2 years ago

please i need a fracta indicator for mt5

creativi77 commented 2 years ago

please i need a fracta indicator for mt5

Visit the link bellow

https://www.mql5.com/en/search#!keyword=fractal&module=mql5_module_codebase