Initial balance condition
Forums › ProRealTime English forum › ProOrder support › Initial balance condition
- This topic has 5 replies, 3 voices, and was last updated 2 years ago by egyptiantrader.
-
-
09/14/2021 at 12:00 PM #177547
Hi. I’ve edited some code I found on here to create a simple initial balance indicator “Balance 15m NASDAQ”. See below.
//15 min Time frame
//Initial Ballance calculation
//First Hour in the morning form 8:00-9:00 GMT+1 on DAXstarttime = 143000
endtime = 153000If Time = endtime then
upper=highest[4](high)
lower=lowest[4](low)
dif=round(abs(lower-upper))endif
RETURN dif
I want to use the following code as another condition before entering a trade
//Initial balance
myBalance15mNASDAQ = CALL “Balance 15m NASDAQ”
c9 = (myBalance15mNASDAQ <50)But when I back test the results are unaffected? Even when I change to <5 for example?
What am I doing wrong please?
Tried it like this too, same result?
//Initial balance
myBalance15mNASDAQ = CALL “Balance 15m NASDAQ”//Conditions to enter long positions
indicator1 = ExponentialAverage[7.8](close)
indicator2 = ExponentialAverage[12.6](close)
c1 = (indicator1 CROSSES OVER indicator2)IF c1 AND myBalance15mNASDAQ <50 AND not daysForbiddenEntry THEN
BUY 0.5 CONTRACT AT MARKET
ENDIF09/14/2021 at 3:28 PM #177561My code works fine.
Indicator:
123456789101112// MyInd indicator//15 min Time frame//Initial Ballance calculation//First Hour in the morning form 8:00-9:00 GMT+1 on DAXstarttime = 143000endtime = 153000If Time = endtime thenupper=highest[4](high)lower=lowest[4](low)dif=round(abs(lower-upper))endifRETURN difStrategy:
1234567891011121314//Initial balancemyBalance15mNASDAQ = CALL "MyInd"//Conditions to enter long positionsindicator1 = ExponentialAverage[7.8](close)indicator2 = ExponentialAverage[12.6](close)c1 = (indicator1 CROSSES OVER indicator2)IF c1 AND myBalance15mNASDAQ <50 AND not OnMarket THENBUY 0.5 CONTRACT AT MARKETENDIFset target pProfit 100set stop ploss 100graph myBalance15mNASDAQI think your code actually opened a trade, but it was left open as no SL or TP were planned (test it again and check among opened orders).
Adding SL and TP should work it out.1 user thanked author for this post.
09/14/2021 at 7:06 PM #177580Thank you.
Did you have to change anything? I’ll have a go at inserting your code tomorrow. This is only a section of the code, I have a SL set and exit parameters too further down.
Thanks again I really appreciate this, I’m very new to this with lots to learn .
09/14/2021 at 10:34 PM #177586I’ve got it working as part of my algo now. I’m not sure why it wasn’t working originally? Must have been syntax?
Thanks again.
10/18/2021 at 10:18 AM #179852Hi there,
I’ve tried a very close piece of code, but can’t manage to open a position. It might be easy however. Any adea ? thanks for your help.
IB break123456789101112131415161718192021222324DEFPARAM CumulateOrders = False // Cumul des positions désactivé//Settingsonce IBup=0once IBdown=0starttime = 080500endtime = 090000If Time = endtime thenIBup = highest[12](high)IBdown = lowest[12](low)IBdif = IBup - IBdownIBp100 = IBup + IBdifIBp200 = IBup + IBdif + IBdifIBm100 = IBdown - IBdifIBm200 = IBdown - IBdif - IBdifEndifIf not onmarket and time >=090500 and Time <=153000 and close CROSSES OVER IBup thenBUY 1 CONTRACT AT MARKETSET STOP LOSS IBdifSET TARGET PROFIT IBdifENDIF10/18/2021 at 10:37 AM #179858Everything looks ok to me. Maybe try removing the “>=090500 and Time <=153000″ and maybe use “close > IBup” instead of “close CROSSES OVER IBup”
I’m very new to this, so this is my best guess.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on