using swap rate as acondition
-
Does anyone know how to use swap rate as a condition to open a trade i.e open trade if swap rate is positive and ither condition are meet. I have founbd this thread https://fxdreema.com/forum/topic/7233/find-swap-rates-before-order-opened which has some custoe code that might well no what i want but i don't actually know how to use it.
-
Try this:

But be aware that more than probably you will need a 'For each trade' block above it. Pink options usually require that pink block.
-
Thanks but i think that is for the swap on an open trade. I need to now to the swap rate before the trade is opened.
-
I havefound a script that i can potentially use with some modification -the script simply outputs the swap value for long and short and colours the object green if its positive and red if negative. - the problem is it is a script i dont think i can import it as an indicator. Is there any way of converting this script.
-
Easiest to use this custom function:
https://fxdreema.com/shared/ExwS5XMUc

Here is more info about all available symbol info codes:
https://docs.mql4.com/constants/environment_state/marketinfoconstants#enum_symbol_info_doubleYou will need a DOUBLE -type data, because that data can use decimal points.
This is long swap, I challenge you to find out the short swap

-
@roar would you just change out long for short in the code?
-
@wralyn yup

-
@roar nice I haven't played around with the custom code but it seems like it adds a whole new level of versatility to the software.
-
@wralyn I agree. You don't need custom code in every project, but it does at least simplify certain things. Its pretty easy to google the necessary function from docs.mql4.com
-
@roar noted.!
-
@roar Thank you, that was exactly what i needed and has helped me understand using the variable a little more. Thank you thotheothers that helped also.