Hi and thank you guys!
I want to code this but dont know how:
for example
BUY 1 contract when the price crosses over 100 then reaches 120 ( so basically the price has to cross over 1oo and reaches 120 to buy a contract at 120 )
CLOSE THE TRADE when the price crosses down 140 then reaches 120 ( price has to cross under 140 and reaches 120 to sell at 120)
Appreciate your help
Thank you
JSParticipant
Senior
Hi,
Try this one:
DefParam CumulateOrders=False
Once LongLevel100=0
Once ShortLevel140=0
If Close Crosses Over 100 then
LongLevel100=1
EndIf
If Close Crosses Over 120 and LongLevel100=1 then
Buy 1 contract at Market
LongLevel100=0
EndIf
If Close Crosses Under 140 then
ShortLevel140=1
EndIf
If Close Crosses Under 120 and ShortLevel140=1 then
SellShort 1 contract at Market
ShortLevel140=0
EndIf
Thank you JS,
It worked but I need the trade to be closed when the price crosses under 140 to 120 and not to sell ( now its buying 1 contract when the price crosses over 100 reaching 120, closing the buying contract and selling 1 contract when the price crosses under 140 reaching 120). what I need to change in this code please?
Thank you so much
JSParticipant
Senior
Hi,
Change line 20 to “Sell at Market”