how do i write a code to take a profit on long when prices moves up 250 pips
and on short 250 pips and then stop loss on both when prices moves against the trade 250.
ratio is 1:1
Set stop pprofit 250
Set stop ploss 250
grahal, i am still having an error on my program, can you please assists
// Conditions to enter long positions
indicator1 = Cycle(close)
c1 = (indicator1 CROSSES OVER -20)
indicator2 = CCI[20]
c2 = (indicator2 CROSSES OVER -100)
indicator3 = Cycle(close)
c3 = (indicator3 CROSSES OVER 0)
IF c1 OR c2 OR c3 THEN
BUY 2 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
Set stop Pprofit 250
Set stop ploss 250
endif
// Conditions to enter short positions
indicator5 = Cycle(close)
c5 = (indicator5 CROSSES UNDER 20)
indicator6 = CCI[20]
c6 = (indicator6 CROSSES UNDER 100)
indicator7 = Cycle(close)
c7 = (indicator7 CROSSES UNDER 0)
IF c5 OR c6 OR c7 THEN
SELLSHORT 2 CONTRACT AT MARKET
ENDIF
// Conditions to exit short positions
Set stop Pprofit 250
Set stop ploss 250
ENDIF
You’ve got two IFs and 4 EndIfs … is that the problem?
Also please use the <> Insert PRT Code button to add code to this page as then your code will be formatted and also in colour and will then be so much easier to read 🙂
GraHal is right, your 2 ENDIF at lines 19 and 37 should not be present.
Thanks guys, now is perfect. I appreciate your help.
Also it should be (target not stop) my mistake, sorry.
Set target pprofit 250
What Market and Timeframe is this Strategy optimised for please CHIFHE? I’m developing an affinity for it now! 🙂
Thanks
GraHal
is SA40 Grahal, I was doing trial and error on it. May be you can help to achieve more that 65 % on back testing it. is a 2hrs time frame.
Regards