Hello!
Still very new here and learning so much.
I’ve been trying to find a solution to this as I am pretty sure it’s rather simple but I just can’t.
I want to short when high is >= MyLine and MA1 =< MyLine which is working fine.
But I don’t want to short if price keeps rising or MA goes above MyLine. (see attached)
I feel that I should measure MA Increase from lastbar to current or just crossing but not sure how to do it.
BarIndex?
Does anyone have any idea what to do?
Marcus
Instead of checking the two conditions when they occur, check whether they occurred on the previous bar, so you can easily tell whether the price and MA kept rising or not.
Hm! I think I understand and sounds like a good idea, does anybody have an example?
I know you do a lot on the forums Roberto, super thankful for all your help and insights.
Instead of:
IF high >= MyLine AND MA1 <= MyLine THEN
//wait to see what happens next...
ENDIF
write:
IF high[1] >= MyLine[1] AND MA1[1] <= MyLine[1] THEN //if the previous bar my conditions had met
IF high <= high[1] AND MA <= MA[1] THEN //go ahead if both the price and MA have not kept rising
//
// do whatever you want to do, here
//
ENDIF
ENDIF
Wow. In hindsight that was really simple.
Thanks a lot, will play around with this new-found knowledge!