| / | Forum |
|
rusty105
2008.06.06 23:52
Is there a way to flag orders once they are placed so that my EA will handle some orders differently then others? I want my EA to be able to place an order, and once it has reached a set take profit level, flag it somehow. Then later have the EA search the open orders for this flag. I thought I could change the arrow color of the order, but found out there was no way to later check the arrow color of an order. Rusty |
|
Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization (Cont.) In this article the author continues to analyze implementation algorithms of simplest trading systems and introduces recording of optimization results in backtesting into one html file in the form of a table. The article will be useful for beginning traders and EA writers. |
|
rusty105
2008.06.09 15:52
Anybody?? Rusty |
|
BarrowBoy
2008.06.09 17:49
Rusty You can use different magic numbers to have more than one set of orders for an EA, e.g. to identify & keep separate the day-trade, swing-trade & position orders. Once on, the orders can be tracked by their magic numbers - generally speaking, once a profit level has been reached, you do something, like move the stop-loss to break-even, move a trailing stop or close...? FWIW -BB- |
|
rusty105
2008.06.09 17:57
BarrowBoy wrote:
Rusty You can use different magic numbers to have more than one set of orders for an EA, e.g. to identify & keep separate the day-trade, swing-trade & position orders. Once on, the orders can be tracked by their magic numbers - generally speaking, once a profit level has been reached, you do something, like move the stop-loss to break-even, move a trailing stop or close...? FWIW -BB- Yes, that is what I am thinkin gof doing. What I want my EA to do is find trade signals, then once they are reach a set TP Level, a different part of the EA handles the order for trailing stop, eyt. while the first part is able to find more signals. Until the open order gets 'handed off' to the trailing stop portion of the EA, the first can't find anymore signals. Rusty |
|
rusty105
2008.06.12 15:39
Anybody have more input for this?? Rusty |
|
BarrowBoy
2008.06.12 16:05
R reading that, there seems to be no need to use separate Magic Numbers. Just loop through the orders each tick or each bar, have one piece of code move the OrderStopLoss when price has moved beyond your set threshold. The code to initiate the next trade only engages when the count of open orders is zero or all open orders have their OrderStopLoss (price) equal to or better than OrderOpenPrice FWIW -BB- |
|
ukt
2008.06.12 16:14
rusty rusty105 wrote:
Anybody have more input for this?? Rusty ok then - I got wide streak paranoia about this gunk, designed my own little system - give u ideas maybe. below is some header docs part of a function... MAGIC# FORMAT: Type int can hold +21 4748 3647 idea is to split up into subfields. As of this writting the format is as follows: eg, if <=20*EAs then top two digits could be 1..20. Keeping leftmost/top2digits one less than 21 ie:20 means: We can have the other digits all set to 9. ie, 20 99 99 99 99 or 20 9999 9999 or 20 99 999 999 etc... Giving scope for info subfields in these 8 rightmost digits and up to 20 EA idents in 2 leftmost digits. We use magic# as generic value which includes the ORDER# FIELD meaning total width is 10digits. The magic# is a complete 32bit int (10digits). The ROOT excludes the ORDER# FIELD the rightmost 5digits. Let: dExpertId = 13, iSymbolId=12, iPeriodId=5, then: dExpertId * 100 000 000 = 1300000000 iSymbolId * 1 000 000 = 0012000000 iPeriodId * 100 000 = 0000500000 total = 1312500000 This leaves 1..99,999 as an unique increment value for EACH NEW order so that MAGIC# is basically unique... Note: zero is not considered valid order# magic# 1 1312500001 2 1312500002 ... 1312500000 99998 1312599998 99999 1312599999 **Ninety Nine Thousand nine hundred and ninety nine orders** at any one time should be enough...! iMagicNumber = EAID_DIVISOR*eiExpertId + SYM_DIVISOR*iSymbolId + PERIOD_DIVISOR*iPeriodId; *** The MagicRoot is equal to iMagicNumber "without" the ORDER# FIELD *** Why? root is static and order# is different for each order METHOD: Fields can be isolated, by using integer arithmetic. see: isMyMagicRoot(),getMagicRoot(),getMagicOrderNum() See eaDefines.mqh for .._DIVISOR #define's to hold 100000,... |
|
rusty105
2008.06.12 22:18
ukt wrote >>
rusty ok then - I got wide streak paranoia about this gunk, designed my own little system - give u ideas maybe. below is some header docs part of a function... VERY interesting !! Some ideas indeed !! I'll need a couple days to sort something out, thanks, one quick question, can you change a majic number once it is assigned? |
|
BarrowBoy
2008.06.12 22:31
Hey - let me do the easy ones ukt :) Rusty - sorry no, the magic number cannot change - even on split & partial closure of a lot. -BB- |
|
rusty105
2008.06.12 22:50
BarrowBoy wrote >>
Hey - let me do the easy ones ukt :) Rusty - sorry no, the magic number cannot change - even on split & partial closure of a lot. -BB- Thanks, I didn't think so :( I need to be able to change the "Status" of an order, yet not split it up. i may have to use an array, or write/read to a file. Rusty |
|
ukt
2008.06.12 23:01
BB - ah cmon - best bit today: track down function > hilite > copy > alt-tab back to browser > paste! For me was great as thinking done moons ago...lol
Rusty - " I need to be able to change the "Status" of an order, yet not split it up" well, my magic over top in a way, idea 4 u: could you maybe log "Status" in bit mapped chunk of magic#? like my use of subfields... just idea as not know how much Status info need to pack... edit.1: please disregard above - am blind and not thinking, geeez.... is obvious yes? magic# (as i damn well know - but not think about as wanna help - silly boy ;) is cast in concrete/is immutable. so how about terminal global vars? the name maybe keyed to magic# so easy to associate - they then have persistence for order lifetime and maybe 64bits then enough? and course, arrays, files too are ways. grrreeate trades ahead for all, yes? :o)) |