EA custom indicator problem beginner - page 3

 
Josip Marić:

I have deleted it and compiled the code, but i get same results again... 


It is needed by the indicator. You should check the value. I don't see where it comes from.

 

This is so weird, when i Print last price or anything else  i get correct results


2021.02.20 22:50:15.922 2021.02.17 23:59:59 BTCUSD,Daily: 48575.56



but when i do PrintFormat i get

2021.02.20 22:50:15.922 2021.02.17 23:59:59 BTCUSD,Daily: last close (-343597384) > middle band (-565150185) && last close(-343597384) < upper band (-197010131)
 
Josip Marić:

This is so weird, when i Print last price i get




but when i do PrintFormat i get

Sorry, my bad. I don't usually use PrintFormat. I wrongly assumed %d was for double.

Try this instead.

PrintFormat("last close (%g) > middle band (%g) && last close < upper band (%g)",Close[1],band_middle_prev,Close[1], band_up_prev);
Documentation on MQL5: Common Functions / PrintFormat
Documentation on MQL5: Common Functions / PrintFormat
  • www.mql5.com
PrintFormat - Common Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
mt4ski:

Sorry, my bad. I don't usually use PrintFormat. I wrongly assumed %d was for double.

Try this instead.

No worries it's fine... now i get correct results

2021.02.21 18:11:04.581 2021.02.17 23:59:59  BTCUSD,Daily: last close (52402.1) > middle band (48235.1) && last close(52402.1) < upper band (51695.2)


but my if logic doesnt work and i dont know why... it's clear that 52402.1 is higher than 51695.2, but i still get buy signal

2021.02.21 18:11:04.581 2021.02.17 00:00:00  BTCUSD,Daily: open a buy order
 
Josip Marić:

No worries it's fine... now i get correct results


but my if logic doesnt work and i dont know why... it's clear that 52402.1 is higher than 51695.2, but i still get buy signal

I think i managed to figure it out.... i had to put everything in my if logic on a previous tick, and now all the values are correct and logic works....


now it places order next day at midnight( on candle close) i don't want that, i would like that it places order at 23:59:00 same day. Do you know how to do that?

Reason: