Is there a way to get the code to automatically work out the 8am open price in the code so it adjusts itself every day?
IF time = 080000 THEN
.
. //write whatever you want to be done at 08:00am here
.
ENDIF
defparam cumulateorders=false
// --- settings
value = 7200 //daily FTSE 8am open price
myTarget = 1.25 //target profit coefficient
Capital = 25000 //capital at starting of the strategy
Risk = 2 //risk in %
StartTime = 080000
EndTime = 163000
// --- end of settings
//indis
ema20 = average[20,1]
istd = std[20]
bollup = ema20+(istd*2)
bolldn = ema20-(istd*2)
tcondition = (time>=StartTime and time<=EndTime) and (opendayofweek>=1 and opendayofweek<=5)
if tcondition then
//short orders
if high-ema20>Value*0.0002 and low>bollup then
//money managenemt
sellentry = low-1*pointsize
sellstoploss = high+2*pointsize
StopLoss = sellstoploss-sellentry
selltarget = StopLoss*myTarget
equity = Capital + StrategyProfit
maxrisk = round(equity*(Risk/100))
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
//pending order
sellshort PositionSize contract at sellentry stop
set target profit selltarget
set stop loss StopLoss
endif
//long orders
if ema20-low>Value*0.0002 and high<bolldn then
//money managenemt
buyentry = high+1*pointsize
buystoploss = low-2*pointsize
StopLoss = buyentry-buystoploss
buytarget = StopLoss*myTarget
equity = Capital + StrategyProfit
maxrisk = round(equity*(Risk/100))
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
//pending order
buy PositionSize contract at buyentry stop
set target profit buytarget
set stop loss StopLoss
endif
endif
//graph high-ema20>value*0.2 and low>bollup
Roberto,
I tried what you suggested but couldnt get it to do what I wanted? How do I get it to automatically work out the 8am open price of the FTSE so I dont have to manually put it in the “Value” of my settings before I start it in the mornings?
Sorry but Im very new to programming
Thanks,
gary
What do you want to di with the OPEN price at 8am ?
Which TF are you using?
Hi,
Its on the 5min TF and all I want is for the code to know what the 8am open price is so I dont have to manually adjust the “Value” setting each day.
Thanks
At line 11 add:
IF time = 080000 THEN
PriceAt0800 = open
ENDIF
then use variable PriceAt0800 whenever you need thet value.
In case it is not the price you need replace TIME with OPENTIME.
Many thanks Roberto.
Seems to work ok, good to learn so hopefully I will know a bit more for the future.