Hi..
Can someone help me with the code I paste to make it by 3 contracts every time after a win and make it buy 1 contract after every loss.
Lets say I loose 1 time I whant so short down to 1 contract until it wins the first time , then I whant it to by 3 contracts everytime as long as it wins until it looses again.
After every loss=1 contract until first win
After every win=3 contracts until first loss
defparam cumulateorders = false
av1 = average[3](close)
av2 = average[20](close)
av3 = average[50](close)
x = 0.5
bull = close> av1 and close >av2 and close > av3
bear = close <av1 and close <av2 and close <av3
//n= 1
hammerup = min(open[1],close[1])>high[1]-(high[1]-low[1])/3 //and timeok
hammerupnegated= max(open,close)<min(open[1],close[1]) and abs(open-close)/(high-low)>x
cs = hammerup and hammerupnegated and bear
hammerdown = max(open[1],close[1])<low[1]+(high[1]-low[1])/3 //and timeok
hammerdownnegated = min(open,close)>max(open[1],close[1]) and abs(open-close)/(high-low)>x
cl = hammerdown and hammerdownnegated and bull
if cs then
sellshort 2 contract at market
endif
if cl then
buy 2 contract at market
endif
//TRAILING STOP
TGL =30//32
TGS= 20//32
if not onmarket then
MAXPRICE = 0
MINPRICE = close
PREZZOUSCITA = 0
ENDIF
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=TGL*pointsize then
PREZZOUSCITA = MAXPRICE-TGL*pointsize
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
PREZZOUSCITA = MINPRICE+TGS*pointsize
ENDIF
ENDIF
if onmarket and PREZZOUSCITA>0 then
EXITSHORT AT PREZZOUSCITA STOP
SELL AT PREZZOUSCITA STOP
ENDIF
SET STOP ploss 110////120//120
SET TARGET pPROFIT 52//50
Sorry, I will not answer your question today. PLEASE POST YOUR MESSAGE IN THE RIGHT FORUM AND USE THAT DAMN ‘INSERT PRT CODE’, FOR HOW LONG HAVE YOU BEEN ON THE WEBSITE? FOR 1 YEAR?? YOU MUST BE KIDDING ME! 👿 👿 👿
I guess something like this should do it:
NbrContracts = 2 //need a value for the first trade
IF PositionPerf(1) < 0 THEN
NbrContracts = 1
ENDIF
IF PositionPerf(1) > 0 THEN
NbrContracts = 3
ENDIF
if cs then
sellshort NbrContracts contract at market
endif
if cl then
buy NbrContracts contract at market
endif
Thanx tob107
I will try this later today.
Tried something simular yesterday but used ordersize insted of nbrcontracts:-)