find candle patterns for tests
- Leverage for each symbol
- 1200 subscribers!!!
- Questions from Beginners MQL5 MT5 MetaTrader 5
- www.mql5.com
Dear,
These are the conditions for Three White Soldiers:
Close[1]>Open[1] && Close[2]>Open[2] && Close[3]>Open[3] && High[1]>High[2] && High[2]>High[3] && Close[1]>Close[2] && Close[2]>Close[3]
fantastic library but I have never used mt5. It would be fantastic such a thing for mt4!
Dear,
These are the conditions for Three White Soldiers:
fantastic library but I have never used mt5. It would be fantastic such a thing for mt4!
Great.
Good luck

the first order does not seem to respect the parameters. This is the code :
//+------------------------------------------------------------------+ //| pricepattern1.mq4 | //| Copyright 2018, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2018, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict double open1, open2, open3, close1, close2, close3, low1, low2, low3, high1, high2, high3, ma; extern int stop_loss=100; extern int take_profit=100; double TP= NormalizeDouble(take_profit*10*Point,5); double SL= NormalizeDouble(stop_loss*10*Point,5); double lotto = 0.01; extern bool Compounding=true; extern double Rischio=2.0; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { ma = iMA(Symbol(),PERIOD_CURRENT,50,0,MODE_SMA,PRICE_CLOSE,1); open1 = NormalizeDouble(iOpen(Symbol(), Period(), 1), 5); open2 = NormalizeDouble(iOpen(Symbol(), Period(), 2), 5); open3 = NormalizeDouble(iOpen(Symbol(), Period(), 3), 5); close1 = NormalizeDouble(iClose(Symbol(), Period(), 1), 5); close2 = NormalizeDouble(iClose(Symbol(), Period(), 2), 5); close3 = NormalizeDouble(iClose(Symbol(), Period(), 3), 5); low1 = NormalizeDouble(iLow(Symbol(), Period(), 1), 5); low2 = NormalizeDouble(iLow(Symbol(), Period(), 2), 5); low3 = NormalizeDouble(iLow(Symbol(), Period(), 3), 5); high1 = NormalizeDouble(iHigh(Symbol(), Period(), 1), 5); high2 = NormalizeDouble(iHigh(Symbol(), Period(), 2), 5); high3 = NormalizeDouble(iHigh(Symbol(), Period(), 3), 5); if(NewBar()){ if (CheckCandle()<ma) EseguiOrdineLong(); } } //+------------------------------------------------------------------+ bool CheckCandle() { if( close1>open1 && close2>open2 && close3>open3 && high1>high2 && high2>high3 && close1>close2 && close2>close3) return true; else return false; } void EseguiOrdineLong() { if (OrdersTotal() == 0) { OrderSend(Symbol(),OP_BUYSTOP,lotto,high1,0,Ask-SL,Ask+TP,"Ordine Long",123,TimeCurrent()+3600); } } bool NewBar(){ static datetime lastbar; datetime curbar = Time[0]; if(lastbar!=curbar){ lastbar=curbar; return (true); } else{ return(false); } }
if (CheckCandle()<ma) EseguiOrdineLong(); bool CheckCandle() {
Since CheckCandle returns a bool (zero or one,) won't the condition always be true (rates above 1.00000)OrderSend(Symbol(),OP_BUYSTOP,lotto,high1,0,Ask-SL,Ask+TP,"Ordine Long",123,TimeCurrent()+3600);
- Since you are buying at the high1, shouldn't your stops be relative to that?
-
Check your return codes for errors, and report them including GLE/LE.
Don't look at it unless you have an error.
Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.
if (OrdersTotal() == 0) {
Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
- Since CheckCandle returns a bool (zero or one,) won't the condition always be true (rates above 1.00000)
because, however, opens orders even when the condition is false? thanks for your reply
- Since CheckCandle returns a bool (zero or one,) won't the condition always be true (rates above 1.00000)
- Since you are buying at the high1, shouldn't your stops be relative to that?
-
Check your return codes for errors, and report them including GLE/LE.
Don't look at it unless you have an error.
Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.
-
Using OrdersTotal directly and/or no Magic number filtering on your
OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual
trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
Thank you for your answer. I added the ( ) to true and false in the bool function, and now everything works fine even in the visual.