In a system of this type:
C1 = LOW[2] > LOW[1]
C2 = LOW[1] > LOW
IF C1 AND C2 THEN
if not longonmarket AND C1 AND C2 then
buy 5 contract at High stop
endif
SET TARGET PROFIT 10
what is the code to put the stop loss below the minimum?
LeoParticipant
Veteran
SET STOP pLOSS (close-lowest[2](low))/pipsize+spread
do not forget the spread at entry the market!
Thanks Roberto and Leo. But the stop does not work as I would like. In fact I want the stop under the minimum of the entrance candle and that it remains fixed there, but now it moves.
I tried to use the stop of the post dochian channel but it does not work. This is my code
// Parameters Definition
DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
// Long Condition
C1 = Low[2] > Low[1]
C2 = Low[1] > Low
C3 = Open[2] > Close[2]
C4 = Open[1] > Close[1]
C5 = Open > Close
C6 = Low[1] > Close
IF C1 AND C2 AND C3 AND C4 AND C5 AND C6 THEN
BUY 1 CONTRACT AT High STOP
ENDIF
//Exit Profit Condition
SET TARGET PROFIT AverageTrueRange[5](close)
//Stop Loss Condition
C7 = Low - 0.1*AverageTrueRange[5](close)
if longonmarket then
sell 1 CONTRACT at c7 stop
endif
Is there a way to put the stop under the minimum of the enter candle, without it moving with the passing of the bars?
This is your modified code, it should do:
// Parameters Definition
DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
// Long Condition
C1 = Low[2] > Low[1]
C2 = Low[1] > Low
C3 = Open[2] > Close[2]
C4 = Open[1] > Close[1]
C5 = Open > Close
C6 = Low[1] > Close
IF C1 AND C2 AND C3 AND C4 AND C5 AND C6 AND Not OnMarket THEN
BUY 1 CONTRACT AT High STOP
//Exit Profit Condition
c8 = AverageTrueRange[5](close)
SET TARGET PROFIT c8
//Stop Loss Condition
C7 = Low - 0.1*c8
ENDIF
if longonmarket then
sell 1 CONTRACT at c7 stop
endif
LeoParticipant
Veteran
if longonmarket then sell 1 CONTRACT at c7 stop endif
This is a good point to ask here.
This type of function never work for me. I don not know why.
If I wish something like this, I have to put
Set stop ploss (close - (Low - 0.1*c8)/pipsize
in order to update my stop loss, or something like
If close < Low[1] - 0.1*c8 THEN
SELL AT MARKET
ENDIF
I tested the above code on both Dax and Eur/Usd, h1, and it works finely!