BCParticipant
Master
I am stucking on a basic coding…how to code below?
Buy 1 contract after Bullcondition appear BullCandleStyle.
Thanks
Bin
//Buy condition
Bullcondition=low crosses over Average[20](close)
//Candle style
BC1 = Close[1] < Close[2]
BC2 = Close > Close[1]
BullCandleStyle=BC1 and BC2
//Long Entry
IF after Bullcondition appear BullCandleStyle then
BUY 1 CONTRACT AT market
Endif
Any good or am I misunderstanding the request or the strategy?
IF Bullcondition AND BullCandleStyle then
BUY 1 CONTRACT AT market
Endif
BCParticipant
Master
Hi Grahal
Thanks, your suggestion is buy when both condition appear at same time.
But my idea is: When bullcondition, hold the buy until BullCandle Style appear.
IF Bullcondition Then
BarIndex = BullIndex
Endif
If BullCandleStyle and BarIndex > BullIndex Then
BUY 1 CONTRACT AT Market
Endif
Or something similar … I’ll sleep on it! 🙂
How long you want to hold the condition? Couldn’t be forever as BullCondition may not be valid, so maybe you need below?
You can optimise variable x
IF Bullcondition Then
BarIndex = BullIndex
Endif
If BullCandleStyle and ((BarIndex - BullIndex) < x) Then
BUY 1 CONTRACT AT Market
Endif
As your Bull Condition is …
Bullcondition=low crosses over Average[20](close)
why not just use …
Bullcondition = Low > Average[20](close)
Then you could have …
If BullCondition and BullCancdle Them
Buye 1 Share at Market
Endif
BCParticipant
Master
Thanks Grahal, actually the bull condition contain 3MA and need confirm by a candle pull back.
I found this intersting strategy from internet and seem workable, you can take a look via below link.
http://www.tradingstrategyguides.com/big-three-trading-strategy/
Yeah link looks good, easy to read and well laid out website … I’ll digest better with my tea tonight. 🙂 It looks a lot like the Alligator Strategy?
I felt the simplistic explanation of the Alligator a bit naff when I first studied it, but I’m pleased to say it has stuck with me and I guess that is the reason (naff)! 🙂
https://www.forextraders.com/forex-education/forex-indicators/alligator-indicator-explained/
There is an Indicator on here …
https://www.prorealcode.com/prorealtime-indicators/bill-williams-alligator/
There is also the PRT Default … see attached.
GraHal
BCParticipant
Master
Hi Grahal
I am working on big three strategy, however I stuck on the stop loss coding.
eg: When long, stop loss should be (MA80-tradeprice), but Prorealtime only read previous tradeprice instead of current tradeprice.
😫😫😫
Didnt use TradePrice(1) did you?
If you put your code on here (using <> icon) we may be able to spot the reason?
BCParticipant
Master
yes, I try blank, (1) and (0), still not work.
I am out for some alcohol to relax, will post code later a moment later.
BCParticipant
Master
Hi GraHal
Here u go.
defparam preloadbars = 3000
defparam cumulateorders =false //true //false
//Big Three MA
FMA=Average[20](close) //green coloured(0,255,0)
MMA=Average[40](close)//blue coloured(0,0,255)
SMA=Average[80](close)//red coloured(255,0,0)
//High Low Bar Setting
CP=10
//Long Entry
if BC and BCandle then
//BUY min(25,PositionSizeLong) CONTRACT AT MARKET
BUY 1 CONTRACT AT MARKET
StopLossLong=Tradeprice-SMA[1]
//takeProfit = takeProfitLong
endif
//Long Exit
if LongonMarket and close crosses under SMA then
sell at market
endif
//short entry
if SC and SCandle then
//SELLSHORT min(25,PositionSizeShort) CONTRACT AT MARKET
SELLSHORT 1 CONTRACT AT MARKET
StopLossShort=SMA[1]-Tradeprice
//takeProfit = takeProfitShort
endif
//Short Exit
if ShortonMarket and close crosses over SMA then
exitshort at market
endif
// Stop Loss
if LongonMarket then
SET STOP LOSS StopLossLong
endif
if ShortonMarket then
SET STOP LOSS StopLossShort
endif
graph SMA
graph Tradeprice
graph StopLossLong
graph StopLossShort
BCParticipant
Master
miss condition
defparam preloadbars = 3000
defparam cumulateorders =false //true //false
//Big Three MA
FMA=Average[20](close) //green coloured(0,255,0)
MMA=Average[40](close)//blue coloured(0,0,255)
SMA=Average[80](close)//red coloured(255,0,0)
//High Low Bar Setting
CP=10
//Buy Signal
B1=low > SMA and low>MMA and low>FMA
B2=high >= highest[CP](high)
BC=B1 and B2
//Buy Candle
BC1 = Close[1] < Close[2]
BC2 = Close > Close[1]
BC3 = Close > Open
BCandle = BC1 and BC2 and BC3
//Sell Signal
S1=high < FMA and high<MMA and high<SMA
S2=low <= lowest[CP](low)
SC=S1 and S2
//Sell Caandle
SC1 = Close[1] > Close[2]
SC2 = Close < Close[1]
SC3 = Close < Open
SCandle = SC1 and SC2 and SC3
//Long Entry
if BC and BCandle then
//BUY min(25,PositionSizeLong) CONTRACT AT MARKET
BUY 1 CONTRACT AT MARKET
StopLossLong=Tradeprice-SMA[1]
//takeProfit = takeProfitLong
endif
//Long Exit
if LongonMarket and close crosses under SMA then
sell at market
endif
//short entry
if SC and SCandle then
//SELLSHORT min(25,PositionSizeShort) CONTRACT AT MARKET
SELLSHORT 1 CONTRACT AT MARKET
StopLossShort=SMA[1]-Tradeprice
//takeProfit = takeProfitShort
endif
//Short Exit
if ShortonMarket and close crosses over SMA then
exitshort at market
endif
// Stop Loss
if LongonMarket then
SET STOP LOSS StopLossLong
endif
if ShortonMarket then
SET STOP LOSS StopLossShort
endif
graph SMA
graph Tradeprice
graph StopLossLong
graph StopLossShort
what instrument / market and timeframe you running this on?
I got it going, see attached. You check it out to see if it’s doing what you want?
Here are the code differences …
40 StopLossLong = Tradeprice - (TradePrice-SMA[1])
53 StopLossShort= Tradeprice - (SMA[1]-Tradeprice)
BCParticipant
Master
Hi Grahal
I found below work.
//Long Entry
if BC and BCandle then
BUY 1 CONTRACT AT MARKET
BuyPrice=Close
StopLossLong = BuyPrice - SMA
endif