Hello all,
I have 2 questions I’m not able to solve. I thought to have undertood how to use summation but probably something is missing. If I want the condition:
C=Close<ExponentialAverage[20] and Close[1]<ExponentialAverage[20] and Close[2]<ExponentialAverage[20] and Close[3]<ExponentialAverage[20] and Close[4]<ExponentialAverage[20] and Close[5]<ExponentialAverage[20]
I want the price to be under EMA 20 for the last 5 candle, why PRT does not give correct to use: C=Summation [5]((Close<ExponentialAverage[20])=5)
what is wrong?
Second question, about stop loss:
c5= highest[5](high)
//condizione per entrare Long
IF NOT longonmarket and my condition then
BUY 1 CONTRACT AT (c5+0.0001*c5) STOP
longstoploss = (close – lowest[5](low) + 0.002)/pipsize
set stop ploss longstoploss
So when my condition is triggered, I want to buy when price goes over at stop limit at the highest of the last 5 candle, and stop loss at the lowest of the same 5 candles. it works sometimes but more often it opens and close position immediately.
someone can help me, please?
thank’s in advance
Alessio
why PRT does not give correct to use: C=Summation [5]((Close<ExponentialAverage[20])=5)
Are you saying you get a syntax error message?
Try GRAPH C to see when C does occur over 1oK bars or more?
more often it opens and close position immediately.
Have you used GRAPH and Cursor Details on your Conditions to easily see what is happening?
Also, in my experience, PRT can give odd results when 0.0001 of a value is used?
Try using different / higher values to get the code working okay then decrease to what values you really want to use to then see at what value the code stops working correctly?
As to the first question, the code seems correct, try placing parenthesis differently:
C=(Summation[5](Close<ExponentialAverage[20])=5)
As to the second question, (c5+0.0001*c5) can also be written as (c5*1.0001) and
longstoploss = (close – lowest[5](low) + 0.002)/pipsize
set stop ploss longstoploss
can also be written as
longstoploss = (close – lowest[5](low) + 0.002)
set stop loss longstoploss
The above examples are intended to only show different ways to achieve the same goal and to use or not conversions. Both original code snippets are correct.
The issue is usually due to not abiding by the broker’s rule to set pending orders at some distance (which may vary during the day).
Check if between the current price and your entry price there’s enough distance
hi Grahal,
I’ve graphed it and it gives always a line=0
this is the code:
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
ONCE Segnale = 0
// Conditions to enter long positions
//PRC_Wick Pressure | indicator
//23.05.2022
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//converted from pinescript
// --- settings
atrmult = 0.7 //ATR Multiplier (The Wick area is filtered on the basis of atr and this is multiplier to that ATR. The more the multiplier value, the less the signals and vice versa)
//boxlength = 16 //Length of Wick Pressure Box
rsiob = 60 //RSI based on which signnals are filtered
rsios = 40 //RSI based on which signnals are filtered
// --- end of settings
meersi = rsi[14](close)
//bullish wick pressure
rsibullishcond = meersi < rsios or meersi[1] < rsios or meersi[2] < rsios
ll3 = lowest[3](low)
lc3 = min(lowest[3](close),lowest[3](open))
C1= low<=lc3 and low[1]<=lc3 and low[2]<=lc3 and open>=lc3 and open[1]>=lc3 and open[2]>=lc3 and lc3-ll3>(atrmult*AverageTrueRange[14](close)) and rsibullishcond and close>open
if c1 then
c2 = lc3
lc3X=Barindex
c5= highest[5](high)
elsif c2=9999 then
endif
//bearish wick pressure
rsibearishcond = meersi > rsiob or meersi[1] > rsiob or meersi[2] > rsiob
hh3 = highest[3](high)
hc3 = max(highest[3](close), highest[3](open))
C3=high>=hc3 and high[1]>=hc3 and high[2]>=hc3 and open<=hc3 and open[1]<=hc3 and open[2]<=hc3 and hh3-hc3>(atrmult*AverageTrueRange[14](close)) and rsibearishcond and close<open
if c3 then
c4 = lc3
lc3Y=Barindex
c6= Lowest[5](low)
elsif c4=0 then
endif
C7=Summation [5]((Close<ExponentialAverage[20])=5)
C8=Close>ExponentialAverage[20] and Close[1]>ExponentialAverage[20] and Close[2]>ExponentialAverage[20] and Close[3]>ExponentialAverage[20] and Close[4]>ExponentialAverage[20] and Close[5]>ExponentialAverage[20]
graph c7
//condizione per entrare Long
IF NOT longonmarket and C1 and c7 then
BUY 1 CONTRACT AT (c5+0.0001*c5) STOP
longstoploss = (close - lowest[5](low) + 0.002)/pipsize
set stop ploss longstoploss
ENDIF
// Conditions to exit long positions
IF longonmarket and C3 then
sell 1 SHARES AT MARKET
ENDIF
//condizione per entrare Short
IF NOT shortonmarket and not LONGONMARKET and c3 and c8 then
sellshort 1 CONTRACT AT (c6-0.0001*c6) STOP
ENDIF
IF shortonmarket and C1 then
EXITSHORT AT MARKET
ENDIF
//set stop ploss 30
//set stop pprofit 30
now I try to modify just like roberto suggests.
I’ve graphed it and it gives always a line=0
Try below and you will get C7 = True on many occasions (DJI, 1 min TF over 1200K bars).
Your code is good, but Condition C7 does not occur 5 times in 5 bars etc?
C7=Summation [5]((Close<ExponentialAverage[20])=1)
GRAPH C7