This is my strategy:
IF c1 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF c2 THEN
SELL AT MARKET
ENDIF
IF c3 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
IF c4 THEN
EXITSHORT AT MARKET
ENDIF
Can someone please code the following:
If c2 is not met, I want c1 to keep buying 1 contract at 50 point intervals until c2 is met e.g whether it buys 1 or 10 times
And the same with selling
If c4 is not met, i want c3 to keep selling short at 50 point intervals until c3 is met.
Thank you,
Rob
To write code, please use the <> “insert PRT code” button yo make code easier to read and understand.
I moved your topic to the english forum, instead of the french one, since you used english.
You seem to be asking the same question in two different topics. Did my answer here not do what you requested?
programming moving average & multiple entries
Please try not to double post as it just results in confusion for everyone.
I don’t know whether Vonasi’s answer in the other post was what you were looking for, but I wrote something while Vonasi was typting and I’m posting it:
FastAvg = average[20,0](close)
SlowAvg = average[100,0](close)
c1 = FastAvg > SlowAvg
c2 = FastAvg CROSSES UNDER SlowAvg
c3 = FastAvg < SlowAvg
c4 = FastAvg CROSSES UNDER SlowAvg
ONCE Treshold = 50 * pipsize
IF Not OnMarket THEN
MyPrice = 0
TradeON = 1
ELSIF OnMarket AND MyPrice = 0 THEN
MyPrice = TRADEPRICE
ENDIF
IF LongOnMarket THEN
TradeON = 0
x = close - MyPrice
IF x > Treshold THEN
TradeON = 1
MyPrice = MyPrice + Treshold
ENDIF
ENDIF
IF c1 AND TradeON THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF c2 THEN
SELL AT MARKET
ENDIF
IF ShortOnMarket THEN
TradeON = 0
x = MyPrice - close
IF x > Treshold THEN
TradeON = 1
MyPrice = MyPrice - Treshold
ENDIF
ENDIF
IF c3 AND TradeON THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
IF c4 THEN
EXITSHORT AT MARKET
ENDIF
graph tradeprice
graph MyPrice
graph close
graph treshold
graph TradeON