Hello. I have been running my own basic trading systems on UK and USA markets, 4 hours, 1 trade open at a time, for a while now but have recognised that I need to add in a stop loss after a certain period of time. I have been researching all the stop loss coding but I am struggling to make a start.
I want to include additional code that does the following:
Open 1 trade and ONLY after 30 periods, close it at a loss of 0.5%
Could someone please assist me – either direct me to a reference or provide some simple code to adapt.
Thankyou
Sean
There you go:
ONCE WaitingPeriods = 30
ONCE Tally = WaitingPeriods
IF StrategyProfit <> StrategyProfit[1]
Tally = 0
ENDIF
IF Not OnMarket THEN
Tally = Tally + 1
ELSE
Tally = 0
ENDIF
IF MyLongConditions AND Not OnMarket AND (Tally > WaitingPeriods) THEN
BUY....
StopLoss = close * 0.005 //0.5%
SET STOP LOSS StopLoss
ENDIF
IF MyShortConditions AND Not OnMarket AND (Tally > WaitingPeriods) THEN
SELLSHORT....
StopLoss = close * 0.005 //0.5%
SET STOP LOSS StopLoss
ENDIF