Hi!
Dose anyone now how to code: IF the instrument you trade goes up 5% one day then dont take trades the day after.
I would be grateful for any help 🙂
Hello mikael,
That’s pretty easy. First look for the variation from yesterday:
var = 100-(DCLOSE(1) / DCLOSE(2))*100
Then test the “var” variable if it’s superior to your threshold (5% here), if so, then define the variable “allowtrade” to 0:
if ABS(var)>5 then
allowtrade = 0
else
allowtrade = 1
endif
Then you can test this variable in your order launch conditions (example):
IF buycondition AND allowtrade=1 THEN
BUY 1 SHARE AT MARKET
ENDIF
Tell me if it does the trick! 🙂
Thanks! It works :). I had thought about something like that but I couldn’t put it together.